Changeset 2797 for libpipi/trunk
 Timestamp:
 Aug 29, 2008, 12:00:12 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libpipi/trunk/pipi/paint/aline_template.h
r2788 r2797 18 18 */ 19 19 20 float x1 = s>x1, y1 = s>y1, x2 = s>x2, y2 = s>y2;21 float g, xd, yd, xgap, xend, yend, xf, yf, val1, val2;22 int x, y, ix1, ix2, iy1, iy2;20 float x1 = s>x1, y1 = s>y1, x2 = s>x2, y2 = s>y2; 21 float g, xd, yd, xgap, xend, yend, xf, yf, val1, val2; 22 int x, y, ix1, ix2, iy1, iy2; 23 23 24 xd = x2  x1;25 yd = y2  y1;24 xd = x2  x1; 25 yd = y2  y1; 26 26 27 /* "Horizontal" line (X greater than Y)*/ 28 if (fabsf(xd) > fabsf(yd)) { 29 if (x1 > x2) 27 /* "Horizontal" line (X greater than Y)*/ 28 if (fabsf(xd) > fabsf(yd)) 30 29 { 31 float tmp; 32 tmp = x1; x1 = x2; x2 = tmp; 33 tmp = y1; y1 = y2; y2 = tmp; 34 xd = (x2x1); 35 yd = (y2y1); 36 } 37 g = yd/xd; 30 if (x1 > x2) 31 { 32 float tmp; 33 tmp = x1; x1 = x2; x2 = tmp; 34 tmp = y1; y1 = y2; y2 = tmp; 35 xd = (x2x1); 36 yd = (y2y1); 37 } 38 g = yd/xd; 38 39 39 40 41 42 43 44 45 40 xend = truncf(x1+0.5); 41 yend = y1 + g*(xendx1); 42 xgap = fractinvf(x1+0.5); 43 ix1 = (int)xend; 44 iy1 = (int)yend; 45 val1 = fractinvf(yend)*xgap; 46 val2 = fractf(yend)*xgap; 46 47 47 PLOT(ix1, iy1, val1);48 PLOT(ix1, (iy1+1)<y1?(iy1+1):iy1, val2);48 PLOT(ix1, iy1, val1); 49 PLOT(ix1, (iy1+1)<y1?(iy1+1):iy1, val2); 49 50 50 51 52 53 54 55 56 57 51 yf = yend+g; 52 xend = truncf(x2+0.5); 53 yend = y2 + g*(xendx2); 54 xgap = fractinvf(x20.5); 55 ix2 = (int)xend; 56 iy2 = (int)yend; 57 val1 = fractinvf(yend)*xgap; 58 val2 = fractf(yend)*xgap; 58 59 59 PLOT(ix2, iy2, val1);60 PLOT(ix2, iy2+1<y2?iy2+1:iy2, val2);60 PLOT(ix2, iy2, val1); 61 PLOT(ix2, iy2+1<y2?iy2+1:iy2, val2); 61 62 62 for (x = (ix1+1); x < ix2; x++) 63 for (x = (ix1+1); x < ix2; x++) 64 { 65 float focus; 66 67 val1 = fractinvf(yf); 68 val2 = fractf(yf); 69 focus = (1.0  fabsf(val1val2)); 70 val1 += 0.3*focus; 71 val2 += 0.3*focus; 72 73 PLOT(x, yf, val1); 74 PLOT(x, (yf+1)<y1?(yf+1):yf, val2); 75 76 yf = yf + g; 77 } 78 } 79 /* "Vertical" line (Y greater than X)*/ 80 else 63 81 { 64 float focus; 82 if (x1 > x2) 83 { 84 float tmp; 85 tmp = x1; x1 = x2; x2 = tmp; 86 tmp = y1; y1 = y2; y2 = tmp; 87 xd = (x2x1); 88 yd = (y2y1); 89 } 65 90 66 val1 = fractinvf(yf); 67 val2 = fractf(yf); 68 focus = (1.0  fabsf(val1val2)); 69 val1 += 0.3*focus; 70 val2 += 0.3*focus; 91 g = xd/yd; 71 92 72 PLOT(x, yf, val1); 73 PLOT(x, (yf+1)<y1?(yf+1):yf, val2); 93 xend = truncf(x1+0.5); 94 yend = y1 + g*(xendx1); 95 xgap = fractf(x1+0.5); 96 ix1 = (int)xend; 97 iy1 = (int)yend; 98 val1 = fractinvf(yend)*xgap; 99 val2 = fractf(yend)*xgap; 74 100 75 yf = yf + g; 76 } 77 } 78 /* "Vertical" line (Y greater than X)*/ 79 else { 80 if (x1 > x2) 81 { 82 float tmp; 83 tmp = x1; x1 = x2; x2 = tmp; 84 tmp = y1; y1 = y2; y2 = tmp; 85 xd = (x2x1); 86 yd = (y2y1); 87 } 101 PLOT(ix1, iy1, val1); 102 PLOT(ix1, (iy1+1)<y1?(iy1+1):iy1, val2); 88 103 89 g = xd/yd;104 xf = xend + g; 90 105 91 xend = truncf(x1+0.5);92 yend = y1 + g*(xendx1);93 xgap = fractf(x1+0.5);94 ix1= (int)xend;95 iy1= (int)yend;96 97 106 xend = truncf(x2+0.5); 107 yend = y2 + g*(xendx2); 108 xgap = fractinvf(x20.5); 109 ix2 = (int)xend; 110 iy2 = (int)yend; 111 val1 = fractinvf(yend)*xgap; 112 val2 = fractf(yend)*xgap; 98 113 99 PLOT(ix1, iy1, val1); 100 PLOT(ix1, (iy1+1)<y1?(iy1+1):iy1, val2); 101 102 xf = xend + g; 103 104 xend = truncf(x2+0.5); 105 yend = y2 + g*(xendx2); 106 xgap = fractinvf(x20.5); 107 ix2 = (int)xend; 108 iy2 = (int)yend; 109 val1 = fractinvf(yend)*xgap; 110 val2 = fractf(yend)*xgap; 111 112 PLOT(ix2, iy2, val1); 113 PLOT(ix2, (iy2+1)<y2?(iy2+1):iy2, val2); 114 PLOT(ix2, iy2, val1); 115 PLOT(ix2, (iy2+1)<y2?(iy2+1):iy2, val2); 114 116 115 117 116 117 {118 float focus;119 int vx = xf;120 val1 = fractinvf(xf);121 val2 = fractf(xf);122 focus = (1.0  fabsf(val1val2));123 val1 += 0.3*focus;124 val2 += 0.3*focus;125 PLOT(vx, y, val1);126 vx++;127 PLOT(vx, y, val2);128 xf = xf + g;129 130 }118 for (y = (iy1+1); y < iy2; y++) 119 { 120 float focus; 121 int vx = xf; 122 val1 = fractinvf(xf); 123 val2 = fractf(xf); 124 focus = (1.0  fabsf(val1val2)); 125 val1 += 0.3*focus; 126 val2 += 0.3*focus; 127 PLOT(vx, y, val1); 128 vx++; 129 PLOT(vx, y, val2); 130 xf = xf + g; 131 } 132 }
Note: See TracChangeset
for help on using the changeset viewer.