Description

The fillRect() method draws a "filled" rectangle. The default color of the fill is black. Before the positions, you can specify the color of the rectangle

Usage

Parameters

  • x {Integer|String} optional

    (optional) The x-coordinate of the upper-left corner of the rectangle. By default, 0.

  • y {Integer} optional

    (optional) The y-coordinate of the upper-left corner of the rectangle. By default, 0.

  • width {Integer} optional

    (optional) The width of the rectangle, in pixels. By default, width of the element.

  • height {Integer} optional

    (optional) The height of the rectangle, in pixels. By default, height of the element.

  • radius {Integer} optional

    (1.3.1) (optional) Defines a rounding on the corners of the rectangle.

Returns

CanvasEngine.Element

Example

In ready method.

Example 1 :

var el = this.createElement(100, 100);
el.fillStyle = "red";
el.fillRect();

Example 2 :

var el = this.createElement(100, 100);
el.fillRect("red");

Example 3 :

var el = this.createElement(100, 100);
el.fillRect("red", 10, 25);

Example 4 :

var el = this.createElement(100, 100);
el.fillRect(10, 25);

Example 5 :

var el = this.createElement();
el.fillRect(10, 25, 100, 100);

Example 6 :

var el = this.createElement();
el.fillRect("red", 0, 0, 100, 100, 10);

Discussion