Home Web Front-end H5 Tutorial HTML5 canvas method usage guide_html5 tutorial skills

HTML5 canvas method usage guide_html5 tutorial skills

May 16, 2016 pm 03:47 PM
canvas html5

Canvas method

save() saves the state of the current environment

restore() returns the previously saved path status and attributes

createEvent()

getContext() returns an object indicating the API necessary to access the drawing function

toDataUPL() returns the URL of the canvas image

Properties and methods of line styles

Attribute:

lineCap sets or returns the end point style of the line

lineJoin sets or returns the corner type created when two lines intersect

lineWidth sets or returns the width of the current line.

miterLimit sets or returns the maximum miter length

Color, style and shadow properties and methods

Attributes

fillStyle sets or returns the color, gradient or pattern used to fill the painting

strokeStyle sets or returns the color, gradient or pattern used for strokes

shadowColor sets or returns the color used for shadows

shadowBlur sets or returns the blur level used for shadows

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

createLinearGradient() creates a linear gradient (used on canvas content)

createPattern() repeats the specified element in the specified direction

createRadialGradient() creates a radial/circular gradient (used on canvas content)

addColorStop() specifies the color or stop position in the gradient object

Path method

fill() fills the current drawing (path)

stroke() draws a defined path

beginPath() starts a path, or resets the current path

moveTo() moves the path to the specified point in the canvas without creating a line

closePath() creates a path from the current point back to the starting point

lineTo() adds a new point and creates a line from that point to the last specified point

clip() cuts an area of ​​any shape and size from the original canvas

quadraticCurveTo() creates a second Bezier curve

bezierCureTo() creates a sub-square Bezier curve

arc() creates arc/curve (used to create circles or partial circles)

arcTo() creates an arc/curve between two tangents

isPointInPath() returns a Boolean value if the specified point is located in the current path

Rectangle

Rect() creates a rectangle

fillRect() draws a "filled" rectangle

strokeRect() draws a rectangle (no fill)

clearRect() clears the specified pixels within the given rectangle

Set text properties and methods

Attributes:

font Sets or returns the current font attribute of the text content

textAlign sets or returns the current alignment of text content

The textBaseline setting returns the current text baseline used when drawing text.

Method:

fillText() draws "filled" text on the canvas

strokeText() draws text on the canvas (no padding)

measureText() returns an object containing the specified text width

Conversion method

scale() scales the current drawing to a larger or smaller size

rotate() rotates the current drawing

translate() remaps the (0,0) position of the floral shirt

transform() replaces the current transformation matrix of the drawing

setTransform() resets the current transformation to the identity matrix. Then run transform()

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1270
29
C# Tutorial
1250
24
Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

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

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

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.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

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

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

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

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

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

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

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

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

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

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

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

See all articles