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 fix_movedcompoundpoint(int x, int y) { float scalex, scaley; canvas_ref_proc = canvas_locmove_proc = null_proc; elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_lengths(); adjust_box_pos(x, y, from_x, from_y, &cur_x, &cur_y); /* make a copy of the original and save as unchanged object */ old_c = copy_compound(cur_c); clean_up(); old_c->next = cur_c; set_latestcompound(old_c); set_action_object(F_EDIT, O_COMPOUND); scalex = ((float) (cur_x - fix_x)) / (from_x - fix_x); scaley = ((float) (cur_y - fix_y)) / (from_y - fix_y); /* scale the compound */ scale_compound(cur_c, scalex, scaley, fix_x, fix_y); /* redraw anything under the old compound */ redisplay_compound(old_c); /* and the new compound */ redisplay_compound(cur_c); /* turn back on all relevant markers */ update_markers(new_objmask); set_lastposition(from_x, from_y); set_newposition(cur_x, cur_y); set_modifiedflag(); wrapup_movepoint(); }
void undo_scale(void) { float scalex, scaley; int xmin1, ymin1, xmax1, ymax1; int xmin2, ymin2, xmax2, ymax2; compound_bound(saved_objects.compounds, &xmin1, &ymin1, &xmax1, &ymax1); scalex = ((float) (last_position.x - fix_x)) / (new_position.x - fix_x); scaley = ((float) (last_position.y - fix_y)) / (new_position.y - fix_y); scale_compound(saved_objects.compounds, scalex, scaley, fix_x, fix_y); compound_bound(saved_objects.compounds, &xmin2, &ymin2, &xmax2, &ymax2); redisplay_regions(xmin1, ymin1, xmax1, ymax1, xmin2, ymin2, xmax2, ymax2); swap_newp_lastp(); }