Canvas draws a simple picture with a lot of code. Why use canvas? Why not use a picture directly
If it’s a one-time drawing, of course.
What if the picture needs to be adjusted in the future? Draw another picture? If you use canvas, you can adjust the parameters.
What if you want to do animation, draw a lot of pictures and switch them regularly? If you use canvas, write a piece of code logic.
Our former project team wanted to make a graphical display of the percentage effect. It is similar to a measuring cylinder filled with liquid, 0% empty and 100% full. So one of my colleagues asked the artists to draw a hundred pictures. Later, I used canvas to make only two pictures.
Heart pain artist
OK, so you can make this with pictures and control the mouse
Since something exists, it has the value of existence.
Canvas is a major feature of HTML5, and it must have its own requirements. Let me say one of my projects.
Main requirements of the project: image OCR recognition, which displays the results of image recognition in the front section. The result of recognition is the content in the image. The front section needs to mark each content with a red marking line. The front section gets the coordinates, and then what lines are drawn with? Use canvas. When the professionals view the results, they are very picky. They need to scale and move the image, and the wireframe also needs to scale and move accurately, and the magnification of the image does not lead to the magnification of the wireframe. That is to say, after the image is scaled, the wireframe needs to relocate the coordinates and draw new lines. No canvas, I can’t get so many images.
The use of canvas can be summarized as follows:
- It is often used for dynamic and special effect image display. There’s a sense of comics.
- Canvas can do 3D effects
- Canvas has the function of canvas, which can design online drawing
- The canvas is gorgeous…
Pictures are dead, gifs are semi alive but can’t interact with users. Canvas can interact with users, and it’s not as simple as drawing a picture, and it can achieve powerful graphic effects (including 3D). This is definitely not a picture can do.