Making the application interactive
Now we have the ability to make any number of shapes and present them to the user. This, however, is very limited in functionality and doesn't allow for any interaction between the application and the consumer. Most drawing applications allow for basic movement and resizing of the objects on the canvas. This requires the application to redraw itself each time the user attempts to change one of the shapes.
The engine
To handle the drawing and updating of the canvas state, we will need a new type that is focused around maintaining this. This type, which we'll call CanvasEngine
, should have a very simple abstraction since it only needs to perform a few basic tasks: drawing the canvas, clearing the canvas, and receiving ...
Get TypeScript Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.