wrestling with the way VSTO/PowerPoint handles colors, I am looking for a way to get the colors derived from the color scheme (see image, interesting portion framed in red).
I tried TintAndShade
and various other transformations in the RGB space, but I can't seem to reproduce what PowerPoint is doing to generate these colors. Has anyone succeeded in getting these colors (programmatically, and independent of the actual color scheme used, of course)?
Any help would be highly appreciated! Thanks in advance, eDude
I found the answer in this article.
In essence, the transformation is applied in the HSL space (Hue/Saturation/Lightness). The conversion from RGB to HSL is somewhat tedious to implement, but is a straightforward mathematical operation.
Once the principal ThemeColorScheme
colors are converted from RGB to HSL, the following transformation will go from the main color to the different shades:
L = L*Abs(fraction) + (fraction > 0 ? 1 : 0) * (1-fraction)
Where fraction
is the percent value given in the tool tip. Convert back from HSL to RGB and you have the colors from the picture.
From my experimenting, then fractions used to build the PowerPoint depend on the L value of the main color. My best guess for the limits are:
With that, I could programmatically build the whole PowerPoint color palette.