Class: Plushie::Canvas::Shape::Scale

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

Overview

Scales the canvas coordinate system.

Use x/y for independent axis scaling, or factor for uniform scaling.

Examples:

Independent

Scale.new(x: 2.0, y: 0.5)

Uniform

Scale.new(factor: 2.0)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x: nil, y: nil, factor: nil) ⇒ Scale

Returns a new instance of Scale.



47
48
49
# File 'lib/plushie/canvas/shape/transform.rb', line 47

def initialize(x: nil, y: nil, factor: nil)
  super
end

Instance Attribute Details

#factorObject (readonly)

Returns the value of attribute factor

Returns:

  • (Object)

    the current value of factor



46
47
48
# File 'lib/plushie/canvas/shape/transform.rb', line 46

def factor
  @factor
end

#xObject (readonly)

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



46
47
48
# File 'lib/plushie/canvas/shape/transform.rb', line 46

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



46
47
48
# File 'lib/plushie/canvas/shape/transform.rb', line 46

def y
  @y
end

Instance Method Details

#to_wireHash

Returns wire-ready transform map.

Returns:

  • (Hash)

    wire-ready transform map



52
53
54
55
56
57
58
# File 'lib/plushie/canvas/shape/transform.rb', line 52

def to_wire
  h = {type: "scale"}
  h[:x] = x if x
  h[:y] = y if y
  h[:factor] = factor if factor
  h
end