forked from icosa-foundation/open-brush
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update a few scripts and lua autocomplete
[CI BUILD]
- Loading branch information
Showing
4 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Assets/Resources/LuaScriptExamples/BackgroundScript.DrawAndAnimateStrokes.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
12 changes: 6 additions & 6 deletions
12
Assets/Resources/LuaScriptExamples/SymmetryScript.AlongStroke.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters