


HTML5 Programming Practice Part 2 - Using animation to switch picture code cases
The knowledge mainly used in this article
This article mainly uses the knowledgeCanvasThe drawImage method in API is briefly introduced below.
Use the drawImage method to draw images in the Canvas API. This is an overloaded method. , defined as follows:
1 2 3 |
|
The first method has three parameters. The first parameter is the image to be drawn (it can also be a video element), and x and y are the starting coordinates of the image in the canvas.
The second method has five parameters. The first three have the same meaning as the first method. w and h refer to the width and height of the image when drawing, which can be used for image scaling.
The third method has nine parameters. The first parameter has the same meaning as the first two methods. The first four of the last eight parameters take a rectangle on the source image, and the last four parameters are used to define a rectangle on the canvas. , the function of the entire method is to copy part of the source image (the part defined by the second to fifth parameters) to the canvas (the part defined by the last four parameters). This article mainly uses the third one. The method completes drawing.
Source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
Code analysis
DrawleftToRight(): The effect is to display from left to right, mainly combining the fourth parameter and the fourth parameter. The eight parameters gradually increase from 0 to the width of the picture
drawtopToBottom(): The effect is to display from top to bottom, mainly increasing the fifth and ninth parameters from 0 to the height of the picture
Drawhcenter(): The effect is to display horizontally from the middle to both sides, mainly reducing the second and sixth parameters from half the image width to 0, and increasing the fourth and eighth parameters from 0 to the image width
Drawvcenter(): The effect is to display from the middle to both sides, similar to the previous one
drawhwindow(): The effect is horizontal blinds, similar to the principle of drawhcenter method, except that it is done from multiple places here
drawvwindow(): The effect is vertical blinds, the principle is similar to the drawvcenter method, except that it is done from multiple places here
drawhvwindow(): The effect is blinds, it is drawhwindow() Combination with drawvwindow()
Welcome everyone to add and improve
Since the picture is placed on other websites, it loads slowly and is not so smooth. You can change it when using it. This
mapThe above is the detailed content of HTML5 Programming Practice Part 2 - Using animation to switch picture code cases. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.
