首先定义一些辅助线函数,并且测试;
float cm = 3.767;
void setup()
{
size(720,404);
frameRate(2);
}
// 画垂直线的函数,参数为x;
void lineX(float x)
{
line(x,0,x,height);
text(">"+str(x),x,30);
}
// 画水平线的函数,参数为y;
void lineY(float y)
{
line(0,y,width,y);
text("V"+str(y),10,y);
}
// 画十字线的函数,参数为x,y;
void lineCross(float x, float y)
{
line(0,y,width,y);
line(x,0,x,height);
text("("+str(x)+", "+str(y)+")",x,y);
}
void draw()
{
background(20);
stroke(#FA826D);
lineX(100);
stroke(#7FFA6D);
lineY(100);
stroke(#6E6DFA);
lineCross(width/2,height/2);
}