Metropoli BBS
VIEWER: progp090.pas MODE: TEXT (ASCII)
{**********************************************************************}
{ Brute force arc generation						}
{**********************************************************************}

procedure arc(xc,yc,xp,yp,a0,a1,color:word);
		{xc,yc = Center of the arc			}
		{xp,yp = Any point on full circle		}
		{a0,a1 = Starting and ending angle in degrees }
		{color = Color of the arc			}

var
a,b,f,s,dx,dy,pi : real;
i,sl,xa,ya,xb,yb,alpha,delta : integer;
begin
    pi := 3.1415926;
    i := xp-xc;
    if i = 0 then i := yp-yc;
    if i = 0 then pixel_write(xc,yc,color) {degenerate case}
    else begin

    	sl := get_scanlines;
	s := sl;
	f := 480/s; { Compute major & minor axis}
	dx := xp - xc;
	dy := (yp - yc)*f;
	a := sqrt(dx * dx + dy * dy);
	b := a/f;
					{ Compute first point		}
	xa := round(xc + a * cos(a0 * PI/180));
	ya := round(yc + b * sin(a0 * PI/180));
	delta := round(6 * 180/(PI * a)); { Force 6 pixels per segment}
					{ Loop over segment on ellipse }
	alpha := a0;
	while alpha < a1 do begin	{ Compute next point on ellipse}
		xb := round(xc + a * cos(alpha * PI/180));
		yb := round(yc + b * sin(alpha * PI/180));
		line (xa, ya, xb, yb, color);	{ Draw to previous pt	}
		xa := xb;
		ya := yb;
		alpha := alpha + delta;
	end;
					{ Do the last segment		}
	xb := round(xc + a * cos(a1 * PI/180));
	yb := round(yc + b * sin(a1 * PI/180));
	line (xa, ya, xb, yb, color);
    end;
end;
[ RETURN TO DIRECTORY ]