mirror of
https://github.com/dyne/FreeJ.git
synced 2026-02-05 12:39:15 +01:00
processing-js 0.4 has been merged in some relevant parts basic and topic scripts added for test color handling fixed, more scripts show up now
73 lines
1.2 KiB
Plaintext
73 lines
1.2 KiB
Plaintext
void setup() {
|
|
size(200, 200);
|
|
colorMode(RGB, 100);
|
|
background(0);
|
|
noFill();
|
|
noLoop();
|
|
}
|
|
|
|
void draw() {
|
|
stroke(40);
|
|
beginShape();
|
|
for(int i=0; i<width; i++) {
|
|
vertex(i, singraph((float)i/width)*height);
|
|
}
|
|
endShape();
|
|
|
|
stroke(55);
|
|
beginShape();
|
|
for(int i=0; i<width; i++) {
|
|
vertex(i, quad((float)i/width)*height);
|
|
}
|
|
endShape();
|
|
|
|
stroke(70);
|
|
beginShape();
|
|
for(int i=0; i<width; i++) {
|
|
vertex(i, quadHump((float)i/width)*height);
|
|
}
|
|
endShape();
|
|
|
|
stroke(85);
|
|
beginShape();
|
|
for(int i=0; i<width; i++) {
|
|
vertex(i, hump((float)i/width)*height);
|
|
}
|
|
endShape();
|
|
|
|
stroke(100);
|
|
beginShape();
|
|
for(int i=0; i<width; i++) {
|
|
vertex(i, squared((float)i/width)*height);
|
|
}
|
|
endShape();
|
|
}
|
|
|
|
float singraph(float sa) {
|
|
sa = (sa - 0.5) * 1.0; //scale from -1 to 1
|
|
sa = sin(sa*PI)/2 + 0.5;
|
|
return sa;
|
|
}
|
|
|
|
float quad(float sa) {
|
|
return sa*sa*sa*sa;
|
|
}
|
|
|
|
float quadHump(float sa) {
|
|
sa = (sa - 0.5); //scale from -2 to 2
|
|
sa = sa*sa*sa*sa * 16;
|
|
return sa;
|
|
}
|
|
|
|
float hump(float sa) {
|
|
sa = (sa - 0.5) * 2; //scale from -2 to 2
|
|
sa = sa*sa;
|
|
if(sa > 1) { sa = 1; }
|
|
return 1-sa;
|
|
}
|
|
|
|
float squared(float sa) {
|
|
sa = sa*sa;
|
|
return sa;
|
|
}
|