fillRect() to draw filled rectangles on CanvasDrag the sliders to change the X, Y position and height width values for the rectangle.
x: Position from left edge of the canvas, y: Position from Top edge of the canvas, width : Width of the rectangle. height : Height of the rectangle. fillStyle() can be used to add colour or colour gradient to rectangle, default is black. var my_canvas=$('#my_canvas').get(0)
var gctx = my_canvas.getContext("2d");
gctx.beginPath();
gctx.fillStyle = 'red';
gctx.fillRect(20,20,50,50);
This article is written by plus2net.com team.
|