Procedure TForm1. DrawFox (lineInfo: String);
Var di, a, b, r, x, y, ab2: integer;
Sub: string;
Temp: double;
The begin
Di:=pos (G02, lineInfo);
If (di=0) then
exit;
A:=strtoint (subString (lineInfo, 'Z', ' ', sub));
B:=strtoint (subString (lineInfo, 'X', ' ', sub));
R:=strtoint (subString (lineInfo, 'r', ' ', sub));
A:=a * 2;
B:=b * 2;
R:=r * 2;
Ab2: a + b=a * * b;
Temp:=SQR (b) (4 * * SQR (r) - SQR (ab2))/(4 * ab2) + SQR/4 (a);
X:=round (- SQRT (temp) + a/2);
Y:=round ((ab2-2 * a * x)/2 * b);
XSH:=paintbox1. Width - 232;
Ysh:=paintbox1. Height - 150;
X:=XSH + x;
Y:=ysh + y;
Paintbox1. Canvas. Pen. Style:=pssolid;
Paintbox1. Canvas. Pen. Width:=3;
Paintbox1. Canvas. Pen. Color:=clred;
Paintbox1. Canvas. MoveTo (x, y);
Paintbox1. Canvas. Arc (x - r, y, r, x + r, y + r, XSH, ysh, XSH + a, ysh - b).
end;
CodePudding user response:
Like this
CodePudding user response:
Know the starting point of the arc end point coordinates and radiusCodePudding user response:
The code above can only draw a semicircle, and can't appear in the correct position, y is 0CodePudding user response:
By using the method of coordinate translation, find the origin of circular arc, the can draw arc,CodePudding user response: