'我只是想让圆圈成长并以混合模式(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);
答案 0 :(得分: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);
}