Skip to content

Alternative Rendering

Gavin Rough edited this page Dec 19, 2019 · 1 revision

Rendering outside of a web browser

Pixel Animator is primarily meant to be used with a web browser, but it's not a requirement. Perhaps you'd like to render your animation in some other form, like a video file or animated GIF.

The PixelAnimator function accepts a DOM node as its second argument. That argument is optional, and if you omit it you'll get a kind of iterator function in return. The iterator returns raw color data one frame at a time, which you're free to handle however you like.

// Get a frame iterator for the animation
const getNextFrame = PixelAnimator({ colorize });

// Call it repeatedly to get one frame of color data at a time
const frame1 = getNextFrame();
const frame2 = getNextFrame();
const frame3 = getNextFrame();
Clone this wiki locally