Sha256: db113c96b0c02591b94f66ce2132fd76f1711c4982ce18b720083c3e79d57a44

Contents?: true

Size: 702 Bytes

Versions: 6

Compression:

Stored size: 702 Bytes

Contents

# -*- coding: utf-8 -*-


require 'rays/ext'
require 'rays/color_space'


module Rays


  class Bitmap

    include Enumerable

    def initialize (width, height, color_space = :RGBA)
      setup width, height, ColorSpace.get_color_space(color_space)
    end

    def each ()
      height.times do |y|
        width.times do |x|
          yield self[x, y], x, y
        end
      end
    end

    def bounds ()
      Bounds.new 0, 0, width, height
    end

    def to_a ()
      map {|o| o}
    end

    def []= (x, y, *args)
      args.flatten!
      case args[0]
      when Color
        set_at x, y, args[0]
      when Numeric
        set_at x, y, *args
      end
    end

  end# Bitmap


end# Rays

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rays-0.1.12 lib/rays/bitmap.rb
rays-0.1.11 lib/rays/bitmap.rb
rays-0.1.10 lib/rays/bitmap.rb
rays-0.1.9 lib/rays/bitmap.rb
rays-0.1.8 lib/rays/bitmap.rb
rays-0.1.7 lib/rays/bitmap.rb