1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60:
| Type TFPoint = record X, Y : double; end;
....
procedure _DrawEllipse(const xfp: array of TFPoint); var i, j, rad, rad2, estep, xRot, yRot : integer; cm, p1, p2, p3, p4, p5 : TPoint; p3f, p4f, p5f, theta, aWinkel, bWinkel, RAngle, r1, r2 : double; begin cm := CnvToP(xfp[0]); p2 := CnvToP(xfp[1]); p3f := xfp[2].x; p4f := xfp[3].x; p5f := xfp[4].x; r1 := Abs(Radius(cm.x, cm.y, p2.x, p2.y)); r2 := Abs(r1 * p3f); RAngle := Winkel(xfp[0].X, xfp[0].Y, xfp[1].X, xfp[1].Y) * (PI/180); aWinkel := p4f; bWinkel := p5f; if isZero(bWinkel-aWinkel) then begin aWinkel := 0; bWinkel := 360 end; theta := aWinkel * (PI/180); // Ellipse (x,y) coordinates [pre-rotation] p1.x := Round(cm.x + r1*COS(theta)); p1.y := Round(cm.y + r2*SIN(theta)); xRot := Round(cm.x + (p1.x - cm.x)* COS(RAngle) - (p1.y - cm.y)* SIN(RAngle) ); yRot := Round(cm.y - (p1.x - cm.x)* SIN(RAngle) - (p1.y - cm.y)* COS(RAngle) ); BCAD.xDraw.Canvas.MoveTo(xRot, yRot); estep := Trunc(bWinkel - aWinkel); for j := 1 to estep do begin theta := (aWinkel+j) * (PI/180); // Ellipse (x,y) coordinates [pre-rotation] p1.x := Round(cm.x + r1*COS(theta)); p1.y := Round(cm.y + r2*SIN(theta)); xRot := Round(cm.x + (p1.x - cm.x)* COS(RAngle) - (p1.y - cm.y)* SIN(RAngle) ); yRot := Round(cm.y - (p1.x - cm.x)* SIN(RAngle) - (p1.y - cm.y)* COS(RAngle) ); BCAD.xDraw.Canvas.LineTo(xRot, yRot) end; theta := bWinkel * (PI/180); // Ellipse (x,y) coordinates [pre-rotation] p1.x := Round(cm.x + r1*COS(theta)); p1.y := Round(cm.y + r2*SIN(theta)); xRot := Round(cm.x + (p1.x - cm.x)* COS(RAngle) - (p1.y - cm.y)* SIN(RAngle) ); yRot := Round(cm.y - (p1.x - cm.x)* SIN(RAngle) - (p1.y - cm.y)* COS(RAngle) ); BCAD.xDraw.Canvas.LineTo(xRot, yRot); end; {DrawEllipse} |