Skip to content

Commit

Permalink
Update a few scripts and lua autocomplete
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Aug 14, 2023
1 parent 72644d8 commit 9b24fee
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 10 deletions.
55 changes: 52 additions & 3 deletions Assets/Resources/LuaModules/__autocomplete.lua
Expand Up @@ -198,6 +198,22 @@ function Brush:ForcePaintingOff(active) end

function Brush:ForceNewStroke() end

---@param type string
---@return string[]
function Brush:GetShaderFloatParameters(type) end

---@param type string
---@return string[]
function Brush:GetShaderColorParameters(type) end

---@param type string
---@return string[]
function Brush:GetShaderTextureParameters(type) end

---@param type string
---@return string[]
function Brush:GetShaderVectorParameters(type) end

---Properties for class CameraPath

---@class CameraPath
Expand Down Expand Up @@ -1009,6 +1025,15 @@ function Layer:Show() end

function Layer:Hide() end

---@param brushType string
---@param start number
---@param end number
function Layer:SetShaderClipping(brushType, start, end) end

---@param parameter string
---@param value number
function Layer:SetShaderFloat(parameter, value) end

---@param brushType string
---@param parameter string
---@param value number
Expand Down Expand Up @@ -2073,6 +2098,10 @@ function Stroke:Join(stroke2) end
---@param name string
function Stroke:MergeFrom(name) end

---@param start number
---@param end number
function Stroke:SetShaderClipping(start, end) end

---@param parameter string
---@param value number
function Stroke:SetShaderFloat(parameter, value) end
Expand Down Expand Up @@ -2114,6 +2143,29 @@ StrokeList.count = nil


function StrokeList:Delete() end

---@param start number
---@param end number
function StrokeList:SetShaderClipping(start, end) end

---@param parameter string
---@param value number
function StrokeList:SetShaderFloat(parameter, value) end

---@param parameter string
---@param color Color
function StrokeList:SetShaderColor(parameter, color) end

---@param parameter string
---@param image Image
function StrokeList:SetShaderTexture(parameter, image) end

---@param parameter string
---@param x number
---@param y number
---@param z number
---@param w number
function StrokeList:SetShaderVector(parameter, x, y, z, w) end
---Methods for type Svg

---@param svgPath string
Expand Down Expand Up @@ -2148,9 +2200,6 @@ Symmetry.brushOffset = nil
---@type Vector3
Symmetry.wandOffset = nil

---@type Vector3
Symmetry.pointerOffset = nil


---Methods for type Symmetry

Expand Down
@@ -0,0 +1,29 @@
Settings = {description="Example stroke animation"}

Parameters = {
speed={label="Speed", type="float", min=1, max=10, default=4},
copies={label="Copies", type="int", min=1, max=96, default=36},
hueShift={label="Hue Shift", type="float", min=0, max=1, default=0.5},
}

function Start()
angle = 360 / copies
Brush.type = "TubeHighlighter"
Sketch.mainLayer.allowStrokeAnimation = true
for i = 0, copies - 1, 1 do
path = Path2d:Polygon(24):OnZ()
path:TranslateBy(Vector3:New(4, 0, 0))
path:RotateBy(Rotation:New(0, i * angle, 0))
path:TranslateBy(Vector3:New(0, 12, 10))
Brush.colorRgb = Color:HsvToRgb(i/copies * hueShift, 1, 0.5)
path:Draw()
end
strokes = Sketch.mainLayer.strokes
end

function Main()
for i = 0, copies - 1, 1 do
value = (Math.Sin(App.time * speed + (i * 0.2)) + 1) / 4
strokes[i].SetShaderClipping(value, value + 0.5)
end
end
@@ -1,35 +1,35 @@
Settings = {space="pointer"}

Parameters = {
spacing={label="Point Spacing", type="float", min=0.1, max=1, default=0.1},
copies={label="Copies", type="int", min=1, max=96, default=32},
}

symmetryHueShift = require "symmetryHueShift"

function Start()
initialHsv = Brush.colorHsv
stroke = Sketch.strokes.last
updatePath()
end

function Main()

-- Update the path if we changed the spacing
if spacing ~= lastSpacing then
if copies ~= lastCopies then
updatePath()
lastSpacing = spacing
lastCopies = copies
end
return path
end

function updatePath()
stroke = Sketch.strokes.last
if stroke == nil then
App.Error("Please draw a stroke and then restart this plugin")
path = Path:New()
else
path = stroke.path
path:SampleByDistance(spacing)
path:SampleByCount(copies)
path:Center()
symmetryHueShift.generate(path.count, initialHsv)
symmetryHueShift.generate(copies, initialHsv)
end
end
Expand Up @@ -9,7 +9,8 @@ Parameters = {
function Main()

if Brush.triggerPressedThisFrame then
Symmetry.transform = Transform:New(Brush.position, Brush.rotation)
Symmetry.current.position = Brush.position
Symmetry.current.rotation = Brush.rotation
end

-- Don't allow painting immediately otherwise you get stray lines
Expand Down

0 comments on commit 9b24fee

Please sign in to comment.