{$n+}
uses crt,gfx3;
{$i mem}



Const
MaxColor = 256-16;

Type
 TpointList = record
               x,y : integer;
              End;

var
i,x,y,backpage : word;
PointList : Array [1..32] of TPointList;
maxdist,dist      : single;
points            : byte;

procedure setpoint (n,x,y : integer);
Begin
PointList[n].x:=x;
PointList[n].y:=y;
inc (points);
End;


Begin
asm
mov ax,13h
int 10h;
end;

points:=0;
SetPoint (1,80,100);
SetPoint (2,240,100);
SetPoint (3,50,50);

BackPage:=malloc (64000);
lpcx ('bw.pcx',backpage);

maxdist:=0;
for x:=0 to 319 do
for y:=0 to 199 do begin

dist:=0;
for i:=1 to points do dist:=dist+SQRT(SQR(x-Pointlist[i].x)+Sqr(Y-Pointlist[i].y));
dist:=dist/points;
if maxdist<dist then maxdist:=dist;
End;

for x:=0 to 319 do
for y:=0 to 199 do begin

dist:=0;
for i:=1 to points do dist:=dist+SQRT(SQR(x-Pointlist[i].x)+Sqr(Y-Pointlist[i].y));
dist:=dist/points;
mem[backpage:y*320+x]:=MaxColor-round(MaxColor/maxdist*dist)+random(3);
End;

flip32 (backpage,sega000);
readkey;


End.
