Canvas.Pen.Pattern lazarus / 39-Graphics ---------------------------------------------------------------------- HomePlaneR · 2013-04-16 21:26 Hi everyone. Following code does not want to work: Code: [Select] Canvas.Pen.Color := clRed;  Canvas.Pen.Style := psPattern;  Canvas.Pen.Pattern := $AAAAAAAA;    //101010...  Canvas.Line(0,0,100,0); It gives a black line, but I expected to have red dotted line. What I'm doing wrong? Thanks in advance. ---------------------------------------------------------------------- Blaazen · 2013-04-16 22:00 Style psPattern does not work here too. Maybe it's not implemented yet or it works only on some widgetsets. Of course there is psDot - you probably know. ---------------------------------------------------------------------- HomePlaneR · 2013-04-17 15:23 Quote from: Blaazen on April 17, 2013, 12:00:25 amStyle psPattern does not work here too. Maybe it's not implemented yet or it works only on some widgetsets. Of course there is psDot - you probably know. That's what I thought. Thanks anyway. ---------------------------------------------------------------------- Blaazen · 2014-12-20 18:54 Just for the case: psPattern works but method SetPattern must be used (property Pattern does nothing). Code: [Select]var aPenPattern: TPenPattern; begin   Canvas.Pen.Style := psPattern;   SetLength(aPenPattern, 2);   aPenPattern[0] := 1;  //line [pixels]   aPenPattern[1] := 1;  //space [pixels]   ...   Canvas.Pen.Width := 1;   Canvas.Line(...); This code will paint subtle dotted line. The array can be longer, the first number is always length of dash, the second is the space. ---------------------------------------------------------------------- PawelO · 2015-03-22 10:36 It works for me only when Pen.Width > 1. When Pen.Width=1, it draws always black solid line (Lazarus v1.2.6, Win XP). Code: [Select]    Canvas.Pen.Color := clRed;     Canvas.Pen.Style := psPattern;     SetLength(aPenPattern, 2);     aPenPattern[0] := 3;  //line [pixels]     aPenPattern[1] := 3;  //space [pixels]     Canvas.Pen.SetPattern(aPenPattern);     Canvas.Pen.Width := 1{2};     Canvas.Line(50,50,100,50);