Class: MagicCloud::Shape

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_cloud/shape.rb

Overview

Basic “abstract shape” class, with all primitive functionality necessary for use it in Spriter and Layouter.

Word for wordcloud is inherited from it, and its potentially possible to inherit other types of shapes and layout them also.

Direct Known Subclasses

Word

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeShape

Returns a new instance of Shape.



10
11
12
13
14
15
16
17
# File 'lib/magic_cloud/shape.rb', line 10

def initialize
  @x = 0
  @y = 0
  @sprite = nil
  @rect = nil
  @width = 0
  @height = 0
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



19
20
21
# File 'lib/magic_cloud/shape.rb', line 19

def height
  @height
end

#rectObject (readonly)

Returns the value of attribute rect.



19
20
21
# File 'lib/magic_cloud/shape.rb', line 19

def rect
  @rect
end

#spriteObject

Returns the value of attribute sprite.



19
20
21
# File 'lib/magic_cloud/shape.rb', line 19

def sprite
  @sprite
end

#widthObject (readonly)

Returns the value of attribute width.



19
20
21
# File 'lib/magic_cloud/shape.rb', line 19

def width
  @width
end

#xObject

Returns the value of attribute x.



19
20
21
# File 'lib/magic_cloud/shape.rb', line 19

def x
  @x
end

#yObject

Returns the value of attribute y.



19
20
21
# File 'lib/magic_cloud/shape.rb', line 19

def y
  @y
end

Instance Method Details

#bottomObject



50
51
52
# File 'lib/magic_cloud/shape.rb', line 50

def bottom
  y + height
end

#draw(_canvas) ⇒ Object



54
55
56
# File 'lib/magic_cloud/shape.rb', line 54

def draw(_canvas)
  fail NotImplementedError
end

#leftObject



38
39
40
# File 'lib/magic_cloud/shape.rb', line 38

def left
  x
end

#rightObject



42
43
44
# File 'lib/magic_cloud/shape.rb', line 42

def right
  x + width
end

#topObject



46
47
48
# File 'lib/magic_cloud/shape.rb', line 46

def top
  y
end