Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

fkRectangle

Ask for help
Post Reply
nyce
Neophyte
Neophyte
Posts: 17
Joined: 16.06.2016 19:48

fkRectangle

Post by nyce »

need help with DrawMapArea proc, the fkRectangle isnt drawing. My points are incorrect?

also, whats the diff between fcWorld and fcScreen?

Thanks.

Code: Select all

Procedure DrawMap(X, Y: Integer);
Var
Figure: TMapFigure;
Begin
  Figure.kind := fkText;
  //fkLine, fkEllipse, fkRectangle,fkDirection,fkText
  Figure.coord := fcWorld;
  //fcWorld, fcScreen
  Figure.x1 := X;
  Figure.y1 := Y;
  Figure.x2 := 0;
  Figure.y2 := 0;
  Figure.brushStyle := bsClear;
  //bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross
  Figure.brushColor := $000000;
  Figure.color := $FFFF00;
  Figure.text := '*';
  AddFigure(Figure);
End;

Procedure DrawMapArea(X, Y: Integer);
Var
Figure: TMapFigure;
Begin
  Figure.kind := fkRectangle;
  //fkLine, fkEllipse, fkRectangle,fkDirection,fkText
  Figure.coord := fcWorld;
  //fcWorld, fcScreen
  Figure.x1 := X-10;
  Figure.y1 := Y-10;
  DrawMap(Figure.x1, Figure.y1);
  Figure.x2 := X+10;
  Figure.y2 := Y+10;
  DrawMap(Figure.x2, Figure.y2);
  AddToSystemJournal('x1: ' + IntToStr(Figure.x1) + ' y1: ' + IntToStr(Figure.y1) + ' x2: ' + IntToStr(Figure.x2) + ' y2: ' + IntToStr(Figure.y2));
  Figure.brushStyle := bsClear;
  //bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross
  Figure.brushColor := $000000;
  Figure.color := $FFFF00;
  Figure.text := '';
  AddFigure(Figure);
End;

begin
  DrawMapArea(GetX(self), GetY(self));
end.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: fkRectangle

Post by Vizit0r »

Code: Select all

Figure.kind := fkRectangle;
  //fkLine, fkEllipse, fkRectangle,fkDirection,fkText
  Figure.coord := fcWorld;
  //fcWorld, fcScreen
  Figure.x1 := X-20;
  Figure.y1 := Y;
  DrawMap(Figure.x1, Figure.y1);
  Figure.x2 := X+20;
  Figure.y2 := Y;
also, whats the diff between fcWorld and fcScreen?
fcWorld - coordinates calculates according to current zoom, map size etc
fcScreen - draws by absolute coordinates from user.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Post Reply