0

我只是想让圆圈变大并用 blendMode(DIFFERENCE); 但半径不变..

int radius = 15;
int radius2 = 15;

size(500, 500);

PGraphics pg = createGraphics(500, 500);
pg.beginDraw();
pg.background(255);
pg.blendMode(DIFFERENCE);
pg.fill(255);
pg.noStroke();
pg.ellipse(width/2, height/2, radius, radius);
pg.ellipse(width/2.25, height/2.25, radius2, radius2);
pg.ellipse(width/2.25, height/1.8, radius2, radius2);
pg.ellipse(width/1.8, height/2.25, radius2, radius2);
pg.ellipse(width/1.8, height/1.8, radius2, radius2);
radius++;
pg.endDraw();


background(255);
image(pg, 0, 0);
4

1 回答 1

1

来自:https ://github.com/processing/processing/wiki/Troubleshooting

如果你的代码有方法(不仅仅是静态模式)或者需要随着时间的推移运行,它必须有一个 draw() 方法,否则什么都不会发生。例如,如果没有 draw(),此代码将在 setup() 方法之后停止。

而已。您需要将代码包装在 draw() 函数中。

这里有一个不错的“按钮”

int radius = 15;
int radius2 = 15;
PGraphics pg ;

void setup() {
  size(500, 500); 
  pg = createGraphics(500, 500);
}

void draw() {
  pg.beginDraw();
  pg.background(255);
  pg.blendMode(DIFFERENCE);
  pg.fill(255);
  pg.noStroke();
  pg.ellipse(width/2, height/2, radius, radius);
  pg.ellipse(width/2.25, height/2.25, radius2, radius2);
  pg.ellipse(width/2.25, height/1.8, radius2, radius2);
  pg.ellipse(width/1.8, height/2.25, radius2, radius2);
  pg.ellipse(width/1.8, height/1.8, radius2, radius2);
  radius++;
  pg.endDraw();


  background(255);
  image(pg, 0, 0);
}
于 2014-09-23T05:33:35.600 回答