Advertisement
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>
- <style>
- body{
- margin:0px;
- }
- </style>
- <script>
- document.addEventListener('DOMContentLoaded', function(){
- const canvas = document.getElementById("canvasId");
- const context = canvas.getContext("2d");
- // context.beginPath();
- // context.fillStyle = "red";
- // context.arc(100, 100, 50, 0, 2*Math.PI);
- // context.fill();
- // context.closePath();
- // context.beginPath();
- // context.fillStyle = "yellow";
- // context.arc(100, 100, 40, 0, 2*Math.PI);
- // context.fill();
- // context.closePath();
- context.fillStyle = "red";
- // context.fillRect(x_goren_lqv_ygyl, y_goren_lqv_ygyl, shirochina, visochina);
- // let w = 10;
- // for (let i = 0; i < 5; i++) {
- // // i = 0, 1, 2, 3, 4 -> 50, 160, 270, 380, 490
- // context.fillRect(50 + i*(w+10), 50, w, 50);
- // }
- // let h = 10;
- // for (let i = 0; i < 5; i++) {
- // // i = 0, 1, 2, 3, 4 -> 50, 160, 270, 380, 490
- // context.fillRect(300, 100 + i*(h + 10), 100, h);
- // }
- let x = 0;
- let w = 50;
- for (let i = 0; i < 5; i++) {
- // i = 0, x = 0, w = 50
- // i = 1, x = 60,w = 60
- // i = 2, x = 130, w = 70,
- // i = 3, x = 210, w = 80,
- // i = 4, x = 300, w = 90;
- context.fillRect(x, 0, w, w);
- w = w + 10;
- x = x + w;
- }
- w = 50;
- x = canvas.width - w;
- y = 0;
- for (let i = 0; i < 5; i++) {
- context.fillRect(x, y, w, w);
- w = w + 10;
- x = x - 10;
- y = y + w;
- }
- w = 50;
- x = canvas.width - w;
- y = canvas.height - w;
- for (let i = 0; i < 5; i++) {
- context.fillRect(x, y, w, w);
- w = w + 10;
- x = x - w - 10;
- y = y - 10;
- }
- w = 50;
- x = 0;
- y = canvas.height - w;
- for (let i = 0; i < 5; i++) {
- context.fillRect(x, y, w, w);
- w = w + 10;
- y = y - w - 10;
- }
- x = canvas.width/2;
- y = canvas.height/2;
- r = 100;
- for (let i = 0; i < 5; i++) {
- context.beginPath();
- context.fillStyle = i % 2 == 0 ? "green" : "red";
- context.arc(x, y, r, 0, 2*Math.PI);
- context.fill();
- context.closePath();
- r = r - 20;
- }
- });
- </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
Advertisement