class CyberarmEngine::Paint
Attributes
bottom_left[RW]
bottom_right[RW]
top_left[RW]
top_right[RW]
Public Class Methods
new(background)
click to toggle source
# File lib/cyberarm_engine/background.rb, line 125 def initialize(background) set(background) end
Public Instance Methods
set(background)
click to toggle source
# File lib/cyberarm_engine/background.rb, line 129 def set(background) @background = background if background.is_a?(Numeric) @top_left = background @top_right = background @bottom_left = background @bottom_right = background elsif background.is_a?(Gosu::Color) @top_left = background @top_right = background @bottom_left = background @bottom_right = background elsif background.is_a?(Array) if background.size == 1 set(background.first) elsif background.size == 2 @top_left = background.first @top_right = background.last @bottom_left = background.first @bottom_right = background.last elsif background.size == 4 @top_left = background[0] @top_right = background[1] @bottom_left = background[2] @bottom_right = background[3] else raise ArgumentError, "background array was empty or had wrong number of elements (expected 2 or 4 elements)" end elsif background.is_a?(Hash) @top_left = background[:top_left] @top_right = background[:top_right] @bottom_left = background[:bottom_left] @bottom_right = background[:bottom_right] elsif background.is_a?(Range) set([background.begin, background.begin, background.end, background.end]) else raise ArgumentError, "background '#{background}' of type '#{background.class}' was not able to be processed" end end