Detailed explanation of HTML5 canvas (2)
The previous article gave a brief introduction and usage examples of the canvas tag, but in fact the usage of canvas is very powerful. Many cool HTML5 animations and games are made based on canvas. . Therefore, I decided to continue writing two canvas-related blog posts to consolidate the foundation of canvas.
This article mainly introduces the related properties and usage of canvas.
Color, Style and Shading
Properties | Description |
---|---|
fillStyle | Sets or returns the color, gradient, or pattern used for fill painting |
strokeStyle | Sets or returns the color, gradient, or pattern used for strokes Gradient or pattern |
shadowColor | Set or return the color used for shadow |
shadowBlur | Set Or returns the blur level used for the shadow |
shadowOffsetX | Sets or returns the horizontal distance of the shadow from the shape |
shadowOffsetY | Sets or returns the vertical distance of the shadow from the shape |
Method | Description |
---|---|
createLinearGradient() | Create a linear gradient (used on canvas content) |
createPattern() | Repeat the specified element in the specified direction |
createRadialGradient() | Create a radial/circular gradient (used on canvas content) |
addColorStop() | Specify the color and stop position in the gradient object |
Line style
Properties | Description |
---|---|
lineCap | Set or return the end endpoint style of the line |
lineJoin | Set or return the corner type created when two lines intersect |
lineWidth | Set or return the current line width |
miterLimit | Set or return the maximum miter length |
Rectangle
Method | Description |
---|---|
Create a rectangle | |
Draw a "filled" rectangle | |
Draw a rectangle (no fill) | |
Clear the specified pixels within the given rectangle |
Description | |
---|---|
Fill the current drawing (path) | |
Draw the defined path | |
Start a path, or reset the current path | |
Move the path to the specified point in the canvas, no Create a line | |
Create a path from the current point back to the starting point | |
Add a new point and create a line in the canvas from that point to the last specified point | |
Clip any from the original canvas Areas of shape and size | |
Creating quadratic Bezier curves | |
Create cubic Bezier curve | |
Create arc/curve (used to create a circle or partial circle) | |
Create an arc/curve between two tangents | |
If specified Returns true if the point is in the current path, otherwise returns false |
Description | |
---|---|
Scale the current drawing to a larger or smaller size | |
Rotate the current drawing | |
Remap the (0,0) position on the canvas | |
Replace the current transformation matrix of the drawing | |
Reset the current transformation to the identity matrix . Then run transform() |
textAlign | |||||||||||||||||||||||||||||||||||||||||||||||
textBaseline | |||||||||||||||||||||||||||||||||||||||||||||||
Method | Description |
---|---|
On canvas Draw "filled" text | |
Draw text on canvas (without fill) | |
Returns an object containing the specified text width |
Description | |
---|---|
height | |
data | |
getImageData() | |
putImageData() | |
globalCompositeOperation | |
restore() | |
createEvent() | |
toDataURL() | |
The above is the detailed content of Detailed explanation of HTML5 canvas (2). 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.

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

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 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 Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

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