Recent

Author Topic: (SOLVED) TStringGrid merge 2 colors  (Read 3147 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
(SOLVED) TStringGrid merge 2 colors
« on: May 26, 2016, 04:30:32 pm »
Hello guys, i have a problem. If you compile the example you will see that in two cells of a StringGrid'm going to split the cell into two colors: green and gray.

I actually wish that the gray is merged with the green to make it look like the green area is disabiliitata. Just I do not understand how. If I draw first one and then the other me overlaps, it makes a merger. How can I fix? Thank you
« Last Edit: May 28, 2016, 10:26:18 am by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TStringGrid merge 2 colors
« Reply #1 on: May 27, 2016, 10:46:26 am »
Not idea?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: TStringGrid merge 2 colors
« Reply #2 on: May 27, 2016, 11:42:33 am »
Sure, the method is color blending and it is used extensively on alpha blending with a 255 steps of blending with 0 is pure color 1(or green in this case) and 255 is pure color 2 (or gray in this case)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TStringGrid merge 2 colors
« Reply #3 on: May 27, 2016, 12:34:04 pm »
Can you tell me where I find an example?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TStringGrid merge 2 colors
« Reply #4 on: May 28, 2016, 03:58:54 am »
Replace filling the two rectangles:
Code: Pascal  [Select][+][-]
  1.       Brush.Color := RGB(160,160,160);
  2.       FillRect(LRct);
  3.  
  4.  
  5.  
  6.       Brush.Color := clGreen;
  7.       FillRect(RRct);

with filling the main rectangle:
Code: Pascal  [Select][+][-]
  1.       GradientFill(aRect, RGB(160,160,160), clGreen, gdHorizontal);

Check the attached image.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TStringGrid merge 2 colors
« Reply #5 on: May 28, 2016, 09:28:03 am »
Ok, thanks a lot, but your example is gradually fade the color in another. What you need to me it is being able to make it look like a colored cell of a grid as if it was disabled. So for example, if a cell has all the green background it must seem dull green or semi-transparent. In short, a color that distinguishes it from any valid cell.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TStringGrid merge 2 colors
« Reply #6 on: May 28, 2016, 09:32:51 am »
To be clear I would get something similar to the pictures that I attach
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: TStringGrid merge 2 colors
« Reply #7 on: May 28, 2016, 10:18:02 am »

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: TStringGrid merge 2 colors
« Reply #8 on: May 28, 2016, 10:26:05 am »
HeavyUser you are angel. Perfect  :D
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018