### Home Classes Methods

### In Files

- lib/rubygame/color/models/rgb.rb

### Parent

Object

### Methods

- ::new
- ::new_from_rgba
- ::new_from_sdl_rgba
- #inspect
- #to_rgba_ary
- #to_s
- #to_sdl_rgba_ary

### Included Modules

- Rubygame::Color::ColorBase

### Files

- CREDITS
- LICENSE
- NEWS
- README
- ROADMAP
- custom_sdl_load_paths.rdoc
- getting_started.rdoc
- keyboard_symbols.rdoc
- macosx_install.rdoc
- managing_framerate.rdoc
- surface_palettes.rdoc
- windows_install.rdoc

### Class/Module Index

Quicksearch

- Rubygame
- Rubygame::ActiveEvent
- Rubygame::Clock
- Rubygame::Color
- Rubygame::Color::ColorBase
- Rubygame::Color::ColorHSL
- Rubygame::Color::ColorHSV
- Rubygame::Color::ColorRGB
- Rubygame::Color::Palette
- Rubygame::Event
- Rubygame::EventActions
- Rubygame::EventActions::BlockAction
- Rubygame::EventActions::MethodAction
- Rubygame::EventActions::MultiAction
- Rubygame::EventHandler
- Rubygame::EventHandler::HasEventHandler
- Rubygame::EventHook
- Rubygame::EventQueue
- Rubygame::EventTriggers
- Rubygame::EventTriggers::AndTrigger
- Rubygame::EventTriggers::AttrTrigger
- Rubygame::EventTriggers::BlockTrigger
- Rubygame::EventTriggers::InstanceOfTrigger
- Rubygame::EventTriggers::KeyPressTrigger
- Rubygame::EventTriggers::KeyReleaseTrigger
- Rubygame::EventTriggers::KindOfTrigger
- Rubygame::EventTriggers::MouseMoveTrigger
- Rubygame::EventTriggers::MousePressTrigger
- Rubygame::EventTriggers::MouseReleaseTrigger
- Rubygame::EventTriggers::OrTrigger
- Rubygame::EventTriggers::TickTrigger
- Rubygame::EventTriggers::YesTrigger
- Rubygame::Events
- Rubygame::Events::ClockTicked
- Rubygame::Events::InputFocusGained
- Rubygame::Events::InputFocusLost
- Rubygame::Events::JoystickAxisMoved
- Rubygame::Events::JoystickBallMoved
- Rubygame::Events::JoystickButtonEvent
- Rubygame::Events::JoystickButtonPressed
- Rubygame::Events::JoystickButtonReleased
- Rubygame::Events::JoystickHatMoved
- Rubygame::Events::KeyPressed
- Rubygame::Events::KeyReleased
- Rubygame::Events::KeyboardEvent
- Rubygame::Events::MouseButtonEvent
- Rubygame::Events::MouseFocusGained
- Rubygame::Events::MouseFocusLost
- Rubygame::Events::MouseMoved
- Rubygame::Events::MousePressed
- Rubygame::Events::MouseReleased
- Rubygame::Events::QuitRequested
- Rubygame::Events::WindowExposed
- Rubygame::Events::WindowMinimized
- Rubygame::Events::WindowResized
- Rubygame::Events::WindowUnminimized
- Rubygame::ExposeEvent
- Rubygame::Ftor
- Rubygame::GL
- Rubygame::Hotspot
- Rubygame::JoyAxisEvent
- Rubygame::JoyBallEvent
- Rubygame::JoyDownEvent
- Rubygame::JoyHatEvent
- Rubygame::JoyUpEvent
- Rubygame::Joystick
- Rubygame::Key
- Rubygame::KeyDownEvent
- Rubygame::KeyUpEvent
- Rubygame::MailQueue
- Rubygame::MediaBag
- Rubygame::Mixer
- Rubygame::Mixer::Music
- Rubygame::Mixer::Sample
- Rubygame::Mouse
- Rubygame::MouseDownEvent
- Rubygame::MouseMotionEvent
- Rubygame::MouseUpEvent
- Rubygame::Music
- Rubygame::NamedResource
- Rubygame::NamedResource::NamedResourceClassMethods
- Rubygame::QuitEvent
- Rubygame::Rect
- Rubygame::ResizeEvent
- Rubygame::SDLError
- Rubygame::SFont
- Rubygame::Screen
- Rubygame::Sound
- Rubygame::Sprites
- Rubygame::Sprites::DepthSortGroup
- Rubygame::Sprites::Group
- Rubygame::Sprites::LimitGroup
- Rubygame::Sprites::Sprite
- Rubygame::Sprites::UpdateGroup
- Rubygame::Surface
- Rubygame::TTF

No matching classes.

# Rubygame::Color::ColorRGB

Represents color in the RGB (Red, Green, Blue) color space.

### Attributes

a[R]
b[R]
g[R]
r[R]

### Public Class Methods

new( [r,g,b,a] ) → ColorRGB click to toggle source
new( [r,g,b] ) → ColorRGB
new( color ) → ColorRGB

Create a new instance from an Array or an existing color (of any type). If the alpha (opacity) component is omitted from the array, full opacity will be used.

All color components range from 0.0 to 1.0.

    # File lib/rubygame/color/models/rgb.rb, line 42
    def initialize( color )
            if color.kind_of?(Array)
                    @r, @g, @b, @a = color.collect { |i| i.to_f }
                    @a = 1.0 unless @a
            elsif color.respond_to?(:to_rgba_ary)
                    @r, @g, @b, @a = color.to_rgba_ary
            end
    end

new_from_rgba( rgba ) click to toggle source

    # File lib/rubygame/color/models/rgb.rb, line 67
    def new_from_rgba( rgba )
            new( rgba )
    end

new_from_sdl_rgba( rgba ) click to toggle source

    # File lib/rubygame/color/models/rgb.rb, line 71
    def new_from_sdl_rgba( rgba )
            new_from_rgba( rgba.collect { |i| i / 255.0 } )
    end

### Public Instance Methods

inspect() click to toggle source
Alias for: to_s
to_rgba_ary() click to toggle source

    # File lib/rubygame/color/models/rgb.rb, line 57
    def to_rgba_ary
            return [@r, @g, @b, @a]
    end

to_s() click to toggle source

    # File lib/rubygame/color/models/rgb.rb, line 61
    def to_s
            "#<#{self.class} [#{@r}, #{@g}, #{@b}, #{@a}]>"
    end

Also aliased as: inspect
to_sdl_rgba_ary() click to toggle source

Converts the color to an RGBA array of integers ranging from 0 to 255, as SDL wants.

    # File lib/rubygame/color/models/rgb.rb, line 53
    def to_sdl_rgba_ary
            self.to_rgba_ary.collect { |i| (i * 255).to_i }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.