Class: Plushie::Canvas::Shape::Translate

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

Overview

Translates the canvas coordinate origin.

Examples:

Translate.new(x: 100, y: 50)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:) ⇒ Translate

Returns a new instance of Translate.



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

def initialize(x:, y:)
  super
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



10
11
12
# File 'lib/plushie/canvas/shape/transform.rb', line 10

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



10
11
12
# File 'lib/plushie/canvas/shape/transform.rb', line 10

def y
  @y
end

Instance Method Details

#to_wireHash

Returns wire-ready transform map.

Returns:

  • (Hash)

    wire-ready transform map



16
17
18
# File 'lib/plushie/canvas/shape/transform.rb', line 16

def to_wire
  {type: "translate", x: x, y: y}
end