Rac. Stroke

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.

The instance applies the stroke color and weight settings in the following combinations:

  • when color = null and weight = null: a no-stroke setting is applied
  • when color is set and weight = null: only the stroke color is applied, stroke weight is not modified
  • when weight is set and color = null: only the stroke weight is applied, stroke color is not modified
  • when both color and weight are set: both stroke color and weight are applied

Constructor

new Stroke(rac, weightnullable, colornullable)

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 <nullable>
null

A Color for the stroke, or null to skip color

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

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