Lua Plugins options

I wanted to give the scripts which called symmetryHueShift.lua the option to choose whether or not to change the colors, without impacting scripts that weren't updated. This appears to work, although sometimes it takes a couple of draw attempts for the change to actually take place
-- Contents of SymmetryHueShift.lua
local SymmetryHueShift = {}

-- Add parameters for hue shift frequency and amount
local hueShiftFrequency = 1
local hueShiftAmount = 0.1

-- Generate a series of colors based on the initial HSV color and the specified number of copies
function SymmetryHueShift.generate(copies, initialHsv, changeColor)
-- Set default behavior for changeColor if not provided
if changeColor == nil then
changeColor = 1 -- Default to 1 (true)
end

Symmetry.ClearColors()
if changeColor == 1 and hueShiftAmount > 0 then
for i = 0, copies - 1 do
local t = i / copies
local newHue = Waveform:Triangle(t, hueShiftFrequency) * hueShiftAmount
local newColor = Color.HsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
Symmetry.AddColor(newColor)
end
Brush.ForceNewStroke()
end
end

return SymmetryHueShift
-- Contents of SymmetryHueShift.lua
local SymmetryHueShift = {}

-- Add parameters for hue shift frequency and amount
local hueShiftFrequency = 1
local hueShiftAmount = 0.1

-- Generate a series of colors based on the initial HSV color and the specified number of copies
function SymmetryHueShift.generate(copies, initialHsv, changeColor)
-- Set default behavior for changeColor if not provided
if changeColor == nil then
changeColor = 1 -- Default to 1 (true)
end

Symmetry.ClearColors()
if changeColor == 1 and hueShiftAmount > 0 then
for i = 0, copies - 1 do
local t = i / copies
local newHue = Waveform:Triangle(t, hueShiftFrequency) * hueShiftAmount
local newColor = Color.HsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
Symmetry.AddColor(newColor)
end
Brush.ForceNewStroke()
end
end

return SymmetryHueShift
1 Reply
AncientWorlds
AncientWorldsOP13mo ago
I wanted to give the scripts which called symmetryHueShift.lua the option to choose whether or not to change the colors
Want results from more Discord servers?
Add your server