效果图:

【Processing学习】 - 公交车马路动态绘制_矢量图

汽车动态移动,云彩动态移动,小草没有找到矢量图,百度了一张先用着.

float q = 0;
int s = 0;
int add = 1;

PImage p1;

void setup()
{
size(800, 400);
background(0, 0, 255);
rect(300, 150, 300, 140, 30);
//sun
fill(255, 255, 0);
circle(800, 0, 40);
first
//circle(360,290,30);
//circle(360,290,30);
//arc(360,290,30,30,0,1,PIE);
//arc(360,290,30,30,2,3,PIE);
//arc(360,290,30,30,4,5,PIE);

second
//circle(540,290,30);
//circle(540,290,30);
//arc(540,290,30,30,0,1,PIE);
//arc(540,290,30,30,2,3,PIE);
//arc(540,290,30,30,4,5,PIE);



//rect(100,100,400,200,50,50,50,50);
//strokeWeight(7);
smooth();
//noFill();
}

void draw()
{
background(0, 0, 255);
//sun
fill(255, 255, 0);
circle(800, 0, 150);
// road
fill(128, 64, 0);
rect(0, 300, 800, 200);

noStroke();
// cloud
fill(255);
ellipse(250-s*0.5, 50, 80, 60);
ellipse(200+s*0.3, 50, 100, 60);
ellipse(170+s*0.3, 50, 50, 40);
ellipse(180+s*0.3, 60, 50, 40);
ellipse(180+s*0.3, 40, 50, 40);
ellipse(210+s*0.1, 60, 80, 60);
// cloud
fill(255);
ellipse(600-s*0.3, 70, 100, 60);
ellipse(570-s*0.3, 70, 50, 40);
ellipse(580-s*0.3, 80, 50, 40);
ellipse(580-s*0.3, 60, 50, 40);
ellipse(610-s*0.1, 80, 80, 60);

stroke(#000000);
//tree1
fill(64, 32, 0);
rect(100, 100, 30, 200);
fill(0, 100, 0);
ellipse(115, 100, 80, 160);

//tree2
fill(64, 32, 0);
rect(300, 100, 30, 200);
fill(0, 100, 0);
ellipse(315, 100, 80, 160);

//tree3
fill(64, 32, 0);
rect(500, 100, 30, 200);
fill(0, 100, 0);
ellipse(515, 100, 80, 160);

//tree4
fill(64, 32, 0);
rect(700, 100, 30, 200);
fill(0, 100, 0);
ellipse(715, 100, 80, 160);


//bus
int start = 500;
if (q < 6.28) q = q + 0.05;
else q = 0;
fill(0, 180, 0);
rect(300+s-start, 150, 300, 140, 30);
//line(400,300,400,320);
//first
fill(0);
circle(360+s-start, 290, 50);
fill(127);
circle(360+s-start, 290, 30);

arc(360+s-start, 290, 30, 30, 0+q, 1+q, PIE);
arc(360+s-start, 290, 30, 30, 2+q, 3+q, PIE);
arc(360+s-start, 290, 30, 30, 4+q, 5+q, PIE);

//second
fill(0);
circle(540+s-start, 290, 50);
fill(127);
circle(540+s-start, 290, 30);

arc(540+s-start, 290, 30, 30, 0+q, 1+q, PIE);
arc(540+s-start, 290, 30, 30, 2+q, 3+q, PIE);
arc(540+s-start, 290, 30, 30, 4+q, 5+q, PIE);
strokeWeight(3);
line(320+s-start, 260, 580+s-start, 260);
line(320+s-start, 250, 580+s-start, 250);

s++;
noStroke();
rect(520+s-start, 170, 40, 50, 10, 50, 0, 0);
rect(460+s-start, 170, 40, 50, 10, 10, 0, 0);
rect(400+s-start, 170, 40, 50, 10, 10, 0, 0);
rect(340+s-start, 170, 40, 50, 50, 10, 0, 0);

//light
fill(255, 255, 0);
ellipse(590+s-start, 240, 20, 20);

//fill(127);
stroke(#000000);
strokeWeight(1);
p1 = loadImage("2.png");
image(p1, 600, 320, 80, 60);
image(p1, 300, 320, 80, 60);
image(p1, 100, 320, 80, 60);
}