给零基础朋友的编程课12 下 - 仿制品7 案例_哔哩哔哩_bilibili
源代码:
// 色表
// 桃红 254,181,167
// 粉红 255,208,199void setup()
{size(1000,750);background(254,181,167);
}void draw()
{// 绘制画框stroke(255,208,199);strokeWeight(28);noFill();rect(0,0, 1000,750);// 绘制画布noStroke();fill(255,208,199);rect(0,120, 1000,512);// 绘制图形// 上排float x = 16, y = 135;drawAFunnel(x,y,true); // 1x += 230+16;drawAFunnel(x,y,true); // 2x += 230+16;drawAFunnel(x,y,false); // 3x += 230+16;drawAFunnel(x,y,true); // 4// 下排x = 16;y += 230+16;drawAFunnel(x,y,false); // 1x += 230+16;drawAFunnel(x,y,true); // 2x += 230+16;drawAFunnel(x,y,false); // 3x += 230+16;drawAFunnel(x,y,false); // 4
}// 绘制一个白色漏斗
void drawAFunnel(float x, float y, boolean isUp)
{pushMatrix(); // 我开辟了一个次空间给你用translate(x,y); // 窗口(画布)的原点坐标noStroke();fill(255);// 开始绘制if(isUp == true) // 如果是竖着的{// 就绘制竖漏斗arc(115,0, 230,230, 0, PI);arc(115,230, 230,230, PI, 2*PI); } else // 否则就绘制水平漏斗{arc(0, 115, 230,230, -0.5*PI,0.5*PI);arc(230,115, 230,230, 0.5*PI,1.5*PI); }popMatrix(); // 现在你用好了,我就将空间还原回去啦~
}