I’m currently working on an integrated Sprites Editor for a game engine I’m building on top of MG. For general idea:
My current concern is to implement brushes for tools used to draw shapes (pixel, line, ellipse, roundrect…)
As I have little experience on this particular topic (brushes) I’ve decided to post a question regarding efficiency of my (naive) solution I am about to implement. So here comes nothing:
- draw shape with 1px basic brush
- get rectangular bounding box of that shape
- set blendmode to replace instead of blend (to preserve selected opacity)
- iterate each pixel of BBox in temporary preview layer, should the pixel be not transparent, store it in queue
- while that queue.count > 0
5.1) apply brush to currently dequeued pixel
Another possible approach would be to give up rendering via primitives and implement proper algorithms for rendering shapes (bresenham for line/circle…), here I would obtain all pixels much faster, the difference would scale with size of the shape itself.
I am probably missing something, generally I’d like to at least partially support features of
Thanks for reading this post.