antirez / load81

SDL based Lua programming environment for kids similar to Codea
BSD 2-Clause "Simplified" License
599 stars 62 forks source link

support offscreen drawing #48

Open rlane opened 12 years ago

rlane commented 12 years ago

Redirecting drawing operations to another SDL surface is useful for postprocessing effects, procedurally generated sprites, etc.

Proposed API:

canvas = createCanvas(width, height) canvas = loadImage(filename) previous = selectCanvas(canvas) drawCanvas(canvas, x, y) canvas = rotozoomCanvas(srcCanvas, angle, zoom, smooth)

The implementation would mostly be a renaming of the existing sprite code and adding more bindings. The sprite() function could be reimplemented in Lua in terms of the canvas functions.

Let me know what you think of this API. I'll implement it in the next couple of days.

r043v commented 12 years ago

would be easy to selectCanvas function only replace current "fb->screen" surface into the l81 struct, all other code would still working out of the box,

after, internally, load81 would reset screen surface to the real one, and do the flip, on each frame

will be ok for blit onto canvas, but not offer any way for blitting canvas on screen with sprite method if this one still keep filename as unique argument.

i started implement dynamic argument in the lua api for my image/anims/maps code, for accept indiferently filenames or image id

maybe time, now as this is project start to define goal and future api of load81.