EN
Данное содержимое не доступно на вашем языке, используйте версию на английском языке.

Methods

This section contains the HTML5 Canvas methods reference documentation.

Note  If you are developing on an intranet and have rendering issues for HTML5, you can add a "meta http-equiv-'X-UA-Compatible' content= " meta command, followed by "IE=edge" to the <head> block of a webpage to force a Windows Store app using JavaScript to use the latest standards. For more information about document compatibility, see Defining Document Compatibility.

In this section

TopicDescription

addColorStop

Adds the specified colors and the position in a CanvasGradient object.

arc

Adds points to a path that represents an arc.

arcTo

Draws an arc of a fixed radius between two tangents that are defined by the current point in a path and two additional points.

beginPath

Resets the current path.

bezierCurveTo

Adds a point to the current subpath by using the specified control points that represent a cubic Bézier curve.

clearRect

Clears the pixels on a CanvasRenderingContext2D object within a given rectangle.

clip

Specifies a new clipping region.

closePath

Closes the current subpath and starts a new subpath that has a start point that is equal to the end of the closed subpath.

createImageData

Returns a CanvasImageData object with the given dimensions in CSS pixels.

createLinearGradient

Creates an object that represents a linear gradient to use in a canvas context.

createPattern

Returns a CanvasPattern object that repeats the specified element in the specified direction.

createRadialGradient

Returns an object that represents a radial or circular gradient to use in a canvas context.

drawImage

Draws a specified image onto a canvas.

fill

Fills subpaths by using the current fill style.

fillRect

Paints a rectangle onto a CanvasRenderingContext2D object by using the current fill style.

fillText

Renders filled text to the canvas by using the current fill style and font.

getContext

Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.

getImageData

Returns an ICanvasImageData object that represents the pixel data for the specified rectangle on a canvas. Use the data property to get a CanvasPixelArray to manipulate individual pixel data.

getLineDash

Gets the current dash list sequence.

isPointInPath

Determines if the specified point is in the current path.

lineTo

Adds a new point to a subpath and connects that point to the last point in the subpath by using a straight line.

measureText

Returns a CanvasTextMetrics object that contains the width of the specified text.

moveTo

Creates a new subpath by using the specified point.

msToBlob

Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing.

putImageData

Paints the data from a specified CanvasImageData object onto a canvas.

quadraticCurveTo

Adds a point to the current subpath by using the specified control points that represent a quadratic Bézier curve.

rect

Creates a new closed rectangular subpath.

restore

Returns previously saved CanvasRenderingContext2D path state and attributes.

rotate

Rotates the current context coordinates (that is, a transformation matrix).

save

Saves the state of the current context.

scale

Scales the current context by the specified horizontal (x) and vertical (y) factors.

setLineDash

Sets the current line dash pattern. The argument is a even numbered list of distances to alternately produce a line and a space.

setTransform

Resets the current transformation matrix of the context back to the identity matrix and then multiplies it by the specified matrix.

stroke

Renders the strokes of the current subpath by using the current stroke styles.

strokeRect

Creates an outline of the specified rectangle on a canvas by using the current stroke, line width, and join styles.

strokeText

Renders the specified text at the specified position by using the current font, lineWidth, and strokeStyle property.

toDataURL

Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element (such as img).

transform

Modifies the transformation matrix of the current context.

translate

Specifies values to move the origin point in a canvas.

 

 

 

Показ:
© 2014 Microsoft