TazeTSchnitzel/PictoSwap — pull request #14 by notanypotato (2014-10-26 21:58:45+00:00)
Title: Refactoring

I did some minor refactoring in preparation to add an eraser tool (which I haven't actually done yet.)

Changes made:

Added htdocs/Page.js and htdocs/PencilTool.js

htdocs/script.js:

- Changed so that it no longer uses global variables inkUsage, empty, pages, pageInkUsage

- Now uses 4 PictoSwap.Page objects to store it all

- global variable page is now an array of PictoSwap.Page objects

- renamed page to currentPage

(How this works:
What was in page[i] is now in pages[i].data.
What was in pageInkUsage[i] is now in pages[i].inkUsage.
What was in empty is now in pages[i].empty. )

- Encapsulated the code inside of canvas.onmousemove/up/down into a new PencilTool object

- Canvas.onmousemove/up/down now calls currentTool.onCanvasMousemove/up/down (currentTool is currently just pencilTool but in the future can be changed)

Everything else should still be the same.