Ciao 访客, welcome back to old school! :p
float totalAmount;void setup(){ size(500,500,P2D); totalAmount=1000;}void draw(){ for(int i=0;i<totalAmount;i++) { for(int j=0;j<totalAmount;j++) { stroke(random(255)); point(i,j); } } //noLoop();}
float xStart, yStart;float xPos, yPos;float spacing;float rows, cols;float diam;float degreeStart, degreeEnd;void setup(){ size(600, 450); background(255); smooth(); diam= spacing=30; xStart=yStart=diam/2; rows=20; cols=15; colorMode(HSB); stroke(20,255,255,140);}void draw(){ for (int i=0;i<rows;i++) { for (int j=0;j<cols;j++) { xPos=xStart+i*spacing; yPos=yStart+j*spacing; fill(random(360), 100, 255, 140); //float distance=dist(xPos,yPos,mouseX,mouseY); //diam=distance/10; ellipse(xPos, yPos, diam, diam); degreeStart=random(360); degreeEnd=degreeStart+random(360); fill(random(360), 255, 255, 200); arc(xPos, yPos, diam, diam, radians(degreeStart), radians(degreeEnd)); } } noLoop();}
float xPos, yPos;float x1, y1, x2, y2;float t;void setup(){ size(500, 500); background(0); smooth(); stroke(255); strokeWeight(3); x1=y1=0; x2=150; y2=210; t=0;}void draw(){ translate(width/2, height/4); xPos=(x2-x1)*t+x1; yPos=(y2-y1)*t+y1; point(xPos, yPos); t+=0.01; t=constrain(t, 0, 1); if (xPos==x2 && yPos==y2) { x1=x2; y1=y2; if (????这里不知道……) { x2=-150; y2=210; } else { x2=0; y2=0; } t=0; }}
float rectBtnX,rectBtnY,rectBtnWidth,rectBtnHeight;float roundBtnX,roundBtnY,roundBtnRadius,roundBtnDiameter;float addRoundX,addRoundY,addRoundDiameter;boolean shutterRound;void setup(){ size(500,500); smooth(); rectMode(CENTER); shutterRound = true; //Set the parameters of two buttons rectBtnX = width/2; rectBtnY = height/3*2; rectBtnWidth = 120; rectBtnHeight = 80; roundBtnX = width/2; roundBtnY = width/3; roundBtnRadius = 60; roundBtnDiameter = roundBtnRadius*2; //Set the parameters of the added ellipse addRoundDiameter = 20; addRoundX = addRoundDiameter/2; addRoundY = rectBtnY+rectBtnHeight/2+addRoundDiameter/2; //Draw the two buttons drawTwoButtons(shutterRound);}void draw(){}void mousePressed(){ if(dist(mouseX,mouseY,roundBtnX,roundBtnY)<roundBtnRadius){ shutterRound = !shutterRound; drawTwoButtons(shutterRound); }else if(mouseX > rectBtnX-rectBtnWidth/2 && mouseX< rectBtnX+rectBtnWidth/2 && mouseY > rectBtnY-rectBtnHeight/2 && mouseY < rectBtnY+rectBtnHeight/2){ drawAddedEllipse(shutterRound); }}void drawAddedEllipse(boolean shutter){ if(shutter){ fill(255); stroke(0); }else{ fill(0); stroke(255); } strokeWeight(6); ellipse(addRoundX,addRoundY,addRoundDiameter,addRoundDiameter); addRoundX += addRoundDiameter;}void drawTwoButtons(boolean shutter){ if(shutter){ background(255); fill(255); stroke(0); }else{ background(0); fill(0); stroke(255); } strokeWeight(6); ellipse(roundBtnX,roundBtnY,roundBtnDiameter,roundBtnDiameter); rect(rectBtnX,rectBtnY,rectBtnWidth,rectBtnHeight); addRoundX = addRoundDiameter/2;}
@Kimi Hu 雪花屏那个作业貌似totalAmount 没有必要为1000 的,500就足够了。第二个果然很酷阿,另外你可以尝试着让cols 与 rows 动态的绑定场景大小试试看,也就是无论场景多大,都会生成单位大小为30 的铺满整个场景的阵列。此外你的第三个问题比较复杂,我目前觉得可以用向量PVector 来实现,但是之前没有做过类似的尝试,我后面几天抽空做个demo 看看。