SRL Archive - Research & Development Lounge

Star Polygon Painter


Camel

2014-10-11 14:11:13

I present to you a completely useless procedure. Unless of course, you want to make your debug for whatever script look really cool.

So here you are, the product of me being bored.

procedure StarPaint(point : TPoint; r, p, q : Integer; Color : TColor);
var
Radian : Extended;
Points : TPointArray;
i : Integer;

OverLap : Integer;
begin
SetLength(Points,p);

Radian := (2.0 * 3.14159) / p;

for i:=0 to High(Points) do
begin
Points[i].X := round( point.x - (sin(Radian*i) * r) );
Points[i].Y := round( point.y - (cos(Radian*i) * r));
end;

for i:=0 to High(Points) do
begin
if ( (i + q) < p ) then
OverLap := (i + q)
else
OverLap := (i + q) - p;

try
SmartImage.LineTo(Points[i],Points[OverLap], Color);
except
WriteLn('Tried to draw out of bounds');
break;
end;

end;
end;

This will draw a star based on a center point. The p and the q are explained here

And here is a picture of various inputs/outputs




So yeah, thats what a 69 pointed star looks like.

Lipcot

2014-10-11 15:12:21

perfect description you made for this, 'useless'. haha, but nice though!

bonsai

2014-10-11 16:12:19

Love it… added to bonsaifighter.

The Mayor

2014-10-11 17:26:34

Very nice ;)

Incurable

2014-10-13 21:41:06

Useless, sure, but awesome nonetheless. :D

N1234

2014-11-17 15:39:19

looks nice, sure to give somebody a surprise lol