diff --git a/cameo/lang.y b/cameo/lang.y index 0bdd616..8e3cdfa 100644 --- a/cameo/lang.y +++ b/cameo/lang.y @@ -74,7 +74,32 @@ static void ref_pick_xy(int ref, double xa, double ya, double xb, double yb, static void align(int ref, double x, double y) { - /* @@@ */ + const struct path *path; + const struct point *p; + double xa = 0, ya = 0, xb = 0, yb = 0; + double xr, yr, xd, yd; + int first = 1; + + for (path = paths; path; path = path->next) + for (p = path->first; p; p = p->next) { + if (first || p->x < xa) + xa = p->x; + if (first || p->x > xb) + xb = p->x; + if (first || p->y < ya) + ya = p->y; + if (first || p->y > yb) + yb = p->y; + first = 0; + } + + ref_pick_xy(ref, xa, ya, xb, yb, &xr, &yr); + xd = x-xr; + yd = y-yr; + + translate(xd, yd, 0); + xo += xd; + yo += yd; }