Arsip: Elips dengan kemiringan tertentu


by MrRidwan in Form more 13 years ago 1426
Artikel ini merupakan sedikit cara untuk membuat ellips dengan kemiringan tertentu.
procedure TForm1.DrawRotatedEllipse;
var CenterX, CenterY: Integer;
RadiusX, RadiusY: Integer;
cs, sn, x, y: real;
sdt: real;
n: Integer;
FP: array[0..360] of TPoint;
begin
{--clear canvas--}
with PaintBox1.Canvas do
begin
Pen.Color:=Color;
Brush.Color:=Color;
Rectangle(0, 0, PaintBox1.Width, PaintBox1.Height);
end;
{--initialization--}
RadiusX:=PaintBox1.Width  div 2;
RadiusY:=PaintBox1.Height div 3;
CenterX:=PaintBox1.Width  div 2;
CenterY:=PaintBox1.Height div 2;
sdt:=SpinEdit1.ValuePI/180;
cs:=cos(sdt);
sn:=sin(sdt);
for n:=0 to 360 do
begin
x:=RadiusX cos(nPI/180);
y:=RadiusY sin(nPI/180);
FP[n].x:=CenterX+Round(x cs+ysn);
FP[n].y:=CenterY+Round(-sn x+cs*y);
end;
PaintBox1.Canvas.Pen.Color:=clBlack;
PaintBox1.Canvas.Brush.Style:=bsClear;
PaintBox1.Canvas.Polygon(FP);
end;
Syntax Highlighted with https://pascal-id.org/syntax


Jangan lupa untuk menambahkan

procedure TForm1.DrawRotatedEllipse;

pada bagian Private atau Public seperti contoh dibawah ini
Uses ....
Private
procedure DrawRotatedEllipse;
Public
....
Syntax Highlighted with https://pascal-id.org/syntax


Pada Event Isikan DrawRotatedEllipse;
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com