Skip to main content

Posts

Showing posts with the label canvas line

Canvas Method to Draw different shape like Rectangle, filled rectangle, circle, line, setting style to canvas element

Canvas Example to draw R ectangle Draw rectangle ctx.rect(x, y, width, height); ctx.stroke(); stroke() is used to draw outline of shape to define color of stroke you can use method  ctx.strokeStyle="white"; Fill rectangle: method is used to filled shape with color default color is black context.fillRect(x, y, width, height); ctx.fill(); : using this method you can fill any shape  with color default color is black. you can define fill color of any shape using method ctx.fillStyle="red";   Stroke rectangle ctx.strokeRect(x, y, width, height);   <DOCTYPE html> <html lang="en"> <head>         <style>          #myCanvas{background-color:orange;           border: 2px solid black;           width:800px;      ...