-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made background to homepage sphirograph
- Loading branch information
1 parent
bdaba7a
commit e9e3423
Showing
5 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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,11 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.min.js" integrity="sha512-WJXVjqeINVpi5XXJ2jn0BSCfp0y80IKrYh731gLRnkAS9TKc5KNt/OfLtu+fCueqdWniouJ1ubM+VI/hbo7POQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="spirograph.js"></script> | ||
<style> body {padding: 0; margin: 0;} </style> | ||
</head> | ||
|
||
<body> | ||
|
||
</body> | ||
</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,51 @@ | ||
let r=10; | ||
let rDir=1; | ||
let rEnabled=1; | ||
let rMax; | ||
let R=2; | ||
let RDir=10; | ||
let REnabled=0; | ||
let RMax; | ||
let O=30; | ||
let ODir = 2.5; | ||
let OMax; | ||
let frame = 0; | ||
let frameMod = 20; | ||
function setup() { | ||
createCanvas(windowWidth,windowHeight); | ||
rMax = windowWidth/4; | ||
OMax = windowWidth/4; | ||
R=rMax+1; | ||
background(0); | ||
stroke(0,100,0); | ||
frameRate(30); | ||
} | ||
|
||
function draw() { | ||
background(0); | ||
for (let t = 0; t < (100 / frameMod) * (frame % frameMod); t+= 0.025) { | ||
line(x(t),y(t),x(t+0.025),y(t+0.025)); | ||
} | ||
if (frame % frameMod == 0) { | ||
r +=rDir; | ||
if (O == r) { | ||
r += rDir; | ||
} | ||
if (r >= rMax || r <= 9) { | ||
rDir *= -1; | ||
O += ODir; | ||
if (O >= r || O <= 0) { | ||
ODir *= -1; | ||
} | ||
} | ||
} | ||
frame++; | ||
} | ||
|
||
function x(t) { | ||
return windowWidth/2 + (R-r)*Math.cos(t) + O*Math.cos(((R-r)/r)*t); | ||
} | ||
|
||
function y( t) { | ||
return windowHeight/2 + (R-r)*Math.sin(t) + O*Math.sin(((R-r)/r)*t); | ||
} |