Changeset 238 for trunk/UMap.pas


Ignore:
Timestamp:
Sep 21, 2018, 12:15:23 AM (6 years ago)
Author:
chronos
Message:
  • Modified: Enabled back drawing only of visible cells.
  • Added: Draw only visible arrows between cells.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMap.pas

    r233 r238  
    155155    Areas: TMapAreas;
    156156    Cyclic: Boolean;
    157     procedure DrawArrow(Canvas: TCanvas; Pos: TPoint; Angle: Double;
    158       Text: string; Zoom: Double);
    159157    function IsOutsideShape(Coord: TPoint): Boolean; virtual;
    160158    function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; virtual;
     
    549547end;
    550548
    551 procedure TMap.DrawArrow(Canvas: TCanvas; Pos: TPoint;
    552   Angle: Double; Text: string; Zoom: Double);
    553 var
    554   Points: array of Classes.TPoint;
    555   FPoints: array of TPointF;
    556   I: Integer;
    557   ArrowSize: TPoint;
    558 begin
    559   Canvas.Brush.Color := clWhite;
    560   Canvas.Pen.Color := clBlack;
    561   SetLength(Points, 8);
    562   SetLength(FPoints, 8);
    563   ArrowSize := TPoint.Create(Trunc(DefaultCellSize.X / 3 * Zoom),
    564     Trunc(DefaultCellSize.Y / 3 * Zoom));
    565   FPoints[0] := TPointF.Create(+0.5 * ArrowSize.X, +0 * ArrowSize.Y);
    566   FPoints[1] := TPointF.Create(+0 * ArrowSize.X, +0.5 * ArrowSize.Y);
    567   FPoints[2] := TPointF.Create(+0 * ArrowSize.X, +0.25 * ArrowSize.Y);
    568   FPoints[3] := TPointF.Create(-0.5 * ArrowSize.X, +0.25 * ArrowSize.Y);
    569   FPoints[4] := TPointF.Create(-0.5 * ArrowSize.X, -0.25 * ArrowSize.Y);
    570   FPoints[5] := TPointF.Create(+0 * ArrowSize.X, -0.25 * ArrowSize.Y);
    571   FPoints[6] := TPointF.Create(+0 * ArrowSize.X, -0.5 * ArrowSize.Y);
    572   FPoints[7] := TPointF.Create(+0.5 * ArrowSize.X, 0 * ArrowSize.Y);
    573   // Rotate
    574   for I := 0 to Length(Points) - 1 do
    575     FPoints[I] := TPointF.Create(FPoints[I].X * Cos(Angle) - FPoints[I].Y * Sin(Angle),
    576       FPoints[I].X * Sin(Angle) + FPoints[I].Y * Cos(Angle));
    577   // Shift
    578   for I := 0 to Length(Points) - 1 do
    579     Points[I] := Point(Trunc(FPoints[I].X + Pos.X), Trunc(FPoints[I].Y + Pos.Y));
    580   with Canvas do begin
    581     Brush.Style := bsSolid;
    582     Polygon(Points);
    583     Brush.Style := bsClear;
    584     Font.Color := clBlack;
    585     Font.Size := Trunc(26 * Zoom);
    586     TextOut(Pos.X - TextWidth(Text) div 2,
    587       Pos.Y - TextHeight(Text) div 2, Text);
    588     Pen.Width := 1;
    589   end;
    590 end;
    591 
    592549function TMap.IsCellsNeighbor(Cell1, Cell2: TCell): Boolean;
    593550begin
Note: See TracChangeset for help on using the changeset viewer.