Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 975

Lua Scripting • raincolors.lua

$
0
0
[ORIGINAL POST DELETED] for new readers first 4 pages of this post may not make sense.

RAINCOLORS.LUA
A color manipualtion library that includes color theory and harmony functions

So, after some days working in this, finally I feel comfortable to share what is the first version of the (now named) raincolors.lua.

This is my first time doing stuff in lua so there might be things that can be optimized and I would love anyone who points at any error, bug, or possible improvement, also new functions are welcomed. I prepared 3 basic skins as examples.

Content
  • Conversion
  • hex2rgb(HEX) and rgb2hex(color)
    Converts Hex to RGB and viceversa.
  • rgb2hsl(r, g, b) and hsl2rgb(h, s, l)
    Convert HSL to RGB and viceversa.

    Information
  • colorBrightness(color)
    Returns color's relative luminance value
  • contrastRatio(color1,color2)
    Returns the contrast ratio between 2 colors.
  • colorHSL(color)
    Returns HSL values of an RGB color.
  • colorHEX(color)
    Returns RGB color in HEX
  • colorRGB(HEX)
    Returns HEX color in RGB.

    Manipulation
  • shiftHue(color, angle)
    Shifts Hue by a given angle.
  • shiftSat(color,amount)
    Shifts Saturation by a given amount.
  • shiftLight(color,amount)
    Shifts Lightness by a given amount.
  • blackORwhite(color)
    Returns black or white depending on the color's brightness.
  • adjustContrast(color1, color2, desiredContrast)
    Brightens or darkens color2 based on color1 to a desired contrast between them.
  • invert(color)
    Inverts a color.
  • desaturate(color, amount)
    Desaturates a color by an amount or 30 if no amount is entered.
  • saturate(color, amount)
    Saturates a color by 30or an amount
  • brighten(color, amount)
    Brightens a color by 30 or an amount.
  • darken(color, amount)
    Darkens a color by 30 or an amount
  • neighborR(color, angle)
    Shifts color's hue 30 degrees.
  • neighborL(color, angle)
    Shifts color's hue -30 degrees.

    Color Theory
  • complementary(color)
    Returns the complementary (180 degrees) of a given color.
  • splitComplementary(color)
    Returns 2 colors - and +150 degrees.
  • triadic(color)
    Returns 2 colors - and +120 degrees.
  • analogous(color)
    Returns 2 colors - and +30 degrees.
  • tetradic(color)
    Returns 3 colors + 60, 180 and 240 degrees.
  • square(color)
    Returns 3 colors + 90, 180 and 270 degrees.

    Color Generation
  • shades(color, count, amount)
    Generates a count of colors with lowered lightness by an amount.
  • tints(color, count, amount)
    Generates a count of colors with increased lightness by an amount.
  • tones(color, count, amount)
    Generates a count of colors with decreased saturation by an amount.
On this package you'll find 3 examples and raincolors.lua script.
I'll come back later to add more info.

To do list:
Add HEX support to all manipulation functions.

Statistics: Posted by RicardoTM — March 5th, 2024, 10:41 pm — Replies 31 — Views 849



Viewing all articles
Browse latest Browse all 975

Trending Articles