如何实现图层?
processing吧
全部回复
仅看楼主
level 10
pdcxs007 楼主
想做一个轨迹的动画,如何画出运动的轨迹?有实现类似flash图层的方法吗?
2015年09月04日 12点09分 1
level 1
Google之后解决了,原来是用PGraphics:
PGraphics path;
float x, y;
PVector location, velocity;
void setup() {
size(400, 200);
path = createGraphics(width, height);
//x = random(width);
//y = random(height);
x = y = 0;
location = new PVector(x, y);
velocity = new PVector(1, 2);
path.beginDraw();
path.background(255);
path.endDraw();
}
void draw() {
location.add(velocity);
velocity.y += 0.1; // the gravity
path.beginDraw();
path.stroke(0);
path.strokeWeight(1);
path.line(x, y, location.x, location.y);
path.endDraw();
if (location.x > width || location.x < 0)
velocity.x *= -1;
if (location.y > height) {
velocity.y *= -0.9;
location.y = height;
}
image(path, 0, 0);
ellipse(location.x, location.y, 20, 20);
x = location.x;
y = location.y;
}
2015年09月05日 14点09分 3
太感谢了
2015年10月04日 01点10分
1