Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - <!DOCTYPE html>
 - <html lang="en">
 - <head>
 - <meta charset="UTF-8">
 - <meta name="viewport" content="width=device-width, initial-scale=1.0">
 - <title>Document</title>
 - <script>
 - document.addEventListener('DOMContentLoaded', function(){
 - const canvas = document.getElementById("canvasId");
 - const context = canvas.getContext("2d");
 - context.fillStyle = 'green';
 - // context.fillRect(0, 0, 50, 50);
 - // context.fillRect(60, 0, 60, 60);
 - // context.fillRect(130, 0, 70, 70);
 - // context.fillRect(210, 0, 80, 80);
 - // context.fillRect(300, 0, 90, 90);
 - let x = 0, y = 0, w = 50, h = 50;
 - for(let i = 0; i < 5; i++){
 - context.fillRect(x, y, w, h);
 - w = h = w + 10;
 - x = x + w;
 - }
 - y = 0, w = 50, h = 50, x = canvas.width - w;
 - for(let i = 0; i < 5; i++){
 - context.fillRect(x, y, w, h);
 - x = x - 10;
 - w = h = w + 10;
 - y = y + h
 - }
 - w = 50, h = 50, x = canvas.width - w, y = canvas.height - h;
 - for(let i = 0; i < 5; i++){
 - context.fillRect(x, y, w, h);
 - w = h = w + 10;
 - y = y - 10;
 - x = x - w - 10;
 - }
 - x = 0, w = 50, h = 50, y = canvas.height - h;
 - for(let i = 0; i < 5; i++){
 - context.fillRect(x, y, w, h);
 - w = h = h + 10;
 - y = y - h - 10;
 - }
 - x = canvas.width/2, y = canvas.height/2, r = 100;
 - for(let i = 0; i < 5; i++){
 - context.beginPath();
 - context.arc(x, y, r, 0, Math.PI*2);
 - context.fill();
 - context.closePath();
 - r = r - 20;
 - context.fillStyle = context.fillStyle == '#008000' ? '#FF0000' : '#008000';
 - console.log(context.fillStyle);
 - }
 - });
 - </script>
 - <style>
 - #canvasId{
 - background:black;
 - }
 - </style>
 - </head>
 - <body>
 - <canvas id="canvasId" width="800" height="600"></canvas>
 - </body>
 - </html>
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment