Changeset 4 for trunk/UGame.pas
- Timestamp:
- Sep 24, 2019, 8:22:47 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r3 r4 200 200 CellSize: TPoint; 201 201 ValueStr: string; 202 Frame: TRect; 202 203 begin 203 204 CellSize := Point(Canvas.Width div Size.X, Canvas.Height div Size.Y); 205 if CellSize.X < CellSize.Y then CellSize.Y := CellSize.X; 206 if CellSize.Y < CellSize.X then CellSize.X := CellSize.Y; 207 Frame := Rect(Canvas.Width div 2 - (Size.X * CellSize.X) div 2, 208 Canvas.Height div 2 - (Size.Y * CellSize.Y) div 2, 209 Canvas.Width div 2 + (Size.X * CellSize.X) div 2, 210 Canvas.Height div 2 + (Size.Y * CellSize.Y) div 2); 211 204 212 Canvas.FillRect(0, 0, Canvas.Width, Canvas.Height); 205 213 Canvas.Font.Color := clBlack; … … 209 217 Canvas.Brush.Color := GetCellColor(Cells[Y, X].Value); 210 218 Canvas.Brush.Style := bsSolid; 211 Canvas.FillRect(Rect( X * CellSize.X,Y * CellSize.Y,212 (X + 1) * CellSize.X,(Y + 1) * CellSize.Y));219 Canvas.FillRect(Rect(Frame.Left + X * CellSize.X, Frame.Top + Y * CellSize.Y, 220 Frame.Left + (X + 1) * CellSize.X, Frame.Top + (Y + 1) * CellSize.Y)); 213 221 if Cells[Y, X].Value <> 0 then begin 214 222 ValueStr := IntToStr(Cells[Y, X].Value); 215 Canvas.TextOut(X * CellSize.X + CellSize.X div 2 - 216 Canvas.TextWidth(ValueStr) div 2, Y * CellSize.Y, ValueStr); 223 Canvas.TextOut(Frame.Left + X * CellSize.X + CellSize.X div 2 - 224 Canvas.TextWidth(ValueStr) div 2, 225 Frame.Top + Y * CellSize.Y, ValueStr); 217 226 end; 218 227 end; 219 228 220 229 for Y := 0 to Size.Y - 1 do begin 221 Canvas.MoveTo( 0,Y * CellSize.Y);222 Canvas.LineTo( Canvas.Width,Y * CellSize.Y);230 Canvas.MoveTo(Frame.Left, Frame.Top + Y * CellSize.Y); 231 Canvas.LineTo(Frame.Left + Size.X * CellSize.X, Frame.Top + Y * CellSize.Y); 223 232 end; 224 233 for X := 0 to Size.X - 1 do begin 225 Canvas.MoveTo(X * CellSize.X, 0); 226 Canvas.LineTo(X * CellSize.X, Canvas.Height); 227 end; 234 Canvas.MoveTo(Frame.Left + X * CellSize.X, Frame.Top); 235 Canvas.LineTo(Frame.Left + X * CellSize.X, Frame.Top + Size.Y * CellSize.Y); 236 end; 237 Canvas.Brush.Style := bsClear; 238 Canvas.Rectangle(Frame); 228 239 end; 229 240
Note:
See TracChangeset
for help on using the changeset viewer.