Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
48
Task/Plasma-effect/Processing/plasma-effect.processing
Normal file
48
Task/Plasma-effect/Processing/plasma-effect.processing
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
Plasmas with Palette Looping
|
||||
https://lodev.org/cgtutor/plasma.html#Plasmas_with_Palette_Looping_
|
||||
*/
|
||||
|
||||
int pal[] = new int[128];
|
||||
int[] buffer;
|
||||
float r = 42, g = 84, b = 126;
|
||||
boolean rd, gd, bd;
|
||||
|
||||
void setup() {
|
||||
size(600, 600);
|
||||
frameRate(25);
|
||||
buffer = new int[width*height];
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
buffer[x+y*width] = int(((128+(128*sin(x/32.0)))
|
||||
+(128+(128*cos(y/32.0)))
|
||||
+(128+(128*sin(sqrt((x*x+y*y))/32.0))))/4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
if (r > 128) rd = true;
|
||||
if (!rd) r++;
|
||||
else r--;
|
||||
if (r < 0) rd = false;
|
||||
if (g > 128) gd = true;
|
||||
if (!gd) g++;
|
||||
else g--;
|
||||
if (r < 0) gd = false;
|
||||
if (b > 128) bd = true;
|
||||
if (!bd) b++;
|
||||
else b--;
|
||||
if (b < 0){ bd = false;}
|
||||
float s_1, s_2;
|
||||
for (int i = 0; i < 128; i++) {
|
||||
s_1 = sin(i*PI/25);
|
||||
s_2 = sin(i*PI/50+PI/4);
|
||||
pal[i] = color(r+s_1*128, g+s_2*128, b+s_1*128);
|
||||
}
|
||||
loadPixels();
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
pixels[i] = pal[(buffer[i]+frameCount)&127];
|
||||
}
|
||||
updatePixels();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue