Class: Plushie::Canvas::Shape::LinearGradient

Inherits:
Data
  • Object
show all
Defined in:
lib/plushie/canvas/shape/linear_gradient.rb

Overview

Linear gradient descriptor usable as a canvas fill value.

Examples:

LinearGradient.new(from: [0, 0], to: [200, 0],
  stops: [[0.0, "#ff0000"], [1.0, "#0000ff"]])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from:, to:, stops:) ⇒ LinearGradient

Returns a new instance of LinearGradient.



12
13
14
# File 'lib/plushie/canvas/shape/linear_gradient.rb', line 12

def initialize(from:, to:, stops:)
  super
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



11
12
13
# File 'lib/plushie/canvas/shape/linear_gradient.rb', line 11

def from
  @from
end

#stopsObject (readonly)

Returns the value of attribute stops

Returns:

  • (Object)

    the current value of stops



11
12
13
# File 'lib/plushie/canvas/shape/linear_gradient.rb', line 11

def stops
  @stops
end

#toObject (readonly)

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



11
12
13
# File 'lib/plushie/canvas/shape/linear_gradient.rb', line 11

def to
  @to
end

Instance Method Details

#[](key) ⇒ Object

Backward-compatible hash-style access.



17
# File 'lib/plushie/canvas/shape/linear_gradient.rb', line 17

def [](key) = to_wire[key]

#to_wireHash

Returns wire-ready gradient map.

Returns:

  • (Hash)

    wire-ready gradient map



20
21
22
# File 'lib/plushie/canvas/shape/linear_gradient.rb', line 20

def to_wire
  {type: "linear", start: from, end: to, stops: stops}
end