waterbearlang / waterbear

Visual block syntax for programming languages
http://waterbearlang.com/
358 stars 88 forks source link

Draw to an offscreen buffer #1272

Closed dethe closed 8 years ago

dethe commented 8 years ago

Would like two new blocks, one wb-expression which creates a new, blank image (given a width and height), and one wb-context which takes an image and creates a temporary <canvas> and context based on that image, allowing us to draw on it. Combined we could then create re-usable images for things like tiling or sprites.

CelticMinstrel commented 8 years ago

The idea seems good, but I'm a little confused about your proposed way of doing it. If you're drawing to an offscreen canvas, you'll later want to copy the contents of that canvas to the screen. How would you do that with your proposed method?

dethe commented 8 years ago

Treat the canvas as an image and draw it like any other image.

CelticMinstrel commented 8 years ago

So... would you say that the context block also declares a variable to be used in the scope it appears in?

dethe commented 8 years ago

No, you initialize an image, pass it to the context, draw on it, then use the image wherever you like. That's how I'm getting around the scope problem for now, we'll see how it works in practice.

CelticMinstrel commented 8 years ago

Ah, so the context block needs to take an image as an argument. I guess that makes sense, then.

dethe commented 8 years ago

Fixed in #1276