program arc;
uses
Windows;
const
DC_BRUSH=18;
const
DC_PEN=19;
const
pi=3.141592653589793;
function SetDCBrushColor(p:hdc;colour:COLORREF): COLORREF; stdcall external 'gdi32.dll' name 'SetDCBrushColor';
function SetDCPenColor(p:hdc;colour:COLORREF): COLORREF; stdcall external 'gdi32.dll' name 'SetDCPenColor';
{NOTE: Don't need brush color here}
function rgb(r:byte;g:byte;b:byte) :COLORREF;
var
a:colorref;
begin
a:= ((0 Shl 16) Or ((0) Shl 8) Or (0) Or $FF000000);
exit (((b Shl 16) Or ((g) Shl 8) Or (r) Or $FF000000) - a);
end;
function GetConsoleHandle(): HWND;
type
StringName = array[0..1024] of char;
var
hwndFound: hwnd;
pszNewWindowTitle, pszOldWindowTitle: StringName;
begin
GetConsoleTitle(pszOldWindowTitle, 1024);
wsprintf(pszNewWindowTitle, '%d/%d');
SetConsoleTitle(pszNewWindowTitle);
Sleep(40);
hwndFound := FindWindow(nil, pszNewWindowTitle);
SetConsoleTitle(pszOldWindowTitle);
exit(hwndFound);
end;
var
p:hwnd;
h:hdc;
centrex:integer;
centrey:integer;
radius:integer;
startangle:single;
sweep:single;
position: ppoint; //unused, only need the parameter for movetoex
begin
p := GetConsoleHandle;
h:=GetDC(p);
sleep(40); // give windows a little space to get the console
setwindowpos(p, HWND_TOPMOST, 0, 0, 800, 600, SWP_SHOWWINDOW);
SelectObject(h,GetStockObject(DC_BRUSH));
SelectObject(h,GetStockObject(DC_PEN));
centrex:=400;
centrey:=300;
radius:=200;
startangle:=24;
sweep:=90;
SetDCpenColor(h,rgb(200,0,0));
movetoex(h,centrex+trunc(radius*cos(startangle*pi/180)),centrey-trunc(radius*sin(startangle*pi/180)),position);
anglearc(h,centrex,centrey,radius,startangle,sweep);
centrex:=600;
centrey:=400;
radius:=100;
startangle:=90;
sweep:=270;
SetDCpenColor(h,rgb(0,200,0));
movetoex(h,centrex+trunc(radius*cos(startangle*pi/180)),centrey-trunc(radius*sin(startangle*pi/180)),position);
anglearc(h,centrex,centrey,radius,startangle,sweep);
readln;
end.