What I Learn from Dom-to-image
the github repo url is below:
GitHub - tsayen/dom-to-image: Generates an image from a DOM node using HTML5 canvas
Why I want to Read the Source Code of This Project?
I use this lib to generate the image of mgclub post content. And When I use it, I found that it will throw out error because of CORS.
Finally, I convert the images to base64 in the server side to solve the problem.
But I wonder how the lib realize the function and how can I solve the CORS in other way.
So I start reading the source code of the project.
RoadMap
README
the README.md
is a good choice to start.
it tells me
- what dom-to-image it is and what can it do
- install
- the way to use it (pass in Dom node and render options)
- how it works (svg foreignObject)
Directory Structure
So we should read the src/dom-to-image.js
mainly.