Rac. Stroke

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 = null and weight = null
  • Applies only stroke color, leaving weight unchanged; when color is set and weight = null
  • Applies only stroke weight, leaving color unchanged; when weight is set and color = null
  • Applies both weight and color; when both color and weight 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 null to skip weight

color Rac.Color <optional>
<nullable>
null

A Color for the stroke, or null to skip color

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 something is an instance of Stroke, returns that same object.
  • When something is an instance of Color, returns a new Stroke using something as color and a null stroke weight.
  • When something is an instance of Fill, returns a new Stroke using fill.color and a null 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 Stroke from

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 Fill from

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 this

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 color of the new Stroke

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 null to skip weight