rect method

void rect(
  1. num x,
  2. num y,
  3. num w,
  4. num h,
)

The CanvasRenderingContext2D.rect() method of the Canvas 2D API adds a rectangle to the current path.

Like other methods that modify the current path, this method does not directly render anything. To draw the rectangle onto a canvas, you can use the CanvasRenderingContext2D.fill or CanvasRenderingContext2D.stroke methods.

Note: To both create and render a rectangle in one step, use the CanvasRenderingContext2D.fillRect or CanvasRenderingContext2D.strokeRect methods.

Implementation

external void rect(
  num x,
  num y,
  num w,
  num h,
);