Recent

Author Topic: How to use TBrush pattern?  (Read 6129 times)

wp

  • Hero Member
  • *****
  • Posts: 11923
How to use TBrush pattern?
« on: February 07, 2017, 06:18:00 pm »
Can anybody give me a short example how the BrushStyle bsPattern (of TBrush) is used? I suppose it is needed to extend the built-in fill patterns (bsCross, bsHorizontal, etc). Why are the more usual BrushStyles (such as bsSolid, bsClear etc) redeclared in graphics, but bsPattern and bsImage not? They require unit FPCanvas.


wp

  • Hero Member
  • *****
  • Posts: 11923
Re: How to use TBrush pattern?
« Reply #2 on: February 07, 2017, 10:17:44 pm »
Thank you - this works fine, it is the "Windows" way, though. I would have expected that bsPattern for TBrush could be supported in way analogous to TPen's psPattern - you set Pen.Style := psPattern and call Pen.SetPattern().

Can I interpret your answer in a way that the LCL itself does not support the BrushStyle bsPattern, at least at the moment? In this case, I should write a feature request.

The background of the question is that I wrote a TChartCombobox which can be used to edit series pointer styles, pen styles, pen widths, and brush styles, and could not find a reasonable solution for the BrushStyle bsPattern.

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 457
Re: How to use TBrush pattern?
« Reply #3 on: February 08, 2017, 10:03:56 am »
Set TBrush.Bitmap to the bitmap you want to use as pattern and TBrush.Style = bsPattern

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: How to use TBrush pattern?
« Reply #4 on: February 08, 2017, 10:48:11 am »
So easy? I can't believe it...

But: What is the difference to bsImage then? Look at the attached demo. It contains four paintboxes, two paint standard brushes (bsCross and bsFDiagonal), one paints bsPattern, and one paints psImage, the latters ones with an alternating black/white bitmap. The paintboxes with bsPattern and psImage look the same. I would have expected that the pattern color of bsPattern could be controlled by changing the Brush.Color (as with the standard patterns). But nothing happens. Then I thought, maybe the bsPattern bitmap should be a 1-bit pixelformat (use FBitmap1 in Paintbox1Paint), but then the entire paintbox goes black.

Another related question: Is there a way to control the background color of non-solid fills in an LCL-conformal way (without going the Windows way as in your demo)?

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 457
Re: How to use TBrush pattern?
« Reply #5 on: February 08, 2017, 02:53:24 pm »
Quote
But: What is the difference to bsImage then?

I dont know

Quote
Look at the attached demo

Sorry no time for now


Quote
Another related question: Is there a way to control the background color of non-solid fills in an LCL-conformal way (without going the Windows way as in your demo)?

AFAIK bsPattern with no mono bitmap is always solid. I tried with a transparent bitmap (png) and it did not work. For mono bitmaps play with Brush.Color, Font.Color

Luiz


 

TinyPortal © 2005-2018