Changeset 19838
- Timestamp:
- Oct 2, 2008, 10:45:24 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/kapa2/src/bDrawOverlay.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/src/bDrawOverlay.c
r16255 r19838 7 7 8 8 int i; 9 int d X, dY, dx, dy;10 int X , Y, Xmin, Ymin, Xmax, Ymax, Xrange, Yrange;11 double expand, X 0, Y0;9 int dx, dy; 10 int Xmin, Ymin, Xmax, Ymax, Xrange, Yrange; 11 double expand, X, Y, dX, dY, pX, pY; 12 12 bDrawColor color; 13 13 … … 18 18 expand = 1.0; 19 19 if (image[0].picture.expand > 0) { 20 expand = 1 / (1.0*image[0].picture.expand);20 expand = image[0].picture.expand; 21 21 } 22 22 if (image[0].picture.expand < 0) { 23 expand = fabs((double)image[0].picture.expand);23 expand = 1.0 / fabs((double)image[0].picture.expand); 24 24 } 25 26 Image_to_Screen (&X0, &Y0, 0.0, 0.0, &image[0].picture);27 X0 -= image[0].picture.x;28 Y0 -= image[0].picture.y;29 25 30 26 Xmin = 0; … … 35 31 Yrange = image[0].picture.dy; 36 32 33 if (N == INFRONT) { 34 fprintf (stderr, "INFRONT deprecated\n"); 35 return; 36 } 37 37 38 for (i = 0; i < image[0].overlay[N].Nobjects; i++) { 38 if (N == INFRONT) { 39 X = image[0].overlay[N].objects[i].x * Xrange; 40 Y = image[0].overlay[N].objects[i].y * Yrange; 41 dX = image[0].overlay[N].objects[i].dx * Xrange; 42 dY = image[0].overlay[N].objects[i].dy * Yrange; 43 } else { 44 X = image[0].overlay[N].objects[i].x/expand + X0; 45 Y = image[0].overlay[N].objects[i].y/expand + Y0; 46 dX = image[0].overlay[N].objects[i].dx/expand; 47 dY = image[0].overlay[N].objects[i].dy/expand; 48 } 49 if ((X + dX < Xmin) || (X - dX > Xmax) || 50 (Y + dY < Ymin) || (Y - dY > Ymax)) { 51 continue; 52 } 39 Image_to_Picture (&X, &Y, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].picture); 40 dX = image[0].overlay[N].objects[i].dx * expand; 41 dY = image[0].overlay[N].objects[i].dy * expand; 42 if (image[0].picture.flipx) dX *= -1; 43 if (image[0].picture.flipy) dY *= -1; 44 45 if (X + dX < Xmin) continue; 46 if (X - dX > Xmax) continue; 47 if (Y + dY < Ymin) continue; 48 if (Y - dY > Ymax); 49 50 pX = (image[0].picture.flipx) ? -1.0 : +1.0; 51 pY = (image[0].picture.flipy) ? -1.0 : +1.0; 53 52 54 53 /* for a LINE, (x, y) is the start, (dx, dy) is the distance to end … … 75 74 bDrawArc (X, Y, dx, dy, 0, 360); 76 75 } else { 77 // very stupid rotate ellipse drawing: 78 double x, y, t; 76 // moderately-stupid rotated ellipse drawing: 77 // ANGLE is distance ccw from the x-axis to the major axis 78 double x0, y0, x1, y1, t; 79 79 double angle = image[0].overlay[N].objects[i].angle * RAD_DEG; 80 80 double cs = cos(angle); 81 81 double sn = sin(angle); 82 x0 = X + pX*dx*cs; 83 y0 = Y - pY*dx*sn; 82 84 // XXX dt should be based on the size of the ellipse... 83 for (t = 0; t < 2*M_PI; t+=0.05) { 84 x = X + dx*cos(t)*cs + dy*sin(t)*sn; 85 y = Y - dx*cos(t)*sn + dy*sin(t)*cs; 86 bDrawPoint (x, y); 85 // 0.10 -> 60 segments on the ellipse 86 # define DT 0.1 87 for (t = DT; t < 2*M_PI + DT; t+=DT) { 88 x1 = X + pX*dx*cos(t)*cs + pX*dy*sin(t)*sn; 89 y1 = Y - pY*dx*cos(t)*sn + pY*dy*sin(t)*cs; 90 bDrawLine (x0, y0, x1, y1); 91 x0 = x1; 92 y0 = y1; 87 93 } 88 94 }
Note:
See TracChangeset
for help on using the changeset viewer.
