Colors 加工过程中从绿色到黄色的渐变

Colors 加工过程中从绿色到黄色的渐变,colors,processing,gradient,Colors,Processing,Gradient,使用处理程序 我该如何使它从绿色变为黄色?我知道如何使它从深绿色变为亮绿色,从蓝色变为黄色,但这不是我想要的。请帮忙 size(300,800); int strokeWeight = 3; for(int i = 0; i< height; i++) { for(int c = 120; c>0; c--) { stroke(c, i, c); line(0, i, width, i); } } 尺寸(300800); int

使用处理程序

我该如何使它从绿色变为黄色?我知道如何使它从深绿色变为亮绿色,从蓝色变为黄色,但这不是我想要的。请帮忙

size(300,800);
  int strokeWeight = 3;

  for(int i = 0; i< height; i++) {
    for(int c = 120; c>0; c--) {
      stroke(c, i, c);
      line(0, i, width, i);
    }
  }
尺寸(300800);
int冲程重量=3;
对于(int i=0;i0;c--){
冲程(c,i,c);
线(0,i,宽度,i);
}
}

查看示例>基础知识>颜色>线性渐变中的线性渐变示例:

/**
 * Simple Linear Gradient 
 * 
 * The lerpColor() function is useful for interpolating
 * between two colors.
 */

// Constants
int Y_AXIS = 1;
int X_AXIS = 2;
color b1, b2, c1, c2;

void setup() {
  size(640, 360);

  // Define colors
  b1 = color(255);
  b2 = color(0);
  c1 = color(204, 102, 0);
  c2 = color(0, 102, 153);

  noLoop();
}

void draw() {
  // Background
  setGradient(0, 0, width/2, height, b1, b2, X_AXIS);
  setGradient(width/2, 0, width/2, height, b2, b1, X_AXIS);
  // Foreground
  setGradient(50, 90, 540, 80, c1, c2, Y_AXIS);
  setGradient(50, 190, 540, 80, c2, c1, X_AXIS);
}

void setGradient(int x, int y, float w, float h, color c1, color c2, int axis ) {

  noFill();

  if (axis == Y_AXIS) {  // Top to bottom gradient
    for (int i = y; i <= y+h; i++) {
      float inter = map(i, y, y+h, 0, 1);
      color c = lerpColor(c1, c2, inter);
      stroke(c);
      line(x, i, x+w, i);
    }
  }  
  else if (axis == X_AXIS) {  // Left to right gradient
    for (int i = x; i <= x+w; i++) {
      float inter = map(i, x, x+w, 0, 1);
      color c = lerpColor(c1, c2, inter);
      stroke(c);
      line(i, y, i, y+h);
    }
  }
}
/**
*简单线性梯度
* 
*函数的作用是插值
*在两种颜色之间。
*/
//常数
int Y_轴=1;
int X_轴=2;
颜色b1、b2、c1、c2;
无效设置(){
尺寸(640360);
//定义颜色
b1=颜色(255);
b2=颜色(0);
c1=颜色(204、102、0);
c2=颜色(0、102、153);
noLoop();
}
作废提款(){
//背景
设置梯度(0,0,宽度/2,高度,b1,b2,X_轴);
设置梯度(宽度/2,0,宽度/2,高度,b2,b1,X_轴);
//前景
设置梯度(50、90、540、80、c1、c2、Y_轴);
设定梯度(50、190、540、80、c2、c1、X_轴);
}
void setGradient(整数x,整数y,浮点w,浮点h,颜色c1,颜色c2,整数轴){
noFill();
如果(轴==Y_轴){//从上到下渐变

对于(int i=y;我是的,好吧。我有点了解,但因为我还是新手,我并不总是理解这些“大”代码(它们让我不知所措,哈),这就是为什么我给出的代码如此简单。但我会去感谢一下,看看更新的答案,如果有用的话,可以自由投票/接受:)我怎样做一个径向梯度?我在Studio.Org上看到了教程,但是没用。我怎么在中间做一个圆圈?渐弱(渐变)。外边缘变成绿色??请帮助,这很紧急!!!!现在很忙,几乎没有在线,请查看处理>文件>示例>基础>颜色>径向渐变以及我最初链接到的。(从昨天开始,你就有了答案;)
noStroke();

color green = color(0,200,0);
color yellow = color(200,200,0);

int gradientSteps = 20;//how detailed will the gradient be
int gradientStripWidth = width/gradientSteps;//compute how many strips of the same width we'll need to fill the sketch

for(int i = 0; i < gradientSteps; i++){//for each gradient strip
  float t = map(i,0,gradientSteps,0.0,1.0);//compute i mapped from 0-gradientSteps to 0.0->1.0
  //this value will plug into lerpColor which does the colour interpolation for you
  color interpolatedColor = lerpColor(green,yellow,t);
  //finally, use the colour and draw some boxes 
  fill(interpolatedColor);
  rect(i*gradientStripWidth,0,gradientStripWidth,height);
}