Page 2 of 3
Re: SysColor plugin 1.0.2
Posted: March 30th, 2013, 11:25 am
by jsmorley
I notice that at least in Windows 8, there is a color that seems fundamental, but I can't see how to get it.
What I would like it to use the "title bar" color that is set in Windows 8 when you have the color scheme set to "automatic". What Windows 8 does in that case is do some evaluation of your desktop background image, and set Aero colors based on that.
What seems to be returned when I use
ColorType=Aero is the color of the Windows Taskbar, which is a few shades darker than the color set for the title bar in an application.
I tried most of the other settings for ColorType, but I'm not sure Windows stores this color in any of the values.
I wonder if you ran into this Brian, and if there was any solution you saw possible?
What I would like to use as a background for a skin:
3-30-2013 7-16-02 AM.jpg
What is returned by the plugin:
3-30-2013 7-16-47 AM.jpg
So what I get when I use that color for the background of a skin (that Locate32 skin):
3-30-2013 7-27-20 AM.jpg
The difference in "darkness" is not a consistent amount that I can just add to the values returned by the plugin when I use them. While it is the same amount for each of the Red/Green/Blue values for a given color, the amount varies depending on the color of the taskbar Windows determines from the evaluation of the background. So it might be +70 each for some colors, and +40 for others.
I can get in the "ballpark" by adding +50 to each Red/Green/Blue element of the color, but it's not exact. Not a big deal, but just wondered if there is some formula Windows 8 uses, or some other value set in Windows, that might determine this.
SolidColor=([MeasureRed]+50),([MeasureGreen]+50),([MeasureBlue]+50),255
3-30-2013 7-35-00 AM.jpg
Re: SysColor plugin 1.0.2
Posted: March 30th, 2013, 12:46 pm
by moshi
you would need a white layer on top of your base color with an opacity that corresponds with the ColorizationAfterglowBalance setting in the registry.
HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM
not sure wether they use just normal blending or a different blending mode.
this explains your +50, +70, +.. differences. hard for me to explain. better play with a white layer in Photoshop to see what effects it has on the base color.
Re: SysColor plugin 1.0.2
Posted: March 30th, 2013, 1:05 pm
by moshi
Re: SysColor plugin 1.0.2
Posted: March 30th, 2013, 1:44 pm
by jsmorley
BANG! Thud...
"Jeff, Jeff... Oh my God!"
Re: SysColor plugin 1.0.2
Posted: March 30th, 2013, 3:01 pm
by moshi
don't feel bad. i think Windows also just puts an additional layer over a base layer and let's the DWM do the compostioning. it's still an MSSTYLE after all.
Re: SysColor plugin 1.0.2
Posted: June 25th, 2013, 1:07 am
by DollarD
Hi jsmorley and moshi,
With regards to the Automatic Aero Color issue...
Essentially, to get it from SysColor, the formula is:
Code: Select all
R = math.floor(( (R * (Balance) / A) + (218 * (1 - Balance)) ) % 256)
G = math.floor(( (G * (Balance) / A) + (218 * (1 - Balance)) ) % 256)
B = math.floor(( (B * (Balance) / A) + (218 * (1 - Balance)) ) % 256)
Balance is the ColorizationColorBalance key in Software\Microsoft\Windows\DWM.
For example:
Skin:
Code: Select all
[Rainmeter]
Update=1000
MiddleMouseDownAction=!RainmeterDeactivateConfig
[Variables]
@Include="#CURRENTPATH#D8Variables.inc"
IncFile="#CURRENTPATH#D8Variables.inc"
FromAlpha=FF
MidRAlpha=FF
MidLAlpha=8F
ToAlpha=00
[MeasureW8Color]
Measure=Plugin
Plugin=Plugin\SysColor.dll
ColorType=Aero
Hex=1
DisplayType=ALL
OnChangeAction=[!UpdateMeasure "MeasureW8ColorBalance"][!UpdateMeasure "MeasureColorScript"]
DynamicVariables=1
UpdateDivider=5
[MeasureW8ColorBalance]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\Windows\DWM
RegValue=ColorizationColorBalance
UpdateDivider=-1
[MeasureColorScript]
Measure=Script
ScriptFile=D8Color.lua
UpdateDivider=-1
[BackgroundRight]
Meter=Image
SolidColor=#WinColor##FromAlpha#
SolidColor2=#WinColor##MidRAlpha#
GradientAngle=180
X=250
Y=0
W=200
H=#WORKAREAHEIGHT#
DynamicVariables=1
[BackgroundMid]
Meter=Image
SolidColor=#WinColor##MidRAlpha#
SolidColor2=#WinColor##MidLAlpha#
GradientAngle=180
X=75
Y=0
W=175
H=#WORKAREAHEIGHT#
DynamicVariables=1
[BackgroundLeft]
Meter=Image
SolidColor=#WinColor##MidLAlpha#
SolidColor2=#WinColor##ToAlpha#
GradientAngle=180
X=0
Y=0
W=75
H=#WORKAREAHEIGHT#
DynamicVariables=1
With accompanying
lua script:
D8Color.lua
Code: Select all
function Initialize()
msMeasureW8Color = SKIN:GetMeasure('MeasureW8Color')
msMeasureW8Balance = SKIN:GetMeasure('MeasureW8ColorBalance')
end -- function Initialize
function Update()
-- Get data from measure
HexColor = msMeasureW8Color:GetStringValue()
ColorBal = msMeasureW8Balance:GetValue()
-- Processing
HexRGB = string.sub(HexColor,1,6)
HexAlpha = string.sub(HexColor,7)
HexRGB = BalColor(HexRGB, (ColorBal/100), HexAlpha)
HexRGBInv = InvColor(HexRGB)
HexRGBAlt = AltColor(HexRGB)
-- Save Data
SKIN:Bang("!WriteKeyValue Variables WinColor " .. HexRGB .. SKIN:ReplaceVariables(" #IncFile# "))
SKIN:Bang("!WriteKeyValue Variables InvColor " .. HexRGBInv .. SKIN:ReplaceVariables(" #IncFile# "))
SKIN:Bang("!WriteKeyValue Variables AltColor " .. HexRGBAlt .. SKIN:ReplaceVariables(" #IncFile# "))
SetVars()
return 0
end
function SetVars( Skin )
if Skin == nil then Skin = " " end
local Config = Skin
SKIN:Bang("!SetVariable WinColor " .. HexRGB .. " " .. Config)
SKIN:Bang("!SetVariable InvColor " .. HexRGBInv .. " " .. Config)
SKIN:Bang("!SetVariable AltColor " .. HexRGBAlt .. " " .. Config)
end -- SetVars
function InvColor(HexRGBString)
local R = tonumber( "0x" .. string.sub(HexRGBString, 1,2) ) / 255
local G = tonumber( "0x" .. string.sub(HexRGBString, 3,4) ) / 255
local B = tonumber( "0x" .. string.sub(HexRGBString, 5,6) ) / 255
-- print("RGB: " .. R .. " " .. G .. " " .. B)
-- RGB to HSV
local H,S,V, Delta
local MAX = math.max(R, G, B)
local MIN = math.min(R, G, B)
V = MAX
Delta = MAX - MIN
if MAX ~= 0 then
S = Delta / MAX
if MAX == R then
H = (G - B) / Delta
elseif MAX == G then
H = 2 + (B - R) / Delta
else
H = 4 + (R - G) / Delta
end
else
S, H = 0, -1
end
H = H * 60
if H < 0 then H = H + 360 end
-- print("HSV: " .. H .. " " .. S .. " " .. V)
-- HSV Invert
H = (H + 180) % 360
S = 1 - S
V = 1 - V
-- HSV to RGB
local Hi = math.floor(H/60)
local H = H / 60
local f = H - Hi
local p = V * (1-S)
local q = V * (1-f*S)
local t = V * (1-(1-f)*S)
if Hi == 0 then
R = V
G = t
B = p
elseif Hi == 1 then
R = q
G = V
B = p
elseif Hi == 2 then
R = p
G = V
B = t
elseif Hi == 3 then
R = p
G = q
B = V
elseif Hi == 4 then
R = t
G = p
B = V
elseif Hi == 5 then
R = V
G = p
B = q
end
R = math.floor(R * 255)
G = math.floor(G * 255)
B = math.floor(B * 255)
-- print("InvRGB: " .. R .. " " .. G .. " " .. B)
-- And back
local HexR = string.format("%02X", R) .. ""
local HexG = string.format("%02X", G) .. ""
local HexB = string.format("%02X", B) .. ""
return HexR .. HexG .. HexB
end
function AltColor(HexRGBString)
local R = tonumber( "0x" .. string.sub(HexRGBString, 1,2) )
local G = tonumber( "0x" .. string.sub(HexRGBString, 3,4) )
local B = tonumber( "0x" .. string.sub(HexRGBString, 5,6) )
-- print("RGB: " .. R .. " " .. G .. " " .. B)
R = math.floor((R + 127) % 255)
G = math.floor((G + 127) % 255)
B = math.floor((B + 127) % 255)
-- print("AltRGB: " .. R .. " " .. G .. " " .. B)
-- And back
local HexR = string.format("%02X", R) .. ""
local HexG = string.format("%02X", G) .. ""
local HexB = string.format("%02X", B) .. ""
return HexR .. HexG .. HexB
end
function BalColor(HexRGBString, Balance, Alpha)
local R = tonumber( "0x" .. string.sub(HexRGBString, 1,2) )
local G = tonumber( "0x" .. string.sub(HexRGBString, 3,4) )
local B = tonumber( "0x" .. string.sub(HexRGBString, 5,6) )
local A = tonumber( "0x" .. Alpha ) / 255
-- print("RGB: " .. R .. " " .. G .. " " .. B)
R = math.floor(( (R * (Balance) / A) + (218 * (1 - Balance)) ) % 256)
G = math.floor(( (G * (Balance) / A) + (218 * (1 - Balance)) ) % 256)
B = math.floor(( (B * (Balance) / A) + (218 * (1 - Balance)) ) % 256)
-- print("BalRGB: " .. R .. " " .. G .. " " .. B)
-- And back
local HexR = string.format("%02X", R) .. ""
local HexG = string.format("%02X", G) .. ""
local HexB = string.format("%02X", B) .. ""
return HexR .. HexG .. HexB
end
It also returns two different contrasting colors for use in the skin, and saves the results in an .inc file for use in other skins.
I actually did a version of this using just the registry measure. Check it out here:
http://rainmeter.net/forum/viewtopic.php?f=99&t=15015
Hope this helps,
$d
Re: SysColor plugin 1.1
Posted: September 13th, 2014, 6:32 am
by Brian
New version of the plugin here:
http://rainmeter.net/forum/viewtopic.php?p=80787#p80787
Finally, accurate Windows 8/8.1 window color is now possible with new option
ColorType=WIN8!!
I recommend using it with
DisplayType=RGB because it still grabs an alpha value. I could have stripped it, but I decided to just let the author do it with DisplayType. I also added some new options to get the "raw" DWM values.
Thanks DollarD for pointing me in the right direction. I did however use a different (but similar) formula.
-Brian
Re: SysColor plugin 1.1
Posted: September 18th, 2014, 1:09 am
by eclectic-tech
Brian wrote:New version of the plugin here:
http://rainmeter.net/forum/viewtopic.php?p=80787#p80787
Finally, accurate Windows 8/8.1 window color is now possible with new option
ColorType=WIN8!!
I recommend using it with
DisplayType=RGB because it still grabs an alpha value. I could have stripped it, but I decided to just let the author do it with DisplayType. I also added some new options to get the "raw" DWM values.
Thanks DollarD for pointing me in the right direction. I did however use a different (but similar) formula.
-Brian
Getting "404" page not found error from github when trying to download the 32/64-bit plugin versions from the link on the first post...
Re: SysColor plugin 1.1
Posted: September 18th, 2014, 2:37 am
by Brian
eclectic-tech wrote:Getting "404" page not found error from github when trying to download the 32/64-bit plugin versions from the link on the first post...
Ohhh, my bad. Just a simple copy/paste typo (probably from when I first made the plugin).
Here are correct links (I fixed all the other links as well):
32-bit:
https://github.com/brianferguson/SysColor.dll/blob/master/PluginSysColor/x32/Release/SysColor.dll?raw=true
64-bit:
https://github.com/brianferguson/SysColor.dll/blob/master/PluginSysColor/x64/Release/SysColor.dll?raw=true
Thanks for reporting that!
-Brian
Re: SysColor plugin 1.1
Posted: September 18th, 2014, 4:41 am
by eclectic-tech
No problem... Got'em now!
Now I have to think about what I can create using them... thanks for the update!