- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
procedure drawGird( var image1: TImage; needAxisLines: Boolean = True );
var
xP, yP: Integer;
xC, yC: Double;
h, w, tx, ty: Integer;
Text: String;
begin
image1.Canvas.FillRect( image1.ClientRect );
accuracy := 1 / cellSize;
image1.Canvas.Brush.Style := bsClear;
xC := p2cX( 0 );
while forC( xC, p2cX( image1.Width ), accuracy ) do
if floor( xC * cellSize ) mod cellSize = 0 then
begin
xP := c2pX( xC );
image1.Canvas.Pen.Color := clSilver;
image1.Canvas.MoveTo( xP, 0 );
image1.Canvas.LineTo( xP, image1.Height );
if ( needaxislines ) and ( abs( xC ) > 0.5 ) and
( xP > 30 ) and ( xP < image1.Width - 30 ) then
begin
image1.Canvas.Pen.Color := clBlack;
image1.Canvas.MoveTo( xP, c2pY( -0.5 ) );
image1.Canvas.LineTo( xP, c2pY( 0.5 ) );
end;
end;
yC := p2cY( 0 );
while forC( yC, p2cY( image1.Height ), accuracy ) do
if floor( yC * cellSize ) mod cellSize = 0 then
begin
yP := c2pY( yC );
image1.Canvas.Pen.Color := clSilver;
image1.Canvas.MoveTo( 0, yP );
image1.Canvas.LineTo( image1.Width, yP );
if ( needaxislines ) and ( abs( yC ) > 0.5 ) and
( yP > 30 ) and ( yP < image1.Height - 30 ) then
begin
image1.Canvas.Pen.Color := clBlack;
image1.Canvas.MoveTo( c2pX( -0.5 ), yP );
image1.Canvas.LineTo( c2pX( 0.5 ), yP );
end;
end;
xC := p2cX( 0 );
while forC( xC, p2cX( image1.Width ), accuracy ) do
if floor( xC * cellSize ) mod cellSize = 0 then
begin
xP := c2pX( xC );
if ( needaxislines ) and ( abs( xC ) > 1.5 ) and
( xP > 30 ) and ( xP < image1.Width - 30 ) then
begin
image1.Canvas.Pen.Color := clBlack;
Text := IntToStr( floor( xC ) );
h := image1.Canvas.TextHeight( Text ) div 2;
w := image1.Canvas.TextWidth( Text ) div 2;
image1.Canvas.TextOut( xP - w, c2pY( -0.5 ) + ( h + 3 ) *
( ( floor( abs( xC ) ) mod ( ( ( w * 2 + 8 ) div cellSize ) +
1 ) ) ), Text );
end;
end;
yC := p2cY( 0 );
while forC( yC, p2cY( image1.Height ), accuracy ) do
if floor( yC * cellSize ) mod cellSize = 0 then
begin
yP := c2pY( yC );
if ( needaxislines ) and ( abs( yC ) > 1.5 ) and
( yP > 30 ) and ( yP < image1.Height - 30 ) then
begin
image1.Canvas.Pen.Color := clBlack;
Text := IntToStr( floor( yC ) );
h := image1.Canvas.TextHeight( Text ) div 2;
w := image1.Canvas.TextWidth( Text ) div 2;
image1.Canvas.TextOut( c2pX( -0.5 ) - w * 2 - 2, yP - h, Text );
end;
end;
image1.Canvas.Brush.Style := bsSolid;
end;