Re: dark theme

andrew strain <[email protected]> Tue, 2 May 2023 12:40:16 -0700 (PDT)
Newsgroups gmane.editors.scite.general
Message-ID <[email protected]>
In the past I patched `static Colour ColourFromString()` in SciTEProps to 
do this, it worked well for me although some colours defined in Scites 
source may never go by ColourFromString. It may be preferable to patch 
`inline constexpr Scintilla::Colour ColourRGB(` and `inline constexpr 
Scintilla::Colour ColourRGB(` in StyleDefinition.h

The simplest luminosity inversion I tested goes :
``
  int inv_red   =  0xff - ( green + blue ) / 2;
  int inv_green =  0xff - ( red   + blue ) / 2;
  int inv_blue  =  0xff - ( red   + green) / 2;       // ( divide by 2 or 
'>>1' )
``

I find it works nicely while being so short, a 'flaw' is that the result is 
less saturated than the original, however less saturation might even be 
aesthetic when lit on a dark background.

A more obscure formula can do a similar inversion with a bit of saturation 
reboost:
``
  int i_red  =  0xff + ( 2*red - 7*grn - 7*blu ) / 12;
  int i_grn  =  0xff + ( 2*grn - 7*red - 7*blu ) / 12;
  int i_blu  =  0xff + ( 2*blu - 7*grn - 7*red ) / 12;
  
  i_red = math.min( 255 , math.max(0 , i_red ) );
  i_grn = math.min( 255 , math.max(0 , i_grn ) );
  i_blu = math.min( 255 , math.max(0 , i_blu ) );
``

I wrote these years ago, anyone is welcome to use them. I would send a 
patch myself I am just not
confident where to place them in the source.

I currently use a much larger conversion function, which partially adjusts 
for relative brightness between r,g,b values and throws in other 
transformations. It is done in a lua script which rewrites a section of 
user.properties where symbolic colour names are defined which the rest of 
the property scripts use instead of rgb, and it stores history and presets.

But I think either of those simple conversions should work nicely for a 
light to dark theme switch.
On Friday, 28 April 2023 at 00:08:02 UTC+1 Neil Hodgson wrote:

> Asif Ali Rizvan:
>
> > Could we at least have an inverted colors like feature for the edit area?
>
> Inverted colours are generally disliked.
>
> > Here's the same window with inverted colors,
>
> Those colours are not inverted: magenta is used for "<stdio.h>" in both. 
> The inverse of magenta is green.
>
> The example is inverting the light (or brightness) value of the colours.
>
> > Please consider.
>
> If someone wants to contribute a good implementation of a brightness 
> inversion option it can be included.
>
> Neil
>
>

-- 
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scite-interest/2bf4ff81-53e8-43ff-b422-b63251436d50n%40googlegroups.com.