Class: Tea::Bitmap
- Inherits:
-
Object
- Object
- Tea::Bitmap
- Includes:
- Blitting, Clipping, Grabbing, ImageSaving, Primitive
- Defined in:
- lib/tea/c_bitmap.rb
Overview
A Bitmap is a grid of pixels that holds graphics.
Constant Summary
Constants included from Primitive
Primitive::BLEND_MIXER, Primitive::REPLACE_MIXER
Instance Method Summary collapse
- #blitting_buffer ⇒ Object
- #clipping_buffer ⇒ Object
- #grabbing_buffer ⇒ Object
-
#h ⇒ Object
Get the height of the Bitmap in pixels.
- #image_saving_buffer ⇒ Object
-
#initialize(*args) ⇒ Bitmap
constructor
Create a new Bitmap.
-
#optimize_for_screen ⇒ Object
Convert the Bitmap’s internal format to that of the screen to speed up drawing.
- #primitive_buffer ⇒ Object
-
#w ⇒ Object
Get the width of the Bitmap in pixels.
Methods included from Primitive
#[], #[]=, #circle, #clear, #line, #rect
Methods included from ImageSaving
Methods included from Grabbing
Methods included from Clipping
Methods included from Blitting
Constructor Details
#initialize(*args) ⇒ Bitmap
Create a new Bitmap. This can be done in 2 ways:
- (image_path)
-
loads from an image
- (width, height, color)
-
creates with the given size and color
May raise ArgumentError if the arguments passed in don’t match one of the above, or Tea::Error if the Bitmap creation fails.
25 26 27 28 29 30 31 32 |
# File 'lib/tea/c_bitmap.rb', line 25 def initialize(*args) case args.length when 1 then from_image(*args) when 3 then fresh(*args) else raise ArgumentError, "wrong number of arguments (#{args.length} for 1 or 3)", caller end end |
Instance Method Details
#blitting_buffer ⇒ Object
52 53 54 |
# File 'lib/tea/c_bitmap.rb', line 52 def blitting_buffer @buffer end |
#clipping_buffer ⇒ Object
57 58 59 |
# File 'lib/tea/c_bitmap.rb', line 57 def clipping_buffer @buffer end |
#grabbing_buffer ⇒ Object
62 63 64 |
# File 'lib/tea/c_bitmap.rb', line 62 def grabbing_buffer @buffer end |
#h ⇒ Object
Get the height of the Bitmap in pixels.
40 41 42 |
# File 'lib/tea/c_bitmap.rb', line 40 def h @buffer.h end |
#image_saving_buffer ⇒ Object
67 68 69 |
# File 'lib/tea/c_bitmap.rb', line 67 def image_saving_buffer @buffer end |
#optimize_for_screen ⇒ Object
Convert the Bitmap’s internal format to that of the screen to speed up drawing. Intended for internal use, but calling it manually won’t bring any harm.
47 48 49 |
# File 'lib/tea/c_bitmap.rb', line 47 def optimize_for_screen @buffer = @buffer.display_format_alpha end |
#primitive_buffer ⇒ Object
72 73 74 |
# File 'lib/tea/c_bitmap.rb', line 72 def primitive_buffer @buffer end |
#w ⇒ Object
Get the width of the Bitmap in pixels.
35 36 37 |
# File 'lib/tea/c_bitmap.rb', line 35 def w @buffer.w end |