wavegradient.pde
来自「This is processing for java examples.」· PDE 代码 · 共 40 行
PDE
40 行
/** * 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;void setup() { size(200, 200); background(200,200,200); noLoop();}void draw() { for (int i =- 75; i < height+75; i++){ // Reset angle to 0, so waves stack properly angle = 0; // Increasing frequency causes more gaps frequency+=.006; for (float j=0; j<width+75; j++){ py = i+sin(radians(angle))*amplitude; angle+=frequency; c = color(abs(py-i)*255/amplitude, 255-abs(py-i)*255/amplitude, j*(255.0/(width+50))); // 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); } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?