Skip to content

Latest commit

 

History

History
335 lines (138 loc) · 7.89 KB

File metadata and controls

335 lines (138 loc) · 7.89 KB

Stroke

Summary

A specific brush stroke

Instance Properties

NameReturn TypeDescription
pathPath
Read/Write
The control points of this stroke from a Path
brushTypestring
Read/Write
The stroke's brush type
brushSizenumber
Read/Write
The stroke's size
brushColorColor
Read/Write
The stroke's Color
layerLayer
Read/Write
The layer the stroke is on
groupGroup
Read/Write
The group this stroke is part of
this[index]Transform
Read/Write
Gets or sets a control point by index
countnumber
Read-only
The number of control points in this stroke

Class Methods

Stroke:SelectRange(from, to)

Adds multiple strokes to the current selection

Returns: nil

Parameters:

NameTypeDefaultDescription
fromnumberStart stroke index (0 is the first stroke that was drawn
tonumberEnd stroke index

Example

Stroke:SelectMultiple(0, 4) --Adds the first 5 strokes on the sketch

Instance Methods

stroke:ChangeMaterial(brushName)

Assigns the material from another brush type to this stroke (Experimental. Results are unpredictable and are not saved with the scene)

Returns: nil

Parameters:

NameTypeDefaultDescription
brushNamestringThe name (or guid) of the brush to get the material from

Example

myStroke.ChangeMaterial("Light")

stroke:Delete()

Deletes the current stroke

Returns: nil

Example

myStroke:Delete()

stroke:Select()

Adds this stroke to the current selection

Returns: nil

Example

myStroke:Select()

stroke:Deselect()

Removes this stroke from the current selection

Returns: nil

Example

myStroke:Deselect()

stroke:JoinRange(from, to)

Joins joins multiple strokes into one stroke

Returns: Stroke

Parameters:

NameTypeDefaultDescription
fromnumberStart stroke index (0 is the first stroke that was drawn
tonumberEnd stroke index

Example

newStroke = Stroke:Join(0, 10)

stroke:JoinToPrevious()

Joins a stroke with the previous stroke

Returns: Stroke

Example

newStroke = myStroke:JoinPrevious()

stroke:Join(stroke2)

Joins a stroke with the previous stroke

Returns: Stroke

Parameters:

NameTypeDefaultDescription
stroke2StrokeThe stroke to join to this one

Example

newStroke = myStroke:JoinPrevious()

stroke:MergeFrom(name)

Imports the file with the specified name from the user's Sketches folder and merges it's strokes into the current sketch

Returns: nil

Parameters:

NameTypeDefaultDescription
namestringName of the file to be merged

Example

Stroke:MergeFrom(string name)

stroke:SetShaderClipping(clipStart, clipEnd)

Hides the section of the stroke that is outside the specified range

Returns: nil

Parameters:

NameTypeDefaultDescription
clipStartnumberThe amount of the stroke to hide from the start (0-1)
clipEndnumberThe amount of the stroke to hide from the end (0-1)

Example

myStroke:SetShaderClipping(0.1, 0.9)

stroke:SetShaderFloat(parameter, value)

Changes a shader float parameter

Returns: nil

Parameters:

NameTypeDefaultDescription
parameterstringThe shader parameter name
valuenumberThe new value

Example

myStroke:SetShaderFloat("_EmissionGain", 0.5)

stroke:SetShaderColor(parameter, color)

Changes a shader color parameter

Returns: nil

Parameters:

NameTypeDefaultDescription
parameterstringThe shader parameter name
colorColorThe new color

Example

myStroke:SetShaderColor("_TintColor", Color.red)

stroke:SetShaderTexture(parameter, image)

Changes a shader texture parameter

Returns: nil

Parameters:

NameTypeDefaultDescription
parameterstringThe shader parameter name
imageImageThe new image to use as a texture

Example

myStroke:SetShaderTexture("_MainTex", myImage)

stroke:SetShaderVector(parameter, x, y, z, w)

Changes a shader vector parameter

Returns: nil

Parameters:

NameTypeDefaultDescription
parameterstringThe shader parameter name
xnumberThe new x value
ynumber0The new y value
znumber0The new z value
wnumber0The new w value

Example

myStroke:SetShaderVector("_TimeOverrideValue", 0.5, 0, 0, 0)