[Solved] How to make a special brush.style ? lazarus / 39-Graphics ---------------------------------------------------------------------- loaded · 2019-11-01 07:19 Hello, dear friends. When drawing inside the closed polygons with the following code; 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   canvas.Brush.Color:=clBlack;                      //bsHorizontal                    //bsVertical                      //bsFDiagonal                    //bsBDiagonal                      //bsCross                    //bsDiagCross  canvas.Brush.Style:=bsCross;  canvas.Rectangle(canvas.ClipRect);  Styles, I can change. I need the styles in the picture. I'd appreciate it if he could help me with this. Respects. ---------------------------------------------------------------------- wp · 2019-11-01 10:38 Create (or load) a bitmap of the repeated elemental cell, assign it to the Bitmap property of the Brush and set the Brush.Style to bsImage (requires FPCanvas in "uses"). A related method using the Brush.Style psPattern and a 32-longword array for the pattern does not seem to work. At least, I did not find a way to make it work. See attached demo. ---------------------------------------------------------------------- loaded · 2019-11-01 11:40 Thank you very much for your wp answer. It expanded my horizon. I've heard the bitmap method, but I haven't tried it because of my performance concerns. But I understand the method I'm looking for is bsPattern. I didn't know this method. Thank you so much for teaching. By the way, the sample you're sending is working fine. About the subject ; I'm gonna have to do some trial and error. ---------------------------------------------------------------------- winni · 2019-11-01 13:21 Hi! You cannot assign a pattern to a brush because the brush has no method setpattern. This is only present for a pen. But it is no problem to draw the background with the pen. It is all drawn to the same canvas. 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 const pat : array[0..3] of LongWord = (10, 3,1,3);var y : integer;              begin               Image4.canvas.Pen.Color:= clBlack;               Image4.canvas.Pen.Style:= psPattern;               Image4.canvas.Pen.SetPattern(pat);                for y := 0 to Image4.height -1 do                     Image4.canvas.line(0,y,Image4.width-1,y);               end;                                                                      In the pattern are the different pixel length of the pattern. Take care:  pattern is an array of longword, so you can put there - by mistake - a value like $AAFFAAFF. Dont do that! The application crashes without any error message. I think it is because the max size of the canvas is maxSmallInt x maxSmallInt (32767). Winni ---------------------------------------------------------------------- loaded · 2019-11-01 13:57 winni thank you very much for your answer. 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);  const  pat : array[0..3] of LongWord = (16, 16,16,16);begin    Image1.Canvas.Brush.Color:=clWhite;    Image1.Canvas.pen.Color:=clWhite;    Image1.Canvas.Brush.Style:=bsSolid;    Image1.Canvas.Rectangle(Image1.Canvas.ClipRect);    Image1.canvas.Pen.Style:= psPattern;    Image1.canvas.Pen.SetPattern(pat);    Image1.canvas.pen.Color:=clred;    Image1.canvas.Pen.Width:=1;    Image1.canvas.line(0,0,Image1.width,Image1.Height);end;  I tried to understand the logic of the work by changing the code you sent a little. What I don't understand is, why does the method that works with the pen not work with the brush? How do I change existing patterns in the brush ? ---------------------------------------------------------------------- wp · 2019-11-01 14:20 See also: https://forum.lazarus.freepascal.org/index.php?topic=35745.0 ---------------------------------------------------------------------- winni · 2019-11-01 17:06 ! Dont try to change an existing brush. Create youself  one. If you want a small checker board do it this way: 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 var bmp : TBitmap;begin        bmp := TBitmap.create;        bmp.setSize(10,10);        bmp.canvas.brush.color := clWhite;        bmp.canvas.FillRect(0,0,Image4.Width,Image4.Height);        bmp.canvas.brush.color := clblack;        bmp.canvas.FillRect(0,0,4,4);        bmp.canvas.FillRect(5,5,9,9);      Image4.canvas.brush.Style:= bsPattern;        Image4.canvas.brush.Bitmap := bmp;        Image4.canvas.FillRect(0,0,Image4.width, image4.height);        bmp.free;      end;   Keep on brushing! Winni ---------------------------------------------------------------------- loaded · 2019-11-02 08:07 Your ideas enlightened me a lot. I did what I tried to do. wp and winni thank you very much. respects. 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 bmp : TBitmap;begin        bmp := TBitmap.create;        bmp.setSize(10,10);        bmp.canvas.brush.color := clWhite;        bmp.canvas.FillRect(bmp.canvas.ClipRect);        bmp.canvas.brush.color := clblack;        bmp.canvas.Line(5,2,2,8);      bmp.canvas.Line(2,8,8,8);        bmp.canvas.Line(8,8,5,2);        Image4.canvas.brush.Color := clWhite;        Image4.canvas.brush.Style := bsSolid;        Image4.canvas.FillRect(Image4.Canvas.ClipRect);         Image4.canvas.brush.Style:= bsPattern;  // add uses FPCanvas        Image4.canvas.brush.Bitmap := bmp;        Image4.canvas.Polygon([Point(10,10), Point(585,15), Point(600,350),Point(55,65)]);        bmp.free;end;