Stroke weight and color for drawing.
Can be used with stroke.apply() to apply the stroke settings globally,
or as the parameter of drawable.draw(stroke) to apply the stroke only
during that call.
Applying the instance can have the following behaviours:
- Applies a no-stroke setting; when
color = nullandweight = null - Applies only stroke color, leaving weight unchanged; when
coloris set andweight = null - Applies only stroke weight, leaving color unchanged; when
weightis set andcolor = null - Applies both weight and color; when both
colorandweightare 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
(nullable) color :Color
The Color to apply for strokes, when null no color setting is
applied.
rac :Rac
Instance of Rac used for drawing and passed along to any created
object.
(nullable) weight :Number
The weight to apply for strokes, when null no weight setting is
applied.
Methods
(static) from(rac, something) → {Rac.Stroke}
Returns a Stroke derived from something.
- When
somethingis an instance ofStroke, returns that same object. - When
somethingis an instance ofColor, returns a newStrokeusingsomethingascolorand anullstroke weight. - When
somethingis an instance ofFill, returns a newStrokeusingfill.colorand anullstroke 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 |