Home > Back-end >  Map editor after painting the diamond lattice, how to correctly select the diamond.
Map editor after painting the diamond lattice, how to correctly select the diamond.

Time:02-04

 
Procedure TForm1. Button1Click (Sender: TObject);
Var
W, h: integer;
I, j: integer;
WWW, HHH, k, l: integer;
The begin
W:=trunc (ww * 1.4);
H:=trunc (hh * 1.4);

W:=image1. Width div w;
H:=image1. Height div h;

WWW:=trunc (ww * 1.4);
HHH:=trunc (hh * 1.4);
Image1. Canvas. Pen. Color:=clred;

For I:=0 to w do
The begin

K:=I * WWW.

Image1. Canvas. Polygon ([Point (k, l + (HHH div 2)), Point (k + (WWW div. 2), l), Point (k + WWW, l + (HHH div 2)), Point (k + (WWW div 2), l + HHH)]);

For j: h=0 to do
The begin
L:=j * HHH;
Image1. Canvas. Polygon ([Point (k, l + (HHH div 2)), Point (k + (WWW div. 2), l), Point (k + WWW, l + (HHH div 2)), Point (k + (WWW div 2), l + HHH)]);
end;

end;




I use the code above picture of the diamond lattice
Now you need to edit the grid in the map editor

Need to select the color or color
I use the following code
 
The x1: x=div trunc (ww * 1.4);
Y1:=y div trunc (hh * 1.4);
Showmessage (' x: + inttostr (x) + 'y: + inttostr (y) +' x1: + inttostr (x1) + 'y1: + inttostr (y1));
Xx:=trunc ww (x1 * * 1.4);
Yy:=trunc (hh y1 * * 1.4);


WWW:=trunc (ww * 1.4);
HHH:=trunc (hh * 1.4);
Pt. X:=xx;
Pt. Y:=yy + trunc (HHH div 2);
PTS [0] :=pt;

Pt. X: xx +=trunc (WWW div 2);
Pt. Y:=yy.
PTS [1] :=pt;

Pt. X: xx +=WWW.
Pt. Y:=yy + trunc (HHH div 2);
PTS [2] :=pt;

Pt. X: xx +=trunc (WWW div 2);
Pt. Y:=yy + HHH;
PTS [3] :=pt;



But I found that I calculated point after onto the canvas will be a list

What's behind the selected coordinates the how to calculate the

Please do me a favor
Give some ideas

I am the xy position of the processing can be used to calculate the position of the four points to draw the diamond

If this method doesn't work please expert advice for other methods

CodePudding user response:

Seek your action help!

Seek the webmaster help ah

CodePudding user response:

Seem to have a similar ptinrect function.. Reference to judge whether the mouse in this range

CodePudding user response:

This is you are asking for trouble,, why not write control? So you can receive the mouse message
Function CreatePlygonRgn and SetWindowRgn controls can be cut into the shape you want

CodePudding user response:

1, each diamond center coordinates
2, the current coordinates and center coordinates of the recent will distinguish you click on the diamond,
3, on the basis of the center coordinates figure this is relatively easy to do
  • Related