planjure
planjure copied to clipboard
Redraw only the difference on world update
The slow part about re-drawing the world (mostly noticeable on large world) is the tight loop through each element in world. What we need to do is only draw the difference.
So we can have a difference hash that only contains the updated rows/cols:
{row-idx-0 {col-idx-0 3
col-idx-1 5 ...}
row-idx-1 { ... }
...}
The canvas component updates on :world changes. So doing a diff would be difficult. We also currently redraw the complete canvas every time. This makes it easy to not have to think about redrawing paths, etc.
Ideas:
- Build a diff of
:worldwith one in history. Would need to add history to app-state, perhaps. - Keep a
:world-diffin the app state. - On path re-draw, we would need to also update the world tiles that were affected.