Drawing a closed Polygon on an Image lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2023-11-04 09:00 Hi All. Been playing around with drawing a closed polygon on an Image1 Just wanted to find out how: 1.   To make the Image1 background  initially WHITE and then have the background remain white while making a blue filled polygon.      (The image turns black after it is initially clicked) 2.   Also, how would you use the left mouse button to start a new polygon, while still leaving the previous one still there. I apologize for asking some probably simple questions, but I was Kinda going round in circles. ---------------------------------------------------------------------- paweld · 2023-11-04 10:18 1. instead of:Code: [Select]  Image1.Canvas.Brush.Style := bsClear;setCode: [Select]  Image1.Canvas.Brush.Style := bsSolid;   Image1.Canvas.Brush.Color := clWhite;   Image1.Canvas.FillRect(Image1.ClientRect);    2. revised project attached      And anyway, for such operations the best is PaintBox ---------------------------------------------------------------------- Boleeman · 2023-11-04 11:23 Thanks for the example Paweld That is exactly what I was looking for. Initial click is left, then followed by right clicks. I saw a few other threads that mentioned using a Paintbox instead of Image. Now I see why. I decided to look more into polygons after failing with that Rose Curve conversion with generics. I will look over both codes to learn a few of your techniques. With this example I liked the way you prefixed the shape vertices with FPoly[j].X - 10, FPoly[j].y - 10 Thank you paweld once again for you great help. ---------------------------------------------------------------------- paweld · 2023-11-04 11:59 I just saw that there is still a piece of unnecessary code - creating a bitmap in OnMouseDown - the final procedure should look like thisCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var  p: TPoint;  polyidx, ptidx: Integer;begin  polyidx := Length(FPoly) - 1;  if polyidx >= 0 then    ptidx := Length(FPoly[polyidx]) - 1  else    ptidx := -1;  if (Button = mbLeft) or (polyidx < 0) then  //if mouse button left or no polygons  begin    //create new polygon    Inc(polyidx);    ptidx := -1;    SetLength(FPoly, polyidx + 1);    SetLength(FPolyColor, polyidx + 1);    FPolyColor[polyidx] := RGBToColor(Random(255), Random(255), Random(255));  //and set random pen color  end;  Inc(ptidx);  SetLength(FPoly[polyidx], ptidx + 1);   p := Mouse.CursorPos;  FPoly[polyidx][ptidx] := PaintBox1.ScreenToClient(p);  // or do this  //FPoly[polyidx][ptidx].X := X;  //FPoly[polyidx][ptidx].Y := Y;  PaintBox1.Invalidate;end;