This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb81677
commit 6a109c6
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>HacktoberFox | Sampson Orson Jackson</title> | ||
<link rel="stylesheet" href="index.css"> | ||
</head> | ||
|
||
<body> | ||
<canvas id="canvaz"></canvas> | ||
</body> | ||
<script src="index.js"></script> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
window.addEventListener("load", (e) => { | ||
const canvazEl = document.getElementById("canvaz"); | ||
|
||
if (!canvazEl?.getContext) return; | ||
|
||
// Resizing | ||
sizeCanvaz(canvazEl); | ||
|
||
const context = canvazEl.getContext("2d"); | ||
const radian = Math.PI / 180; | ||
let r = 50; | ||
let x = -50; | ||
let startAngle = 90 * radian; | ||
let endAngle = 2 * Math.PI; | ||
let currentAngle = 0; | ||
let oldTime = getTime(); | ||
|
||
// x, y, radius, startAngle, endAngle [, counterclockwise] | ||
// the x and y position is relative to the center of the circle | ||
setInterval(() => { | ||
let newTime = getTime(); | ||
let diff = newTime - oldTime; | ||
|
||
context.fillStyle = "#000"; | ||
context.fillRect(0, 0, context.canvas.width, context.canvas.height); | ||
|
||
context.beginPath(); | ||
context.fillStyle = "red"; | ||
context.arc(x++, context.canvas.height / 2, r, startAngle + currentAngle, endAngle + currentAngle); | ||
context.fill(); | ||
|
||
currentAngle += 0.1; | ||
currentAngle %= 2 * Math.PI; | ||
|
||
if (x >= context.canvas.width + r) { | ||
x = -r; | ||
} | ||
}, 10); | ||
}); | ||
|
||
const sizeCanvaz = (el) => { | ||
el.width = "350"; | ||
el.height = "350"; | ||
}; | ||
|
||
const getTime = () => (new Date()).getTime(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"art_name": "HacktoberFox", | ||
"author_name": "Sampson Orson Jackson", | ||
"author_github_url": "https://github.com/dev-sampsonorson" | ||
} |