看到新的Google图标,感觉很好玩,使用Processing实现了一下。先看一下Google的图标:
以下是实现的代码:
PGraphics path;
float vec;
float x, y;
float radius;
float dotRad;
float cx, cy;
float bottom, top;
void setup() {
size(700, 200);
background(255);
smooth();
path = createGraphics(width, height);
radius = 0.4 * height;
dotRad = 4;
x = 0;
cx = width / 2;
cy = height / 2;
bottom = cy + radius;
top = cy - radius;
y = getY(x);
vec = 1;
}
void draw() {
x += vec;
if (x >= width || x <= 0)
vec *= -1;
float calx, caly;
calx = getX(x);
caly = getY(x);
background(255);
text("Click mouse to clear the path.", 5, 12);
ellipse(cx, cy, 2*radius, 2*radius);
line(0, bottom, width, bottom);
stro