conifer icon indicating copy to clipboard operation
conifer copied to clipboard

Layers

Open nbrr opened this issue 3 years ago • 1 comments

Here is a PR so that we can study difficulties related to #9.

Canvas holds a vec of Layer. Layers are meant to represent a depth in the scene to draw. Each layer has an array of Option<Pixel> representing whether a layer has something to display on a particular pixel. They are meant to be ordered so that only the top-most layer is will actually be displayed.

I think eventually it'd be best that each layer has a reference to the canvas that holds it so that we can manipulate the layers on their own. In the approach I took it is necessary to go through the canvas because I attempt to keep the canvas' pixels up to date regarding which is the top-most pixel as I update some layer's pixel. I went this way because for-looping the whole thing to determine the top-most pixels each time I want to display was way too slow. However in the drag example I want to clear a layer from the line drawn at the previous iteration. I used a for-loop and this step makes it very slow. I'm not sure what to do. Maybe use a map of coordinated -> pixels so that active pixels of a layer are easily accessible without need to go through the whole thing? It doesn't seem convenient though. I am also worried that we might eventually run into this problem anyway at some point since writing something on the whole screen does seem like something trivial one would want to do. How is the helloworld example actually performing since that's what it does?

nbrr avatar Aug 30 '20 17:08 nbrr