Last active
May 15, 2016 10:35
-
-
Save dj0/fe9c46f67297c512c31f77da855d2697 to your computer and use it in GitHub Desktop.
縞(空間周波数と速度が可変)
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
/*要・controlP5ですを*/ | |
import controlP5.*; | |
ControlP5 cp5; | |
float sliderValue = 1; //空間周波数スライダー用 | |
float sliderspeed = 1; //速度スライダー用 | |
float rad; | |
float dispdeg; | |
float speed = 0; | |
void setup(){ | |
size(500, 500); | |
frameRate(60); | |
//-----スライダー | |
cp5 = new ControlP5(this); | |
cp5.addSlider("sliderValue") //周波数いじるやつ | |
.setLabel("freq") | |
.setSize(width/3,10) | |
.setScrollSensitivity(0.001) | |
.setPosition(width/2,height-10) | |
.setRange(1,(float)height/4); | |
cp5.addSlider("sliderspeed") //速度いじるやつ | |
.setLabel("speed") | |
.setSize(width/3,10) | |
.setScrollSensitivity(0.001) | |
.setPosition(width/2,height-25) | |
.setRange(0,10); | |
dispdeg = 360.0/(float)height; //画面の大きさに周期を合わせる | |
} | |
void draw(){ | |
for(int i=0; i<height; i++){ | |
speed = frameCount * sliderValue * sliderspeed; | |
rad = radians(i * dispdeg * sliderValue + speed); //サイン関数に与える | |
stroke(norm(sin(rad),-1,1)*255); //色が縞模様になるようにする | |
line(0,i,height,i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment