0x0funky/agent-sprite-forge / skills/video2dsprite
video2dsprite
VerifiedTurn one approved master still into a character's whole animated sprite set - one image-to-video clip per action (idle, walk, run, attack, jump, hurt, cast and so on), all from that still, generated through generate2dmedia route_media.py (the xAI API when a key is configured, else the local Grok CLI) - then gate each take, key it with a soft matte, register it to the master, pick loops or retime actions, finish (HD by default, pixel on request) and package fixed-canvas frames, alpha WebM, packed MP4 for iPhone and a PNG fallback with engine metadata and a JS runtime. Also processes a supplied clip. Use for character and creature animation, fluid motion and any video-to-sprite work. Not for FX, icon or prop sheets (generate2dsprite), maps or plate loops (generate2dmap), code-drawn animation (codeart2d, only on request) or calling a video API by itself (generate2dmedia).
references/packed-alpha-runtime.js
View on GitHub/* Packed-alpha playback, thin wrapper. The application owns scheduling, visibility
and disposal. Serve media over HTTP(S); cross-origin media needs CORS (set
crossOrigin before src). The shared WebGL compositor and its Canvas2D CPU
fallback live in runtime/packed-alpha-webgl.mjs; timing, distance-driven walks,
hit-stop and transitions live in runtime/forge-runtime.mjs. Copy the runtime
folder together with this file. */
import {sharedPackedAlphaCompositor} from './runtime/packed-alpha-webgl.mjs';
export {
createPackedAlphaCompositor, packedGeometry, sharedPackedAlphaCompositor,
} from './runtime/packed-alpha-webgl.mjs';
/* Rebuild a straight-alpha drawable from a packed video (RGB left, alpha right).
metadata is animation.json packedAlpha (2.0 or 3.0) or a mobilePackedAlpha
tier. Returns {drawable, update(force), lease, release()}: update() composes
the current decoded frame when it changed and returns true, and throws when
the video does not match the metadata. Every drawable shares one WebGL
context (options apply to the first call); without WebGL the CPU path is used.
Pass options.compositor to use your own compositor. */
export function createPackedAlphaDrawable(video, metadata, options = {}) {
const compositor = options.compositor ?? sharedPackedAlphaCompositor(options);
const lease = compositor.acquire(video, metadata, options);
return {
drawable: lease.drawable,
lease,
update(force = false) {
const composed = lease.update(force);
if (lease.failed()) throw new Error(lease.error);
return composed;
},
release: () => lease.release(),
};
}
/* Draw a frame at its original source anchor, excluding even-padding pixels.
sourceRect allows a single union crop without changing world placement.
drawable is a canvas/image, or the object createPackedAlphaDrawable returns
(its lease region is then used, which also covers scaled mobile tiers).
options: {region: [x, y, w, h] of the drawable that maps onto sourceRect,
snap: true to place the frame on whole pixels (pixel art at integer scale)}.
For Three.js use the drawable as a CanvasTexture with the same geometry. */
export function drawAnchoredFrame(ctx, drawable, clip, x, y, scale = 1, options = {}) {
const source = drawable && drawable.drawable ? drawable.drawable : drawable;
const leaseRegion = drawable && (drawable.region ?? drawable.lease?.region);
const [rx, ry, rw, rh] = clip.sourceRect;
const [ax, ay] = clip.sourceAnchor;
const content = clip.contentSize ?? [source.width, source.height];
const [sx, sy, sw, sh] = options.region ?? leaseRegion ?? [0, 0, content[0], content[1]];
let left = x + (rx - ax) * scale, top = y + (ry - ay) * scale;
if (options.snap) {
left = Math.round(left);
top = Math.round(top);
}
ctx.drawImage(source, sx, sy, sw, sh, left, top, rw * scale, rh * scale);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |