static void transform_lib_obj(XKeyEvent *kpe, unsigned char c, KeySym keysym) { int x,y; x = cur_x; y = cur_y; /* first erase the existing image */ put_draw(ERASE); if (c == 'r') { rotn_dirn = 1; act_rotnangle = 90; rotate_compound(new_c, x, y); } else if (c == 'l') { rotn_dirn = -1; act_rotnangle = 90; rotate_compound(new_c, x, y); } else if (c == 'h') { flip_compound(new_c, x, y, LR_FLIP); } else if (c == 'v') { flip_compound(new_c, x, y, UD_FLIP); } else if (c == 's') { scale_compound(new_c, 0.9, 0.9, x, y); } else if (c == 'S') { scale_compound(new_c, 1.1, 1.1, x, y); } /* if not any of the above characters, ignore it */ /* and draw the new image */ put_draw(PAINT); }
static void init_flipcompound(F_compound *old_c, int px, int py) { F_compound *new_c; set_temp_cursor(wait_cursor); new_c = copy_compound(old_c); flip_compound(new_c, px, py, flip_axis); if (copy) { add_compound(new_c); } else { toggle_compoundmarker(old_c); draw_compoundelements(old_c, ERASE); change_compound(old_c, new_c); } /* redisplay objects under this object before it was rotated */ redisplay_compound(old_c); /* and this object and any other objects on top */ redisplay_compound(new_c); reset_cursor(); }
void flip_compound(F_compound *c, int x, int y, int flip_axis) { F_line *l; F_arc *a; F_ellipse *e; F_spline *s; F_text *t; F_compound *c1; int p, q; switch (flip_axis) { case UD_FLIP: /* x axis */ p = y + (y - c->nwcorner.y); q = y + (y - c->secorner.y); c->nwcorner.y = min2(p, q); c->secorner.y = max2(p, q); break; case LR_FLIP: /* y axis */ p = x + (x - c->nwcorner.x); q = x + (x - c->secorner.x); c->nwcorner.x = min2(p, q); c->secorner.x = max2(p, q); break; } for (l = c->lines; l != NULL; l = l->next) flip_line(l, x, y, flip_axis); for (a = c->arcs; a != NULL; a = a->next) flip_arc(a, x, y, flip_axis); for (e = c->ellipses; e != NULL; e = e->next) flip_ellipse(e, x, y, flip_axis); for (s = c->splines; s != NULL; s = s->next) flip_spline(s, x, y, flip_axis); for (t = c->texts; t != NULL; t = t->next) flip_text(t, x, y, flip_axis); for (c1 = c->compounds; c1 != NULL; c1 = c1->next) flip_compound(c1, x, y, flip_axis); }