electronicwhisper / recursive-drawing

568 stars 77 forks source link

Uneditable outwardly recursive object #2

Open paulbatum opened 12 years ago

paulbatum commented 12 years ago

So its reasonably straightforward to make an outwardly recursive object where you can zoom out indefinitely, but somehow I ended up making one where editing is disabled (hovering over objects doesn't do anything). Also, the preview on the left and all the previews on the right became blank.

http://imgur.com/gdA3h

electronicwhisper commented 12 years ago

Hi @paulbatum thanks for the report. This is a tough issue that I probably won't be able to attack in the near term, so for now I'll give a technical brain dump for anyone who might be interested.

I think this could possibly be fixed by making a smarter rendering algorithm.

The way rendering works now, it renders the recursion to a certain depth every frame (i.e. every time there is a change, for example when you're dragging a shape). I do this because if it rendered past that depth, the UI would start becoming unresponsive. The shapes I calculate for rendering at this stage are also used to calculate if the mouse is hovering over a shape (using Canvas API's isPointInPath).

While the UI is idle, the renderer will keep rendering the recursion (on a superimposed canvas layer). This is why you'll see that when you drag something around and then let go or pause, more recursion will happen. However, because there get to be lots of shapes in this stage, I don't check to see if the mouse is over these further rendered shapes. (You'll see all these shapes grey out when you hover the mouse over an originally rendered shape.)

Usually these shapes end up being really small so one wouldn't want to manipulate them. Additionally, there are some unsolved issues with the numerical constraint solver that make manipulating shapes very far down in the recursion tree problematic.

But I think this could eventually be fixed. The renderer would have to be smarter about what parts of the recursion tree are worth rendering and testing for mouse interaction. This would improve performance in addition to fixing the problem you mention. Also, some of the constraint solving would need to be revisited to deal with manipulations deep in the recursion tree.

forresto commented 11 years ago

This might happen less if the default scale of a newly-added recursion was .999.

Are there any cases where you want to scale >1? I always made them smaller.