Sha256: 9e11af43b84bdf6ad61536269940e606c97221816565708fbda3611e4120350a

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

# encoding: UTF-8

module FreeImage
  class RGBTriple < FFI::Struct
    if FFI::Platform::BYTE_ORDER == FFI::Platform::LITTLE_ENDIAN
      layout :blue,     :byte, 0,
             :green,    :byte, 1,
             :red,      :byte, 2
    else
      layout :red,      :byte, 0,
             :green,    :byte, 1,
             :blue,     :byte, 2
    end

    # Creates a new RGBTriple color
    #
    # == Parameters
    # red:: Value for red, should be between 0 and 255
    # green:: Value for green, should be between 0 and 255
    # blue:: Value for blue, should be between 0 and 255
    #
    def self.create(red, green, blue)
      result = self.new
      result[:red] = red
      result[:green] = green
      result[:blue] = blue
      result
    end

    def eql?(other)
      other.instance_of?(RGBQuad) and
      self[:red]   == other[:red] and
      self[:green] == other[:green] and
      self[:blue]  == other[:blue]
    end
    alias :== :eql?

    def to_s
      "RGBQuad - Red: #{self[:red]}, Green: #{self[:green]}, Blue: #{self[:blue]}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
free-image-0.8.1 lib/free-image/types/rgb_triple.rb
free-image-0.8.0 lib/free-image/types/rgb_triple.rb
free-image-0.7.1 lib/free-image/types/rgb_triple.rb
free-image-0.7.0 lib/free-image/types/rgb_triple.rb
free-image-0.6.2 lib/free-image/types/rgb_triple.rb
free-image-0.6.1 lib/free-image/types/rgb_triple.rb
free-image-0.6.0 lib/free-image/types/rgb_triple.rb
free-image-0.5.0 lib/free-image/types/rgb_triple.rb