Sha256: ba4380faf7743863f1ae3357c498fb5aa770ce21c6f68fc67cb0c1c0f1188f94
Contents?: true
Size: 785 Bytes
Versions: 3
Compression:
Stored size: 785 Bytes
Contents
module Joybox module Common class Color < Array def self.defaults { red: 1, green: 1, green: 1 } end def initialize(red, green, blue) self.push(red, green, blue) end def self.create(options = {}) options = options.nil? ? defaults : defaults.merge!(options) self.new(options[:red], options[:green], options[:blue]) end def self.from_rgb(red, green, blue) self.new(red, green, blue) end def self.from_hex(hex) split_hex = [hex.delete(' ').delete('#')].pack('H*').unpack('C*') red = split_hex[0] green = split_hex[1] blue = split_hex[2] self.new(red, green, blue) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
joybox-0.0.5 | lib/joybox/cocos2d/common/color.rb |
joybox-0.0.4 | lib/joybox/cocos2d/common/color.rb |
joybox-0.0.3 | lib/joybox/cocos2d/common/color.rb |