1 #include <aros/oldprograms.h>
7 BezCoord Bezpt
[MaxSegs
+1];
12 int BezMesh
= DefBezMeshVal
;
13 float BezStepSize
= 1.0/DefBezMeshVal
;
15 void DrawBox(int, int, int);
16 void DrawSqr(int, int, int);
17 void DrawPnt(int, int, int);
18 void DrawLine(int, int, int, int, int);
21 void SetBezMesh( value
)
25 BezStepSize
= 1.0/value
;
36 static float xa
, xb
, xc
, xd
;
37 static float ya
, yb
, yc
, yd
;
39 * start up calculations that must be performed before calling
40 * CalcBezPt on any given segment
44 xa
= -StartPtX(ActSeg
) + 3.0*( Cntrl1X(ActSeg
) - Cntrl2X(ActSeg
))
46 xb
= 3.0 *( StartPtX(ActSeg
) + Cntrl2X(ActSeg
) - 2.0*Cntrl1X(ActSeg
));
47 xc
= 3.0*( Cntrl1X(ActSeg
) - StartPtX(ActSeg
));
48 xd
= StartPtX(ActSeg
);
50 ya
= -StartPtY(ActSeg
) + 3.0*( Cntrl1Y(ActSeg
) - Cntrl2Y(ActSeg
))
52 yb
= 3.0 *( StartPtY(ActSeg
) + Cntrl2Y(ActSeg
) - 2.0*Cntrl1Y(ActSeg
));
53 yc
= 3.0*( Cntrl1Y(ActSeg
) - StartPtY(ActSeg
));
54 yd
= StartPtY(ActSeg
);
58 * calculate a point on the bezier curve of a segment
60 void CalcBezPt( t
, xvp
, yvp
)
64 *xvp
= (( t
*xa
+ xb
) * t
+ xc
) *t
+ xd
;
66 *yvp
= (( t
*ya
+ yb
) * t
+ yc
) *t
+ yd
;
75 int fromx
, fromy
, tox
, toy
;
78 for( fromx
= StartPtX(ActSeg
), fromy
= StartPtY(ActSeg
), t
=BezStepSize
;
79 t
< 1.0; fromx
= tox
, fromy
= toy
, t
+= BezStepSize
) {
81 CalcBezPt( t
, &ftox
, &ftoy
);
84 DrawLine( fromx
, fromy
, tox
, toy
, XOR
);
85 DrawPnt( tox
, toy
, XOR
);
87 DrawLine( fromx
, fromy
, EndPtX(ActSeg
), EndPtY(ActSeg
),XOR
);
92 void XdrawAllBezSegs()
100 DrawStartPt(); /* Leonards changes */
101 DrawEndPt(); /* Leonards changes */
110 if( NumBezPts
> 0 && CurMode
== FITBEZIER
) {
114 for( i
= 0; i
< NumBezPts
; i
++ ) {
115 Bezpt
[i
].x
.cur1
= Bezpt
[i
].x
.prev2
= Bezpt
[i
].x
.cur0
;
116 Bezpt
[i
].y
.cur1
= Bezpt
[i
].y
.prev2
= Bezpt
[i
].y
.cur0
;
126 * set the value of a bezpt element
128 static void SetBezPt( xval
, yval
)
133 i
= &Bezpt
[NumBezPts
-1].x
;
134 i
->cur0
= i
->prev2
= i
->cur1
= xval
;
135 i
= &Bezpt
[NumBezPts
-1].y
;
136 i
->cur0
= i
->prev2
= i
->cur1
= yval
;
142 void InitBezPt(xval
,yval
)
149 segno
= NumBezPts
-2;
152 DrawLine( StartPtX( segno
), StartPtY(segno
),
153 EndPtX( segno
), EndPtY(segno
), XOR
);
161 void EditBezPt(xval
, yval
)
164 int segno
= NumBezPts
-2;
166 DrawLine( StartPtX(segno
), StartPtY(segno
),
167 EndPtX( segno
), EndPtY(segno
), XOR
);
169 SetBezPt(xval
, yval
);
171 DrawLine( StartPtX( segno
), StartPtY(segno
),
172 EndPtX( segno
), EndPtY(segno
), XOR
);