width property

Gets or sets the width of a canvas element on a document.

This property is read/write.

 

Syntax

HRESULT put_width(
  [in]          long v
);

HRESULT get_width(
  [out, retval] long *width
);

Property values

Type: long

The width of a canvas element, in pixels.

Standards information

Remarks

Note  The maximum size of the rendered area on a canvas is from 0,0 to 8192 x 8192 pixels, regardless of the size of the canvas. For example, a canvas is created with a width and height of 8292 pixels. A rectangular fill is then applied as "ctx.fillRect (0,0, canvas.width, canvas.height)".Only the area within the coordinates (0, 0, 8192, 8192) can be rendered, leaving a 100 pixel border on the right and bottom of the canvas.

 

Note  When sizing a canvas, use the canvas IHTMLCanvasElement::width and IHTMLCanvasElement::height properties to get your initial size. You can use CSS to set the width and height, but it will scale the image rather than set the canvas size itself. The default width and height are 300px by 150px.