ColorRotate

Discuss the use of Lua in Script measures.
User avatar

ColorRotate

August 26th, 2017, 4:07 am
jsmorley
Developer   [16120 posts]

This requires at least the r2858 4.1 beta of Rainmeter from https://www/rainmeter.net.

Use Lua to rotate through the 360° "hue" of the HSB color space.
So this will transition through red > yellow > green > cyan > blue > purple and back to red.

The "saturation" and "brightness" can be set to some desired static value from 0.0 to 1.0, a percentage.

ColorRotate.ini:

Code: Select all

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

[Metadata]
Name=ColorRotate
Author=JSMorley
Information=Use Lua to rotate through the 360° "hue" of the HSB color space.|So this will transition through red > yellow > green > cyan > blue > purple and back to red.||The "saturation" and "brightness" can be set to some desired static value from 0.0 to 1.0, a percentage.
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=August 25, 2017

[MeasureMyColor]
Measure=Script
ScriptFile=ColorRotate.lua
; MySaturation and MyBrightness can be 0.0 (none) to 1.0 (full)
MySaturation=0.5
MyBrightness=1.0

[MeterMyImage]
Meter=Image
W=100
H=100
SolidColor=[MeasureMyColor]
DynamicVariables=1

[MeterMyString]
Meter=String
X=15R
Y=17
FontSize=30
FontWeight=400
FontColor=[MeasureMyColor]
AntiAlias=1
DynamicVariables=1
Text=Color is: [MeasureMyColor]#CRLF#Hue is: [&MeasureMyColor:currentHue]°


ColorRotate.lua:

Code: Select all

function Initialize()

   dofile(SKIN:GetVariable('@')..'HSBLib\\HSBLib.lua')
   
   huePercent = 0.0
   saturation = SELF:GetOption('MySaturation') or 1.0
   brightness = SELF:GetOption('MyBrightness') or 1.0
   
end

function Update()

   red, green, blue = HSBtoRGB(huePercent, saturation, brightness)
   
   currentHue = Round(360 * huePercent)
   
   huePercent = Clamp(huePercent + 0.005, 0.0, 1.0)
   if huePercent == 1.0 then huePercent = 0.0 end   
      
   return red..','..green..','..blue
   
end


https://docs.rainmeter.net/manual-beta/lua-scripting/inline-lua/

This also includes a library HSBLib.lua, to convert back and forth from RGB to HSB. This is more or less a "black box", and you should not have to deal with it.

ColorRotate_1.0.rmskin
(2.29 KiB) Downloaded 9 times


Return to “Lua Scripting”



Who is online

Users browsing this forum: No registered users and 1 guest