Bezier curves lazarus / 39-Graphics ---------------------------------------------------------------------- user5 · 2023-06-12 13:47 The code below works fine but is there a way to do the same thing without the antialiasing? I could use something other than BGRABitmap since speed in this case is not important. Code: 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.Button1Click(Sender: TObject);var  image: TBGRABitmap;  pts: array of TPointF;  storedSpline: array of TPointF;  c: TBGRAPixel;begin  image := TBGRABitmap.Create(ClientWidth,ClientHeight ,ColorToBGRA(ColorToRGB(clBtnFace))); c := ColorToBGRA(ColorToRGB(clWindowText));  setlength(pts,4); pts[0] := PointF(50,50); pts[1] := PointF(150,50); pts[2] := PointF(150,150); pts[3] := PointF(50,150); image.DrawPolylineAntialias (pts,BGRA(255,0,0,150),1); storedSpline := image.ComputeOpenedSpline(p ts,ssVertexToSide); //image.DrawPolylineAntialias(storedSpline,c,1); s toredSpline := image.ComputeBezierSpline([BezierCurve(PointF(50,50),Po intF(150,50),PointF(150,100)),                                          BezierCurve(PointF(150,100),PointF(150,150),PointF(50,150))]); imag e.DrawPolylineAntialias(storedSpline,c,2); image.Draw(Canvas,0,0,True) ; image.free; end; ---------------------------------------------------------------------- wp · 2023-06-12 20:46 Quote from: user5 on June 12, 2023, 03:47:38 pm I could use something other than BGRABitmap since speed in this case is not important. Use the PolyBezier of the standard LCL canvas: https://lazarus- ccr.sourceforge.io/docs/lcl/graphics/tcanvas.polybezier.html. Simple demo attached. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Points[0] := Point(10, 10);  Points[1] := Point(70, 10);  Points[2] := Point(100, 100-70);  Points[3] := Point(100, 100);  Points[4] := Point(100, 100+70);  Points[5] := Point(200-70, 200);  Points[6] := Point(200, 200);    Paintbox1.Canvas.Pen.Color := clRed;  Paintbox1.Canvas.Pen.Style := psSolid;  Paintbox1.Canvas.PolyBezier(Points); ---------------------------------------------------------------------- user5 · 2023-06-13 01:55 Thank you wp for the example you posted.     It's exactly what I need. ---------------------------------------------------------------------- user5 · 2023-06-13 04:00 If you happen to see this note wp, can you tell what or where PaintBox1Paint is called or invalidated.     There is no Form1.show so in your example I can't figure out how the already painted paintbox appears automatically when the form is opened. Thanks again. ---------------------------------------------------------------------- wp · 2023-06-13 08:39 PaintBox1Paint is the handler for the OnPaint event of the paintbox. TPaintbox is very "stupid", it has no built-in way how to react when the OS requests it to repaint itself. Therefore the user must provide a handler for the OnPaint event which is executed in this case. When the form ist shown for the first time, the paintbox is requested to draw itself - and thus executes the user's OnPaint code. When you put your drawing code in the OnClick event of a button it could be that the drawing appears in the paintbox, at least on Windows, but it will not be persistent: Drag the form partly out of the screen and then back into the screen again, and you'll see that part of the drawing is erased. This is because the paintbox does not know how to redraw itself if OnPaint is empty - the button's OnClick code is unreachable for the paintbox. The button's OnClick code is correct only when it draws into a bitmap (similar to what you do with BGRABitmap, but a standard TBitmap will work as well) which is displayed in a TImage. A TImage by default "knows" how to redraw itself - namely to draw the bitmap assigned to it. Unlike a TPaintbox where you would need an OnPaint handler again to draw the bitmap on the control. In order to assign code to the OnPaint event (or any other event) double-click on the event in the object inspector. The IDE creates an empty procedure skeleton for you in the code editor which you must complete with your own code. ---------------------------------------------------------------------- user5 · 2023-06-14 05:40 Thank you for taking the time and effort to help me wp. You really know your stuff. Wow.