Recent

Author Topic: FillRect - make old backgrould lighter/darker  (Read 332 times)

Alextp

  • Hero Member
  • *****
  • Posts: 1174
    • UVviewsoft
FillRect - make old backgrould lighter/darker
« on: September 09, 2020, 08:31:38 pm »
I use BGRABitmap to paint sel-sect (over some pixels) on minimap in CudaText.
On black UI theme, I need to make sel-rect lighter by 20%.
On almost white UI theme, I need to make it darker by 20%.
(20% is approx value, 5-30% is ok)

I don't know how to set
-Color
-Alpha
-DrawMode
in FillRect.

circular

  • Hero Member
  • *****
  • Posts: 3646
    • Personal webpage
Re: FillRect - make old backgrould lighter/darker
« Reply #1 on: September 09, 2020, 10:33:42 pm »
In general you can use the color BGRA(255,255,255, 20*255 div 100) to make it 20% lighter.
And BGRA(0,0,0, 20*255 div 100) to make it 20% darker.
All of this with dmDrawWithTransparency mode.

Alternatively, when you have the Alpha word parameter, you can use BGRAWhite and BGRABlack and an Alpha value of 20*65535 div 100. When using opaque colors, using dmSet or dmDrawWithTransparency gives the same result.

Using dmSet would be useful for example if you want to make a hole, an area where pixels are transparent. You could supply a semi-transparent color like red BGRA(255,0,0, 128) and mode dmSet to make an area semi-transparent and red.

Also dmSet can be slightly faster, for example if you know that a texture is opaque, you can use dmSet mode instead of dmDrawWithTransparency.
Conscience is the debugger of the mind

Alextp

  • Hero Member
  • *****
  • Posts: 1174
    • UVviewsoft
Re: FillRect - make old backgrould lighter/darker
« Reply #2 on: September 09, 2020, 11:09:44 pm »
Thanks!

 

TinyPortal © 2005-2018