案例一:画笔的粗细效果
void setup()
{
size(704,576);
smooth();
strokeWeight(20);//画笔粗细为20像素
strokeJoin(ROUND);//圆形的转角画笔
rect(40,40,70,70);
strokeJoin(BEVEL);//锥形的转角画笔
rect(150,40,70,70);
strokeCap(SQUARE);//锥形的转角画笔
line(100,200,500,200);
strokeCap(ROUND);//锥形的转角画笔
line(100,300,500,300);
}
效果如下
案例二:常见的几何图形绘制
void setup()
{
size(704,576);
smooth();
}
void draw()
{
//线
line(10,10,300,10);
//三角形
triangle(10,20,180,20,80,62);
//四边形
quad(400,10,700,20,600,25,300,35);
//矩形
//rect(x,y,width,height);
rect(100,100,300,200);
//椭圆圆形
//ellipse(x,y,width,height);
ellipse(600,300,80,60);
//椭圆的一半
//arc(x,y,width,height,start,stop);
arc(600,200,100,100,HALF_PI,PI);//注意屏幕的坐标系的方向
//arc(100,50,50,50,0,TWO_PI);
//arc(100,50,50,50,TWO_PI,0);
}
效果图如下: