Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 36e0868

Browse files
added my JS project
beautiful butterfly
1 parent 6dff235 commit 36e0868

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

‎Butterfly_/Butterfly.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script>
5+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script>
6+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.sound.min.js"></script>
7+
<script src="Butterfly.js"></script>
8+
9+
<link rel="stylesheet" type="text/css" href="style.css">
10+
<style> body {padding: 0; margin: 0;} </style>
11+
</head>
12+
<body>
13+
</body>
14+
</html>

‎Butterfly_/Butterfly.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var yoff=0;
2+
var q=1;
3+
var z=1;
4+
var j=91;
5+
function setup(){
6+
createCanvas(windowWidth,windowHeight);
7+
frameRate(25);
8+
9+
}
10+
function draw(){
11+
translate(width/2,height/2);
12+
13+
rotate(PI/2);
14+
background(0);
15+
stroke(225);
16+
strokeWeight(3);
17+
beginShape();
18+
var xoff =0;
19+
dx=0.02;
20+
for(var l=0;l<10;l++)
21+
{
22+
for(var a=-PI/2;a<PI/2;a+=PI/100){
23+
var n=noise(xoff,yoff);
24+
var r=sin(a*2)*map(n,0,1,100,300);
25+
var x= r*cos(a);
26+
var y=sin(yoff)*r*sin(a);
27+
xoff+=dx;
28+
vertex(x,y);
29+
30+
}
31+
if(j%90==0){
32+
q=z=1;
33+
}
34+
if(q==z){
35+
var a=random(0,255);
36+
var b=random(0,255);
37+
var c=random(0,255);
38+
z=z+90;
39+
}
40+
41+
j++;
42+
fill(a,b,c,1000);
43+
for(var a=PI/2;a<= (3*PI)/2;a+=PI/100){
44+
var n=noise(xoff,yoff);
45+
var r=sin(a*2)*map(n,0,1,100,300);
46+
var x= r*cos(a);
47+
var y= sin(yoff)*r*sin(a);
48+
xoff-=dx;
49+
vertex(x,y);
50+
}
51+
}
52+
endShape();
53+
yoff+=0.07;
54+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /