class MagicCloud::Shape

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.

Attributes

height[R]
rect[R]
sprite[R]
width[R]
x[R]
y[R]

Public Class Methods

new() click to toggle source
# File lib/magic_cloud/shape.rb, line 9
def initialize
  @x = 0
  @y = 0
  @sprite = nil
  @rect = nil
  @width = 0
  @height = 0
end

Public Instance Methods

bottom() click to toggle source
# File lib/magic_cloud/shape.rb, line 49
def bottom
  y + height
end
draw(_canvas) click to toggle source
# File lib/magic_cloud/shape.rb, line 53
def draw(_canvas)
  fail NotImplementedError
end
left() click to toggle source
# File lib/magic_cloud/shape.rb, line 37
def left
  x
end
right() click to toggle source
# File lib/magic_cloud/shape.rb, line 41
def right
  x + width
end
sprite=(sprite) click to toggle source
# File lib/magic_cloud/shape.rb, line 20
def sprite=(sprite)
  @sprite = sprite
  @width = sprite.width
  @height = sprite.height
  @rect = Rect.new(left, top, right, bottom)
end
top() click to toggle source
# File lib/magic_cloud/shape.rb, line 45
def top
  y
end
x=(newx) click to toggle source
# File lib/magic_cloud/shape.rb, line 27
def x=(newx)
  @x = newx
  @rect.move_to(@x, @y)
end
y=(newy) click to toggle source
# File lib/magic_cloud/shape.rb, line 32
def y=(newy)
  @y = newy
  @rect.move_to(@x, @y)
end