Skip to content

Commit

Permalink
script refactor and more svg/path methods
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Apr 15, 2023
1 parent 6e8f379 commit c485777
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 108 deletions.
8 changes: 8 additions & 0 deletions Assets/Resources/LuaModules/__autocomplete.lua
Expand Up @@ -274,6 +274,13 @@ function path.transform(path, transform) end
function path.translate(path, amount) end
function path.rotate(path, amount) end
function path.scale(path, amount) end
function path.centered(path) end
function path.startingFrom(path, index) end
function path.findClosest(path, point) end
function path.findMinimum(path, axis) end
function path.findMaximum(path, axis) end
function path.normalized(path) end
function path.resample(path, spacing) end
visualizer.sampleRate = nil
visualizer.duration = nil
function visualizer.enableScripting(name) end
Expand Down Expand Up @@ -338,6 +345,7 @@ function symmetry.getColors() end
function symmetry.setBrushes(brushes) end
function symmetry.getBrushNames() end
function symmetry.getBrushGuids() end
function symmetry.pointsToPolar(transforms) end
function symmetry.pointsToPolar(cartesianPoints) end
function timer.set(fn, interval, delay, repeats) end
function timer.unset(fn) end
Expand Down
24 changes: 24 additions & 0 deletions Assets/Resources/LuaModules/symmetryHueShift.lua
@@ -0,0 +1,24 @@
local symmetryHueShift = {}

if not Parameters then
Parameters = {}
end

Parameters["hueShiftFrequency"] = {label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1}
Parameters["hueShiftAmount"] = {label="Hue Shift Amount", type="float", min=0, max=1, default=0.3}

function symmetryHueShift.generate(copies, initialHsv)
if hueShiftAmount > 0 then
colors = {}
for i = 0, copies - 1 do
t = i / copies
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(colors, newColor)
end
symmetry.setColors(colors)
brush.forceNewStroke()
end
end

return symmetryHueShift
10 changes: 10 additions & 0 deletions Assets/Resources/LuaModules/symmetryHueShift.lua.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -4,15 +4,16 @@

Parameters = {
layerNumber={label="Layer Number", type="int", min=0, max=10, default=1},
speedX={label="X Rotation Speed", type="float", min=0.01, max=20, default=0},
speedY={label="Y Rotation Speed", type="float", min=0.01, max=20, default=0},
speedZ={label="Z Rotation Speed", type="float", min=0.01, max=20, default=6},
radius={label="Radius", type="float", min=0.01, max=5, default=1},
speedX={label="X Rotation Speed", type="int", min=-10, max=10, default=0},
speedY={label="Y Rotation Speed", type="int", min=-10, max=10, default=0},
speedZ={label="Z Rotation Speed", type="int", min=-10, max=10, default=2},
}

function Start()
layers.centerPivot(layerNumber)
originalRotation = layers.getRotation(layerNumber)
angle = {x = 0, y = 0, z = 0}
layers.centerPivot(layerNumber)
-- layers.showPivot(layerNumber)
end

function Main()
Expand All @@ -24,3 +25,7 @@ function Main()
rotation = angle
layers.setRotation(layerNumber, rotation)
end

function End()
layers.setRotation(layerNumber, originalRotation)
end
@@ -1,12 +1,12 @@
Settings = {space="canvas"}

Parameters = {
copies={label="Number of copies", type="int", min=1, max=64, default=12},
delay={label="Delay per copy", type="int", min=1, max=10, default=4},
amount={label="Amount", type="float", min=0, max=1, default=0.5},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.1}
}

Settings = {space="canvas"}
symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
Expand Down
Expand Up @@ -6,10 +6,10 @@ Parameters = {
copies={label="Number of copies", type="int", min=1, max=96, default=32},
eccentricity={label="Eccentricity", type="float", min=0.1, max=3, default=2},
axisConsistency={label="Axis Consistency", type="float", min=0, max=2, default=1},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.3}
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
--symmetry.transform = {
Expand All @@ -20,9 +20,12 @@ end

function Main()

if brush.triggerIsPressedThisFrame then
symmetryHueShift.generate(copies, initialHsv)
end

pointers = {}
theta = (math.pi * 2.0) / copies
Colors = {}

for i = 0, copies - 1 do
angle = (symmetry.rotation.y * unityMathf.deg2Rad) + i * theta
Expand All @@ -41,20 +44,10 @@ function Main()
rotation={0, angle * unityMathf.rad2Deg, 0}
}
table.insert(pointers, pointer)

--Colour cycling for the extra pointers
if hueShiftAmount > 0 then
t = i / copies
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(Colors, newColor)
end

end
return pointers
end

function End()
--TODO
--color.setHsv(color.HsvToRgb(brush.colorHsv))
-- TODO fix brush.colorHsv = initialHsv
end
20 changes: 7 additions & 13 deletions Assets/Resources/LuaScriptExamples/SymmetryScript.ManyAlong.lua
Expand Up @@ -5,18 +5,21 @@
Parameters = {
copies={label="Number of copies", type="int", min=1, max=36, default=12},
distance={label="Distance", type="float", min=0, max=20, default=5},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.5}
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
end

function Main()

if brush.triggerIsPressedThisFrame then
symmetryHueShift.generate(copies, initialHsv)
end

pointers = {}
Colors = {}

for i = 0, copies - 1 do

Expand All @@ -29,19 +32,10 @@ function Main()
symmetry.brushOffset.z
}}
table.insert(pointers, pos)

--Colour cycling for the extra pointers
if hueShiftAmount > 0 then
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(Colors, newColor)
end

end
return pointers
end

function End()
--TODO
--color.setHsv(color.HsvToRgb(brush.colorHsv))
-- TODO fix brush.colorHsv = initialHsv
end
21 changes: 7 additions & 14 deletions Assets/Resources/LuaScriptExamples/SymmetryScript.ManyAround.lua
Expand Up @@ -4,10 +4,10 @@

Parameters = {
copies={label="Number of copies", type="int", min=1, max=96, default=32},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.3}
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
--symmetry.transform = {
Expand All @@ -18,9 +18,12 @@ end

function Main()

if brush.triggerIsPressedThisFrame then
symmetryHueShift.generate(copies, initialHsv)
end

pointers = {}
theta = 360.0 / copies
Colors = {}

for i = 0, copies - 1 do
angle = i * theta
Expand All @@ -33,20 +36,10 @@ function Main()
rotation={0, angle, 0}
}
table.insert(pointers, pointer)

--Colour cycling for the extra pointers
if hueShiftAmount > 0 then
t = i / copies
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(Colors, newColor)
end

end
return pointers
end

function End()
--TODO
--color.setHsv(color.HsvToRgb(brush.colorHsv))
-- TODO fix brush.colorHsv = initialHsv
end
Expand Up @@ -5,19 +5,22 @@
Parameters = {
copies={label="Number of copies", type="int", min=1, max=96, default=32},
sides={label="Sides", type="int", min=3 , max=12, default=5},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.3}
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
end

function Main()

if brush.triggerIsPressedThisFrame then
symmetryHueShift.generate(copies, initialHsv)
end

pointers = {}
theta = (math.pi * 2.0) / copies
Colors = {}

for i = 0, copies - 1 do
angle = (symmetry.rotation.y * unityMathf.deg2Rad) + i * theta
Expand All @@ -32,20 +35,10 @@ function Main()
rotation={0, angle * unityMathf.rad2Deg, 0}
}
table.insert(pointers, pointer)

--Colour cycling for the extra pointers
if hueShiftAmount > 0 then
t = i / copies
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(Colors, newColor)
end

end
return pointers
end

function End()
--TODO
--color.setHsv(color.HsvToRgb(brush.colorHsv))
-- TODO fix brush.colorHsv = initialHsv
end
Expand Up @@ -7,29 +7,18 @@ Parameters = {
numPointsHeight={label="Number of points along height", type="int", min=2, max=32, default=5},
spacing={label="Spacing", type="float", min=0.001 , max=1, default=.2},
exteriorOnly={label="Exterior Only", type="int", min=0, max=1, default=1},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.3}
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
end

function Main()

if brush.triggerIsPressedThisFrame then
if hueShiftAmount > 0 then
colors = {}
copies = numPointsWidth * numPointsHeight * 2
for i = 0, copies - 1 do
t = i / copies
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(colors, newColor)
end
symmetry.setColors(colors)
brush.forceNewStroke()
end
symmetryHueShift.generate(numPointsWidth * numPointsHeight * 2, initialHsv)
end

if (exteriorOnly==1) then
Expand Down Expand Up @@ -77,6 +66,5 @@ end


function End()
--TODO
--color.setHsv(color.HsvToRgb(brush.colorHsv))
-- TODO fix brush.colorHsv = initialHsv
end
Expand Up @@ -7,19 +7,22 @@ Parameters = {
n={label="n", type="float", min=0.1 , max=4, default=4},
eccentricity={label="Eccentricity", type="float", min=0.1, max=3, default=1},
axisConsistency={label="Axis Consistency", type="float", min=0, max=2, default=1},
hueShiftFrequency={label="Hue Shift Frequency", type="float", min=0.1, max=6, default=1},
hueShiftAmount={label="Hue Shift Amount", type="float", min=0, max=1, default=0.3}
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = brush.colorHsv
end

function Main()

if brush.triggerIsPressedThisFrame then
symmetryHueShift.generate(copies, initialHsv)
end

pointers = {}
theta = (math.pi * 2.0) / copies
Colors = {}

for i = 0, copies - 1 do
angle = (symmetry.rotation.y * unityMathf.deg2Rad) + i * theta
Expand All @@ -41,20 +44,10 @@ function Main()
rotation={0, angle * unityMathf.rad2Deg, 0}
}
table.insert(pointers, pointer)

--Colour cycling for the extra pointers
if hueShiftAmount > 0 then
t = i / copies
newHue = waveform.triangle(t, hueShiftFrequency) * hueShiftAmount
newColor = unityColor.hsvToRgb(initialHsv.x + newHue, initialHsv.y, initialHsv.z)
table.insert(Colors, newColor)
end

end
return pointers
end

function End()
--TODO
--color.setHsv(color.HsvToRgb(brush.colorHsv))
-- TODO fix brush.colorHsv = initialHsv
end

0 comments on commit c485777

Please sign in to comment.