home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xfig / part02 / u_translate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-27  |  3.4 KB  |  158 lines

  1. /*
  2.  * FIG : Facility for Interactive Generation of figures
  3.  * Copyright (c) 1985 by Supoj Sutanthavibul
  4.  *
  5.  * "Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both the copyright
  8.  * notice and this permission notice appear in supporting documentation. 
  9.  * No representations are made about the suitability of this software for 
  10.  * any purpose.  It is provided "as is" without express or implied warranty."
  11.  */
  12.  
  13. #include "fig.h"
  14. #include "resources.h"
  15. #include "object.h"
  16.  
  17. translate_ellipse(ellipse, dx, dy)
  18.     F_ellipse       *ellipse;
  19.     int            dx, dy;
  20. {
  21.     ellipse->center.x += dx;
  22.     ellipse->center.y += dy;
  23.     ellipse->start.x += dx;
  24.     ellipse->start.y += dy;
  25.     ellipse->end.x += dx;
  26.     ellipse->end.y += dy;
  27. }
  28.  
  29. translate_arc(arc, dx, dy)
  30.     F_arc       *arc;
  31.     int            dx, dy;
  32. {
  33.     arc->center.x += (float) dx;
  34.     arc->center.y += (float) dy;
  35.     arc->point[0].x += dx;
  36.     arc->point[0].y += dy;
  37.     arc->point[1].x += dx;
  38.     arc->point[1].y += dy;
  39.     arc->point[2].x += dx;
  40.     arc->point[2].y += dy;
  41. }
  42.  
  43. translate_line(line, dx, dy)
  44.     F_line       *line;
  45.     int            dx, dy;
  46. {
  47.     F_point       *point;
  48.  
  49.     for (point = line->points; point != NULL; point = point->next) {
  50.     point->x += dx;
  51.     point->y += dy;
  52.     }
  53. }
  54.  
  55. translate_text(text, dx, dy)
  56.     F_text       *text;
  57.     int            dx, dy;
  58. {
  59.     text->base_x += dx;
  60.     text->base_y += dy;
  61. }
  62.  
  63. translate_spline(spline, dx, dy)
  64.     F_spline       *spline;
  65.     int            dx, dy;
  66. {
  67.     F_point       *point;
  68.     F_control       *cp;
  69.  
  70.     for (point = spline->points; point != NULL; point = point->next) {
  71.     point->x += dx;
  72.     point->y += dy;
  73.     }
  74.     for (cp = spline->controls; cp != NULL; cp = cp->next) {
  75.     cp->lx += dx;
  76.     cp->ly += dy;
  77.     cp->rx += dx;
  78.     cp->ry += dy;
  79.     }
  80. }
  81.  
  82. translate_compound(compound, dx, dy)
  83.     F_compound       *compound;
  84.     int            dx, dy;
  85. {
  86.     compound->nwcorner.x += dx;
  87.     compound->nwcorner.y += dy;
  88.     compound->secorner.x += dx;
  89.     compound->secorner.y += dy;
  90.  
  91.     translate_lines(compound->lines, dx, dy);
  92.     translate_splines(compound->splines, dx, dy);
  93.     translate_ellipses(compound->ellipses, dx, dy);
  94.     translate_arcs(compound->arcs, dx, dy);
  95.     translate_texts(compound->texts, dx, dy);
  96.     translate_compounds(compound->compounds, dx, dy);
  97. }
  98.  
  99. translate_arcs(arcs, dx, dy)
  100.     F_arc       *arcs;
  101.     int            dx, dy;
  102. {
  103.     F_arc       *a;
  104.  
  105.     for (a = arcs; a != NULL; a = a->next)
  106.     translate_arc(a, dx, dy);
  107. }
  108.  
  109. translate_compounds(compounds, dx, dy)
  110.     F_compound       *compounds;
  111.     int            dx, dy;
  112. {
  113.     F_compound       *c;
  114.  
  115.     for (c = compounds; c != NULL; c = c->next)
  116.     translate_compound(c, dx, dy);
  117. }
  118.  
  119. translate_ellipses(ellipses, dx, dy)
  120.     F_ellipse       *ellipses;
  121.     int            dx, dy;
  122. {
  123.     F_ellipse       *e;
  124.  
  125.     for (e = ellipses; e != NULL; e = e->next)
  126.     translate_ellipse(e, dx, dy);
  127. }
  128.  
  129. translate_lines(lines, dx, dy)
  130.     F_line       *lines;
  131.     int            dx, dy;
  132. {
  133.     F_line       *l;
  134.  
  135.     for (l = lines; l != NULL; l = l->next)
  136.     translate_line(l, dx, dy);
  137. }
  138.  
  139. translate_splines(splines, dx, dy)
  140.     F_spline       *splines;
  141.     int            dx, dy;
  142. {
  143.     F_spline       *s;
  144.  
  145.     for (s = splines; s != NULL; s = s->next)
  146.     translate_spline(s, dx, dy);
  147. }
  148.  
  149. translate_texts(texts, dx, dy)
  150.     F_text       *texts;
  151.     int            dx, dy;
  152. {
  153.     F_text       *t;
  154.  
  155.     for (t = texts; t != NULL; t = t->next)
  156.     translate_text(t, dx, dy);
  157. }
  158.