Class: Rays::Bitmap
Instance Method Summary collapse
- #[]=(x, y, *args) ⇒ Object
- #bounds ⇒ Object
- #each ⇒ Object
-
#initialize(width, height, color_space = :RGBA) ⇒ Bitmap
constructor
A new instance of Bitmap.
- #to_a ⇒ Object
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 |
#bounds ⇒ Object
27 28 29 |
# File 'lib/rays/bitmap.rb', line 27 def bounds () Bounds.new 0, 0, width, height end |
#each ⇒ Object
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_a ⇒ Object
31 32 33 |
# File 'lib/rays/bitmap.rb', line 31 def to_a () map {|o| o} end |