BrandonArmand / Binari

Interactive code editor with a live binary tree visual designed to teach new developers the fundamentals of Data Structures.
https://binari.dev
MIT License
181 stars 113 forks source link

#11 optimize position calc #44

Closed georgeCog closed 4 years ago

georgeCog commented 4 years ago

Position, layer and position from left to right data is now calculated for each node on canvas initilisation so this information can be used to render the tree. Additionally all nodes are stored in an array so there is the option of iteration through all nodes or traversing the tree. New script in draw is not identical to the previous in terms of spacing but is very similar and can be easily adjusted using variables at the top of the script. Pretty sure this is clearly commented. (Position from left to right is position as if the layer was full)

netlify[bot] commented 4 years ago

Deploy request for binari accepted.

Accepted with commit 5f6893b06e2101a03f170cba7b690c6175a51909

https://app.netlify.com/sites/binari/deploys/5ef3917deb87580008dac9cf

BrandonArmand commented 4 years ago

@georgeCog Hey man, fantastic! I have reviewed the code and it looks great, I will test it and merge sometime this week when I have availability (:

The initial code was done as an MVP sorta deal, so it was very unoptimized but workable. Glad to see it getting some love finally.

I eventually want to animate the visuals in some way to give it some life and design the container to make it look nicer, but one step at a time.

Thanks!