SVG whiteboard implementation with TypeScript and SVG.js
Edvards Lazdans
- June 16, 2017
The task
In a recent project cliizii.com, a client wanted to have a drawing board in a browser where multiple users could interact. They already had a working whiteboard that we would have to redesign and improve according to their needs.
The problem
When we looked at the whiteboard’s code, we immediately realized that it wouldn’t work in the long term. The library version being used was quite outdated and a lot of source code could be improved since there are new patterns invented in that area. The update to the newest version wasn’t possible without digging into the version history.
The solution
After talking with the client, we got approval to start over from scratch. But that raised a few questions – Canvas or SVG? Are there ready-to-go implementations? If not, what libraries could we use for our own implementation?
Canvas or SVG?
The first question we addressed was whether to use Canvas or SVG. We dug into Google to search for ways that Canvas and SVG were being used and the differences between them. Then we decided which was the best for our needs. We found this article that summarizes our research quite well. Here are the relevant things for our drawing board that we discovered:
The problem
When we looked at the whiteboard’s code, we immediately realized that it wouldn’t work in the long term. The library version being used was quite outdated and a lot of source code could be improved since there are new patterns invented in that area. The update to the newest version wasn’t possible without digging into the version history.
The solution
After talking with the client, we got approval to start over from scratch. But that raised a few questions – Canvas or SVG? Are there ready-to-go implementations? If not, what libraries could we use for our own implementation?
Canvas or SVG?
The first question we addressed was whether to use Canvas or SVG. We dug into Google to search for ways that Canvas and SVG were being used and the differences between them. Then we decided which was the best for our needs. We found this article that summarizes our research quite well. Here are the relevant things for our drawing board that we discovered:
- Canvas doesn’t scale. Using it with mobile would be impossible/hard to implement.
- SVG elements allow us to interact with them (different DOM events, CSS styles, etc.).
- Because SVG is an XML format, it makes saving to a database pretty easy. This also helps us create PDFs from the drawing board.
Result
You can check out the working example when you sign up for a free trial at cliizii.com. Thank you!Table of content
Need a Reliable Tech Partner?
Access senior engineers, architects, and project managers to build scalable software products.
Explore Engagement Models