YACS is a project that started out as just a small function of a few lines, to just grab the color under the cursor and copy it to the clipboard. Then I decided that I wanted to see the color i was hovering over. Then I decided I wanted to see more than one pixel in the color preview. It was at that point that I realized I would need to use GDI to make this usable. Now, it's a fully featured color selector that you can use standalone, or in your own projects!
-
FontName- The name of the font to use for the label on the
ColorPickerpreview window.
- The name of the font to use for the label on the
-
FontSize- The size of the font to use for the label on the
ColorPickerpreview window.
- The size of the font to use for the label on the
-
ViewMode- Can be "crosshair", "grid", any other value will result in the "blank" overlay with the center dot highlighter.
-
UpdateInterval- The interval at which the preview will update, in milliseconds. 16ms = ~60 updates / second.
-
HighlightCenter- If True, highlights the pixel that the color is copied from.
-
BorderWidth- Thickness of the preview border, in pixels.
-
CrosshairWidth- Thickness of crosshair lines, in pixels.
-
GridWidth- Thickness of grid lines, in pixels.
-
CenterDotRadius- Radius of the Center Dot when not in "grid" or "crosshair" mode, in pixels.
-
TextPadding- The padding added above and below the preview Hex String, in pixels (half above, half below)
-
DefaultCaptureSize- The size of area you want to capture around the cursor in pixels (N by N square).
-
DefaultZoomFactor-
The amount by which to multiply the preview size.
-
window side length in pixels = captureSize * zoomFactor.EX: (9 * 11 = 99x99 pixel preview)
-
-
LargeJumpAmount- How many pixels to move the preview window by when holding shift and moving it with the keyboard.
-
Color Arrays:
- Each array holds two values. The first value in each array is for one theme, and the second value is for the other
-
TextFGColors[],TextBGColors[]-
Text Foreground and Background color control
-
Holds two hexadecimal values in the format
0xBBGGRR. Switch between colors while running by pressingC.
-
-
BorderColors[],CrosshairColors[],GridColors[],HighlightColors[]-
Border, Crosshair, Grid, and Highlighter color control.
-
Holds two hexadecimal values in the format
0xAABBGGRR. Switch between colors while running by pressingC.
-
-
Format Strings
- The format strings control the format of the output object.
-
HexFormat-
Default:
"#{R}{G}{B}" -
{R}: Represents theRchannel. -
{G}: Represents theGchannel. -
{B}: Represents theBchannel.
-
-
RGBFormat-
Default:
"rgb({R}, {G}, {B})" -
{R}: Represents theRchannel. -
{G}: Represents theGchannel. -
{B}: Represents theBchannel.
-
-
Color- The output
Color, please refer to theColorclass definition for more details.
- The output
-
Clip- If
True, copies the selected color value to the clipboard.
- If
-
TargetHWND- If assigned a valid HWND, the ColorPicker will be locked inside of that window or control.
-
Callback-
Can be assigned any function that takes a single argument.
-
The object passed to the callback function is the same as the output object.
-
The callback is called on every update of the ColorPicker. Depending on what your callback does, it can slow the operation down considerably.
-
-
Constructor:
ColorPicker(clip := False, hwnd := 0, callback := 0)-
Creates a new instance of
ColorPicker -
Arguments:
-
clip: If true, the chosen color will be copied to the clipboard -
hwnd: When provided with a valid HWND, the ColorPicker will be locked inside of that window or control. -
callback: Provide a function that takes one argument. The object provided to the function is the same asColorPicker.Color. This will be called on every update of the ColorPicker.
-
-
-
Start(clip := False, hwnd := 0, callback := 0)-
Starts the
ColorPickerinstance with the provided options and property values. -
Arguments:
-
clip: If true, the chosen color will be copied to the clipboard -
hwnd: When provided with a valid HWND, the ColorPicker will be locked inside of that window or control. -
callback: Provide a function that takes one argument. The object provided to the function is the same asColorPicker.Color. This will be called on every update of the ColorPicker.
-
-
-
static Run(clip := False, hwnd := 0, callback := 0)-
Starts a
ColorPickerwith default values. -
Does not create a persistent
ColorPickerinstance. -
Arguments:
-
clip: If true, the chosen color will be copied to the clipboard -
hwnd: When provided with a valid HWND, the ColorPicker will be locked inside of that window or control. -
callback: Provide a function that takes one argument. The object provided to the function is the same asColorPicker.Color. This will be called on every update of the ColorPicker.
-
-
-
To use, just create an instance of
ColorPicker. If you don't pass arguments now, you can assign those properties later:picker := ColorPicker()
-
Change any properties you want to change:
-
picker.FontName := "Papyrus" -
picker.FontSize := 16 -
picker.TargetHWND := ControlGetHwnd(control)
-
-
Start the
ColorPicker!color := picker.Start()
-
If you don't want to create an instance of
ColorPicker, you can use a static method :color := ColorPicker.Run()