It is currently April 20th, 2019, 11:14 am

Color Triad

Post your work-in-progress and completed skins to share and discuss.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3290
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Color Triad

eclectic-tech » October 4th, 2017, 3:11 pm

Color Triad
Generates Two Complimentary Colors
Generates Opposite Color
Magnified* Desktop Color Picker Included (* Magnify only for Win8.1 or Win10)
Gradients of Complimentary and Opposite Colors

ct4.png
ct4mag.png
Features:
  • Using HSBLib (modded colorBrightness formula)
  • Pick Color from Spectrum Image (RGB Value is Copied to Clipboard)
  • Middle-click for Magnified* Desktop Color Picker (Selects screen color under the crosshair)
  • 2 Complimentary Colors and Opposite Color are Generated
  • Click Top Color Rectangles to Copy Generated RGB Values to Clipboard
  • Click The Gradient Titles to Copy Generated RGB Values to your variables file *New*
  • Options to Input RGB Code Manually and to Set Shift Degrees of Complimentary Colors
  • Based on Triad Colors Scheme (see Circle Image in spoiler)
  • Color Picker skin easily adaptable for general use
  • Thanks to JSMorley for his CursorColor plugin
Triad color scheme may help you select colors that will compliment your primary color; but depending on your primary color, the generated colors may not be pleasing (complimentary... yes, pleasing... no)! Use it as a guide, not a rigid rule.

Uses "Magnify.exe" in Win8.1 and Win10 to assist in picking screen colors; you can control the magnification setting through Windows "Ease of Access" settings.

You can click on a color in the spectrum image, middle-click for a desktop color picker, or enter the RGB value directly. Colors will be generate automatically. You can change the Color shift degrees to tweak the compl1 / Compl2 colors (default 30 degrees). Complimentary and Opposite RGB Values can be easily copied to the clipboard for use in your skins.

Note: Rainmeter.exe 'Properties', 'Compatibility', 'High DPI Settings' should be set to 'Override high DPI scaling by Application', otherwise you will get erroneous colors using the color spectrum and picker.

V 1.2019.02.12 Added the ability to write the 3 color values (Opposite, Complimentary1, and Complimentary2 colors) to your own variables in a separate file. See the [Variables] settings in the skin to set this up. The action to write these is done from the gradient titles below the spectrum. Also added DPI scaling based on your screen DPI setting (see note above).
Image is from Paletton Site
triad0.png
You do not have the required permissions to view the files attached to this post.
Last edited by eclectic-tech on October 12th, 2017, 6:49 pm, edited 6 times in total.
User avatar
balala
Rainmeter Sage
Posts: 8080
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Triad

balala » October 4th, 2017, 4:42 pm

Good work eclectic-tech, thanks. :thumbup: I'm planning creating some skins, where I could use your work (not necessary to pick the opposite color, but "main" one, definitely), if you agree. This skin would be used instead of the RainRGB 4.0, to avoid using and including in the skin installer, an exe.
Just a side note, I mention a while ago, rbriddickk84 also wrote a similar skin to pick colors and then he also posted it here, on the forum. He named his work EasyRGB pick 2.04. That skin didn't pick the opposite color, but could be used to pick the primary color.
Anyway, congratulations and thanks again.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3290
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Color Triad

eclectic-tech » October 4th, 2017, 5:36 pm

Thanks balala!

Both this and Kaelri's TestColorSpectrum skin use a lua script to determine selected color. It is not as robust as RainRGB, but might work for you.

If you don't need alternate colors, you could trying Kaelri's TestColorSpectrum skin. The main difference is his skin returns both decimal and hex values and comes in Large/Small versions.
tcs.png
His original post is lost somewhere, but you can find a copy here.

Both are released under CC license... :welcome:
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 8080
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Triad

balala » October 4th, 2017, 5:55 pm

eclectic-tech wrote:Both this and Kaelri's TestColorSpectrum skin use a lua script to determine selected color.
Thanks eclectic-tech, I also will try Kaelri's TestColorSpectrum skin.
eclectic-tech wrote:It is not as robust as RainRGB, but might work for you.
Definitely. I hate to include a .exe in my skin installers, as much as this is possible. I always try to get some such solution, to replace a .exe with a .ini, with or without a .lua.
eclectic-tech wrote:Both are released under CC license... :welcome:
I suppose this means it's ok to include your code into my work. Right? Thanks if yes.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3290
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Color Triad

eclectic-tech » October 4th, 2017, 6:04 pm

Use them as you like... Credit is always appreciated, but not required for mine :D :welcome:
User avatar
balala
Rainmeter Sage
Posts: 8080
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Triad

balala » October 4th, 2017, 6:11 pm

eclectic-tech wrote:Use them as you like... Credit is always appreciated, but not required for mine :D :welcome:
Ok, I'll mention both of you (you and Kaelri) as the author of the skins I took the idea from. Thanks.
User avatar
jsmorley
Developer
Posts: 19178
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Color Triad

jsmorley » October 4th, 2017, 9:21 pm

Building a color picker like RainRGB in Rainmeter / Lua probably wouldn't be terribly hard, the key is that you don't want to think in RBG (Red, Green, Blue), but rather in HSB (Hue, Saturation, Brightness). If you look at RainRGB carefully, what is "returned" is RGB, but it is based on picking colors using HSB.
1.png
I have already posted code here in the forums that can convert between HSB and RGB.
https://forum.rainmeter.net/viewtopic.php?p=139148#p139148

The only reason I didn't, and won't, give up my .exe RainRGB is that I depend on the "picker" part of the functionality. Being able to drag an eyedropper to any point on the screen and get the color under the magnified cursor is critical to me.
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3290
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Color Triad

eclectic-tech » October 4th, 2017, 10:17 pm

jsmorley wrote:...The only reason I didn't, and won't, give up my .exe RainRGB is that I depend on the "picker" part of the functionality. Being able to drag an eyedropper to any point on the screen and get the color under the magnified cursor is critical to me.
That is one of the best features of RainRGB and I use that often... :thumbup:

My skin is more about finding colors that hopefully won't clash with a color that is chosen. It can be a color picker, but that was only added as an option to inputting your color value. The main purpose I had in mind was to generate alternate colors.

Choices are good! ;-)

For flexibility and end user color selection, I would use RainRGB.
To help determine alternate colors, I would use ColorTriad.
User avatar
jsmorley
Developer
Posts: 19178
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Color Triad

jsmorley » October 4th, 2017, 10:25 pm

eclectic-tech wrote:That is one of the best features of RainRGB and I use that often... :thumbup:

My skin is more about finding colors that hopefully won't clash with a color that is chosen. It can be a color picker, but that was only added as an option to inputting your color value. The main purpose I had in mind was to generate alternate colors.

Choices are good! ;-)

For flexibility and end user color selection, I would use RainRGB.
To help determine alternate colors, I would use ColorTriad.
Sorry matey, this thread be hijacked! Arrrr!
User avatar
jsmorley
Developer
Posts: 19178
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Color Triad

jsmorley » October 4th, 2017, 10:52 pm

Look Ma, No Lua!
ColorPicker_1.0.rmskin
1.png

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
Chosen=159,253,7

[MeasurePicker]
Measure=Plugin
Plugin=CursorColor
Format=RGB

[MeterBack]
Meter=Image
W=420
H=405
SolidColor=47,47,47,255

[MeterSpectrum]
Meter=Image
X=10
Y=10
ImageName=#@#ColorSpectrum.jpg
LeftMouseUpAction=[!CommandMeasure MeasurePicker "GetColor"][!UpdateMeasure MeasurePicker][!SetVariable Chosen "[&MeasurePicker]"][!WriteKeyValue Variables Chosen "[&MeasurePicker]"][!UpdateMeter *][!Redraw]

[MeterColor]
Meter=Image
Y=10R
X=0r
W=100
H=75
SolidColor=[#Chosen]
DynamicVariables=1

[MeterRGB]
Meter=String
X=20R
Y=21r
FontSize=21
FontWeight=700
FontColor=255,255,255,255
AntiAlias=1
Text=RGB : [#Chosen]
DynamicVariables=1

For those that want it:

Code for C++ plugin CursorColor.dll

Code: Select all

#include <string>
#include <stdio.h>
#include <Windows.h>
#include "../../API/RainmeterAPI.h"

enum Instance
{
	RGB,
	RED,
	GREEN,
	BLUE
};

struct Measure
{
	std::wstring returnedString;
	Instance type;
	void* rm;
	Measure() : type(RGB), rm() {}
};

PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
	Measure* measure = new Measure;
	*data = measure;
	measure->rm = rm;
}

PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	Measure* measure = (Measure*)data;

	LPCWSTR colorFormat = RmReadString(rm, L"FORMAT", L"RGB");
	if (_wcsicmp(colorFormat, L"RGB") == 0)
	{
		measure->type = RGB;
	}
	if (_wcsicmp(colorFormat, L"RED") == 0)
	{
		measure->type = RED;
	}
	if (_wcsicmp(colorFormat, L"GREEN") == 0)
	{
		measure->type = GREEN;
	}
	if (_wcsicmp(colorFormat, L"BLUE") == 0)
	{
		measure->type = BLUE;
	}
}

//PLUGIN_EXPORT double Update(void* data)
//{
//        Measure* measure = (Measure*)data;
//        return 0.0;
//}

PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
	Measure* measure = (Measure*)data;
	return measure->returnedString.c_str();
}

PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args)
{
	Measure* measure = (Measure*)data;

	if (_wcsicmp(args, L"GetColor") == 0) {
		WCHAR buffer[32];

		// Get the device context for the screen
		HDC hDC = GetDC(NULL);
		if (hDC == NULL) {
			RmLogF(measure->rm, LOG_WARNING, L"CursorColor: Error getting screen device handle");
			return;
		}

		// Get the current cursor position
		POINT p;
		BOOL b = GetCursorPos(&p);
		if (!b) {
			RmLogF(measure->rm, LOG_WARNING, L"CursorColor: Error getting current cursor position");
			return;
		}

		// Retrieve the color at that position
		COLORREF color = GetPixel(hDC, p.x, p.y);
		if (color == CLR_INVALID) {
			RmLogF(measure->rm, LOG_WARNING, L"CursorColor: Error getting pixel color");
			return;
		}

		// Release the device context again
		ReleaseDC(GetDesktopWindow(), hDC);

		switch (measure->type)
		{
		case RGB:
			_snwprintf_s(buffer, _TRUNCATE, L"%i,%i,%i", GetRValue(color), GetGValue(color), GetBValue(color));
			break;
		case RED:
			_snwprintf_s(buffer, _TRUNCATE, L"%i", GetRValue(color));
			break;
		case GREEN:
			_snwprintf_s(buffer, _TRUNCATE, L"%i", GetGValue(color));
			break;
		case BLUE:
			_snwprintf_s(buffer, _TRUNCATE, L"%i", GetBValue(color));
			break;
		}
		measure->returnedString = buffer;
	}
}

PLUGIN_EXPORT void Finalize(void* data)
{
	Measure* measure = (Measure*)data;
	delete measure;
}
Readme.txt:

Code: Select all

CursorColor Plugin
Retrieves the color of the pixel under the cursor.
Must be called with [!CommandMeasure MeasureName "GetColor"].
Only option is "Format", which can be RGB/Red/Green/Blue.

[MeasureRGBColor]
Measure=Plugin
Plugin=CursorColor
Format=RGB

[MeasureRedColor]
Measure=Plugin
Plugin=CursorColor
Format=Red

[MeasureGreenColor]
Measure=Plugin
Plugin=CursorColor
Format=Green

[MeasureBlueColor]
Measure=Plugin
Plugin=CursorColor
Format=Blue

Sorry eclectic-tech ;-) I'll go away now...
You do not have the required permissions to view the files attached to this post.