Stroke weight and color for drawing.
Can be used as stroke.apply()
to apply the stroke settings globally, or
as the parameter of drawable.draw(stroke)
to apply the stroke only for
that draw
.
Applying the instance can have the following behaviours:
- Applies a no-stroke setting; when
color = null
andweight = null
- Applies only stroke color, leaving weight unchanged; when
color
is set andweight = null
- Applies only stroke weight, leaving color unchanged; when
weight
is set andcolor = null
- Applies both weight and color; when both
color
andweight
are set
instance.Stroke
Instances of Rac
contain a convenience
rac.Stroke
function to create Stroke
objects with
fewer parameters. This function also contains ready-made convenience
objects, like rac.Stroke.none
, listed
under instance.Stroke
.
Example
let rac = new Rac()
let color = rac.Color(0.2, 0.4, 0.6)
// new instance with constructor
let stroke = new Rac.Stroke(rac, 2, color)
// or convenience function
let otherStroke = rac.Stroke(2, color)
- See also:
Constructor
new Stroke(rac, weightnullable, coloropt, nullable)
Creates a new Stroke
instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
||
weight |
Number
|
<nullable> |
The weight of the stroke, or |
|
color |
Rac.Color
|
<optional> <nullable> |
null
|
A |
Members
rac :Rac
Instance of Rac
used for drawing and passed along to any created
object.
Methods
(static) from(rac, something) → {Rac.Stroke}
Returns a Stroke
derived from something
.
- When
something
is an instance ofStroke
, returns that same object. - When
something
is an instance ofColor
, returns a newStroke
usingsomething
ascolor
and anull
stroke weight. - When
something
is an instance ofFill
, returns a newStroke
usingfill.color
and anull
stroke weight. - Otherwise an error is thrown.
Parameters:
Name | Type | Description |
---|---|---|
rac |
Rac
|
Instance to pass along to newly created objects |
something |
Rac.Stroke
|
Rac.Color
|
Rac.Fill
|
An object to
derive a |
appendFill(someFill) → {Rac.StyleContainer}
Returns a new StyleContainer
containing this
and the Fill
derived from someFill
.
- See also:
Parameters:
Name | Type | Description |
---|---|---|
someFill |
Rac.Fill
|
Rac.Color
|
Rac.Stroke
|
An object to derive
a |
appendStyle(style) → {Rac.StyleContainer|Rac.Stroke}
Returns a new StyleContainer
containing this
and style
. When
style
is null
, returns this
instead.
Parameters:
Name | Type | Description |
---|---|---|
style |
Rac.Stroke
|
Rac.Fill
|
Rac.StyleContainer
|
A style object
to contain along |
container() → {Rac.StyleContainer}
Returns a new StyleContainer
containing only this
.
withAlpha(newAlpha) → {Rac.Stroke}
Returns a new Stroke
with a copy of color
setup with newAlpha
,
and the same stroke
as this
.
When this.color
is set to null
, returns a new Stroke
that is a
copy of this
.
Parameters:
Name | Type | Description |
---|---|---|
newAlpha |
Number
|
The alpha channel of the |
withWeight(newWeightnullable) → {Rac.Stroke}
Returns a new Stroke
with weight
set to newWeight
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
newWeight |
Number
|
<nullable> |
The weight of the stroke, or |