1 int offset=10;
2 float x, y;
3 float r=300;
4 float a=0;
5 void setup()
6 {
7 size(600,600);
8 background(0);
9 }
10
11
12 void draw()
13 {
14 background(0); //背景颜色
15 x=r*cos(a); //扫描线x轴增量
16 y=r*sin(a); //扫描线y轴增量
17 /* 绘制扫描线 */
18 fill(0,180,0); //设置扫描线颜色
19 line(width/2,height/2,width/2+x, height/2+y); //扫描线的起点在屏幕中央,x,y分别是两个方向上的增量
20 /* 绘制坐标轴 */
21 fill(0,110,0,50); //设置四轴颜色
22 for(int i=0;i<4;i++)
23 {
24 line(width/2,height/2, //扫描线的起点在屏幕中央
25 width/2+r*cos(i*PI/2), height/2+r*sin(i*PI/2));
26 }
27 /* 同心圆绘制 */
28 stroke(0,110,0);
29 for(int j=1;j<7;j++)
30 ellipse(width/2,height/2,2*50*j,2*50*j);
31 /* 刻度标识距离 */
32 fill(160,250,160);
33 for(int ii=0;ii<4;ii++)
34 {
35 for(int t=0;t<6;t++)
36 text(t*50,width/2+t*50*cos(ii*PI/2), height/2+t*50*sin(ii*PI/2));
37 }
38 fill(0,180,00);
39 text("Angle:"+(a/PI)*180,480,580);
40 a=a+0.02; //扫描角度变化
41 //拖影扫描线的绘制
42 for(int col=1;col<200;col++)
43 {
44 fill(0,180,0,1*col);
45 arc(width/2,height/2,2*r,2*r,a+0.001*(col-1),a+0.001*col);
46 }
47 }