New methods:
drawpixels.pixel(buffer, x, y, r, g, b, a) to draw a pixel to the buffer
drawpixels.color(buffer, x, y) to read color from buffer
drawpixels.line(buffer_info, x0, y0, x1, y1, red, green, blue, alpha) to draw a line to the buffer
drawpixels.bezier(buffer_info, x0, y0, xc, yc, x1, y1, red, green, blue, alpha) draw a bezier line between two points and one control point
Moreover:
Refactoring and code clearing
Performance optimisation!!!
Bug fixing
I’ve been playing with this a while and it’s so much fun! I’m stuck trying to create “canvas” instances dynamically. This doesn’t work because the pixels are tied to this bitmap:
What’s drawn on one canvas is therefore also drawn to the other. One solution is to use two separate sprites. In my case that won’t work, because my (ambitious) plan is to create (literally) millions canvases dynamically, each different from the others.
Is it possible to create a texture on the fly somehow? I noticed this is possible in GUI, but I haven’t been able to find a similar way to do it with a go.
Edit: If textures cannot be created at runtime, I suppose one workaround would be to re-use a pool of 10 sprites or so, and make sure none of the visible canvases are using the same sprite.
Well you’re going to have to limit yourself. Each canvas takes up texture memory and there’s only a certain amount of it available. Think of a max amount that you can support (think about target platform and min GPU memory you want to support) and design around that.
I’m testing your “draw pixel” code. I just want to draw a filled rectangle but it’s not showing me anything… I followed the instruction provided in the github…
could you please help me? I put a snapshot of the code below:
Wow. Only just saw this project for the first time. So awesome @AGulev !!! Really like the toolkit.
Using it to test a little genetic evolution program. Thanks! WIll post some screenshots once working.
Oh, so much fun. Thanks again. I’ll put this project up sometime soon. Want to let the original author of biosim know what Ive done - its all MIT, but I like to make sure peoples work is recognised.