Class: Rays::Bitmap

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rays/bitmap.rb

Instance Method Summary collapse

Constructor Details

#initialize(width, height, color_space = :RGBA) ⇒ Bitmap



15
16
17
# File 'lib/rays/bitmap.rb', line 15

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

Instance Method Details

#[]=(x, y, *args) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/rays/bitmap.rb', line 35

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

#boundsObject



27
28
29
# File 'lib/rays/bitmap.rb', line 27

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

#eachObject



19
20
21
22
23
24
25
# File 'lib/rays/bitmap.rb', line 19

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

#to_aObject



31
32
33
# File 'lib/rays/bitmap.rb', line 31

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