Created
April 13, 2014 14:20
-
-
Save micromeeeter/10586065 to your computer and use it in GitHub Desktop.
http://level3.perfume-global.com/ のチカチカするロゴをP5で作りましたがプログラムが粗雑でもっといい方法があるのではないかと思います。ご教授お願いします…
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
void setup(){ | |
colorMode(HSB,360,100,100); | |
size(600,600); | |
background(1,0,99); | |
stroke(189,99,99); | |
strokeWeight(1); | |
frameRate(20); | |
} | |
void draw(){ | |
//画面をリセットする | |
noStroke(); | |
fill(1,0,99,100); | |
rect(0,0,600,600); | |
stroke(); | |
//原点を中央に | |
translate(300,300); | |
//チカチカのランダム | |
float a = random(3); | |
float b = random(3); | |
float c = random(3); | |
float d = random(3); | |
float e = random(3); | |
float f = random(3); | |
float g = random(3); | |
float h = random(3); | |
float i = random(3); | |
float j = random(3); | |
float k = random(3); | |
float l = random(3); | |
//頂点を一個おきに配置 | |
float x0 = 250 * cos(radians(30*0)); | |
float y0 = 250 * sin(radians(30*0)); | |
float x1 = 250 * cos(radians(30*1)); | |
float y1 = 250 * sin(radians(30*1)); | |
float x2 = 250 * cos(radians(30*2)); | |
float y2 = 250 * sin(radians(30*2)); | |
float x3 = 250 * cos(radians(30*3)); | |
float y3 = 250 * sin(radians(30*3)); | |
float x4 = 250 * cos(radians(30*4)); | |
float y4 = 250 * sin(radians(30*4)); | |
float x5 = 250 * cos(radians(30*5)); | |
float y5 = 250 * sin(radians(30*5)); | |
float x6 = 250 * cos(radians(30*6)); | |
float y6 = 250 * sin(radians(30*6)); | |
float x7 = 250 * cos(radians(30*7)); | |
float y7 = 250 * sin(radians(30*7)); | |
float x8 = 250 * cos(radians(30*8)); | |
float y8 = 250 * sin(radians(30*8)); | |
float x9 = 250 * cos(radians(30*9)); | |
float y9 = 250 * sin(radians(30*9)); | |
float x10 = 250 * cos(radians(30*10)); | |
float y10 = 250 * sin(radians(30*10)); | |
float x11 = 250 * cos(radians(30*11)); | |
float y11 = 250 * sin(radians(30*11)); | |
//一つの点と対角線をグループにして描画 | |
for(int z = 0;z < 12;z++){ | |
float x = 250 * cos(radians(30*z)); | |
float y = 250 * sin(radians(30*z)); | |
if(a>1){ | |
line(x,y,x0,y0); | |
}else{ | |
}if(b>1){ | |
line(x,y,x1,y1); | |
}else{ | |
}if(c>1){ | |
line(x,y,x2,y2); | |
}else{ | |
}if(d>1){ | |
line(x,y,x3,y3); | |
}else{ | |
}if(e>1){ | |
line(x,y,x4,y4); | |
}else{ | |
}if(f>1){ | |
line(x,y,x5,y5); | |
}else{ | |
}if(g>1){ | |
line(x,y,x6,y6); | |
}else{ | |
}if(h>1){ | |
line(x,y,x7,y7); | |
}else{ | |
}if(i>1){ | |
line(x,y,x8,y8); | |
}else{ | |
}if(j>1){ | |
line(x,y,x9,y9); | |
}else{ | |
}if(k>1){ | |
line(x,y,x10,y10); | |
}else{ | |
}if(l>1){ | |
line(x,y,x11,y11); | |
}else{ | |
} | |
} | |
//上を回転させて描画 | |
for(int z = 0;z < 12;z++){ | |
float x = 250 * cos(radians(30*z)); | |
float y = 250 * sin(radians(30*z)); | |
//45度回転 | |
rotate(PI/4); | |
if(a>1){ | |
line(x,y,x0,y0); | |
}else{ | |
}if(b>1){ | |
line(x,y,x1,y1); | |
}else{ | |
}if(c>1){ | |
line(x,y,x2,y2); | |
}else{ | |
}if(d>1){ | |
line(x,y,x3,y3); | |
}else{ | |
}if(e>1){ | |
line(x,y,x4,y4); | |
}else{ | |
}if(f>1){ | |
line(x,y,x5,y5); | |
}else{ | |
}if(g>1){ | |
line(x,y,x6,y6); | |
}else{ | |
}if(h>1){ | |
line(x,y,x7,y7); | |
}else{ | |
}if(i>1){ | |
line(x,y,x8,y8); | |
}else{ | |
}if(j>1){ | |
line(x,y,x9,y9); | |
}else{ | |
}if(k>1){ | |
line(x,y,x10,y10); | |
}else{ | |
}if(l>1){ | |
line(x,y,x11,y11); | |
}else{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment