Smoothness of a sketch
in
Programming Questions
•
7 months ago
Hey guys, I'm currently working on the intro to my audio-visual show and I'm using the "wave gradient" example as a basis to make a funky, colourful intro to my piece. The problem I'm having is that the 'waves' are moving in a very static manner especially when the screen is very large and I was wondering if there was a way to "smooth out" the running of the 'waves' so that it looked less static and more fluid.
If it makes any difference I'm controlling the changing colours by using millis()
Anyone got any ideas?
If it makes any difference I'm controlling the changing colours by using millis()
Anyone got any ideas?
- float angle = 0;
float px = 0, py = 0;
float amplitude = 30;
float frequency = 0;
float fillGap = 2.5;
int m;
int m2;
int m3;
color c;
void setup() {
size(500, 500);
background(200);
}
void draw() {
m = millis() / 100;
m2 = millis() / 1000;
m3 = millis() / 500;
for (int i =- 75; i < height+75; i++){
// Reset angle to 0, so waves stack properly
angle = 0;
// Increasing frequency causes more gaps
frequency+=.002;
for (float j = 0; j < width+75; j++){
py = i + sin(radians(angle+frameCount*0.1)) * amplitude;
angle += frequency;
c = color(abs(py-i)*m2/amplitude, 255-abs(py-i)*m/amplitude, j*(255.0/(width+50)), m3);
// 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);
}
}
}
}
1