Add 'practicing-processing/' from commit 'a863dc99fc5e1967264c286f2adf2b27b50585ef'
git-subtree-dir: practicing-processing git-subtree-mainline:d40d570281
git-subtree-split:a863dc99fc
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Wave Gradient
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* Generate a gradient along a sin() wave.
|
||||
*/
|
||||
|
||||
float angle = 0;
|
||||
float px = 0, py = 0;
|
||||
float amplitude = 30;
|
||||
float frequency = 0;
|
||||
float fillGap = 2.5;
|
||||
color c;
|
||||
|
||||
int colorRange = 255;
|
||||
int ncycles = 500;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
background(200);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
for (int i =- ncycles; i < height+ncycles; i++){
|
||||
// Reset angle to 0, so waves stack properly
|
||||
angle = 0;
|
||||
// Increasing frequency causes more gaps
|
||||
frequency+=.01;
|
||||
for (float j = 0; j < width+ncycles; j++){
|
||||
py = i + sin(radians(angle)) * amplitude;
|
||||
angle += frequency;
|
||||
c = color(abs(py-i)*colorRange/amplitude, colorRange-abs(py-i)*colorRange/amplitude, j*((colorRange * 1.0)/(width+(int)(ncycles * 0.66))));
|
||||
// Hack to fill gaps. Raise value of fillGap if you increase frequency
|
||||
for (int filler = 0; filler < fillGap; filler++){
|
||||
set(int(j-filler), int(py)-filler, c);
|
||||
set(int(j), int(py), c);
|
||||
set(int(j+filler), int(py)+filler, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
0
practicing-processing/sketchbook/libraries/.gitkeep
Normal file
0
practicing-processing/sketchbook/libraries/.gitkeep
Normal file
0
practicing-processing/sketchbook/modes/.gitkeep
Normal file
0
practicing-processing/sketchbook/modes/.gitkeep
Normal file
0
practicing-processing/sketchbook/tools/.gitkeep
Normal file
0
practicing-processing/sketchbook/tools/.gitkeep
Normal file
Reference in New Issue
Block a user