Created
August 24, 2020 13:40
-
-
Save Skoatpalace/0da01c32e63a0d0939667ba5091229cc to your computer and use it in GitHub Desktop.
Canvas HTML Rosace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canvas = document.getElementById('canvas'); | |
let ctx = canvas.getContext('2d'); | |
canvas.width = window.innerWidth; | |
canvas.height = window.innerHeight; | |
let x = 0; | |
let y = 0; | |
let tour = 0; | |
ctx.translate(innerWidth / 2, innerHeight / 2); | |
const draw = () => { | |
requestAnimationFrame(draw); | |
ctx.beginPath(); | |
ctx.strokeStyle = '#EDF5E1'; | |
ctx.arc(x, y, 100, 0, 2 * Math.PI); | |
ctx.stroke(); | |
ctx.rotate(10 * Math.PI / 180); | |
tour = tour + 10; | |
if (tour > 7200) { | |
return; | |
} | |
if (tour % 360 === 0) { | |
x += 7; | |
y += 7; | |
} | |
} | |
draw(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="fr"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Rosace canvas</title> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; | |
} | |
html, body { | |
width: 100%; | |
height: 100%; | |
} | |
canvas { | |
display: block; | |
background: #282828; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id="canvas"></canvas> | |
<script src='app.js'></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment