var
xCount,yCount:Integer;
x,y:Integer;
xDelta,yDelta:Integer;
iText:Integer;
txtWidth:Integer;
begin
with Image1,Canvas do
begin
Brush.Color:=clYellow;
FillRect(ClientRect);
xCount:=10;
yCount:=10;
x:=ClientRect.Left+20;
y:=ClientRect.Bottom-1-20;
xDelta:=(Width-20) div xCount;
yDelta:=(Height-20) div yCount;
//画竖线
iText:=0;
while x<=ClientRect.Right do
begin
MoveTo(x,ClientRect.Left);
LineTo(x,ClientRect.Bottom-20);
txtWidth:=TextWidth(IntToStr(iText));
TextOut(x-txtWidth div 2,ClientRect.Bottom-20,IntToStr(iText));
Inc(x,xDelta);
Inc(iText,10);
end;
//画横线
iText:=0;
while y>=0 do
begin
MoveTo(ClientRect.Left+20,y);
LineTo(ClientRect.Right,y);
txtWidth:=TextWidth(IntToStr(iText));
TextOut(ClientRect.Left+10-txtWidth div 2,y-5,IntToStr(iText));
Dec(y,yDelta);
Inc(iText,10);
end;
end;
end;