Class: Plushie::Canvas::Shape::HitRect

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

Overview

Explicit hit test rectangle override for interactive canvas shapes.

Examples:

HitRect.new(x: 0, y: 0, w: 100, h: 50)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:, w:, h:) ⇒ HitRect

Returns a new instance of HitRect.



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

def initialize(x:, y:, w:, h:)
  super
end

Instance Attribute Details

#hObject (readonly)

Returns the value of attribute h

Returns:

  • (Object)

    the current value of h



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

def h
  @h
end

#wObject (readonly)

Returns the value of attribute w

Returns:

  • (Object)

    the current value of w



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

def w
  @w
end

#xObject (readonly)

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



10
11
12
# File 'lib/plushie/canvas/shape/hit_rect.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/hit_rect.rb', line 10

def y
  @y
end

Instance Method Details

#[](key) ⇒ Object

Backward-compatible hash-style access.



16
# File 'lib/plushie/canvas/shape/hit_rect.rb', line 16

def [](key) = to_wire[key]

#to_wireHash

Returns wire-ready hit rect map.

Returns:

  • (Hash)

    wire-ready hit rect map



19
20
21
# File 'lib/plushie/canvas/shape/hit_rect.rb', line 19

def to_wire
  {x: x, y: y, w: w, h: h}
end