Class: Tea::Bitmap

Inherits:
Object
  • Object
show all
Includes:
Blitting, Clipping, PrimitiveDrawing
Defined in:
lib/tea/c_bitmap.rb

Overview

A Bitmap is a grid of pixels that holds graphics.

Constant Summary

Constants included from PrimitiveDrawing

PrimitiveDrawing::BLEND_MIXER, PrimitiveDrawing::REPLACE_MIXER

Instance Method Summary collapse

Methods included from PrimitiveDrawing

#circle, #clear, #line, #point, #rect

Methods included from Clipping

#clip

Methods included from Blitting

#blit

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.



23
24
25
26
27
28
29
30
# File 'lib/tea/c_bitmap.rb', line 23

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

#blittable_bufferObject



43
44
45
# File 'lib/tea/c_bitmap.rb', line 43

def blittable_buffer
  @buffer
end

#clipping_bufferObject



48
49
50
# File 'lib/tea/c_bitmap.rb', line 48

def clipping_buffer
  @buffer
end

#hObject

Get the height of the Bitmap in pixels.



38
39
40
# File 'lib/tea/c_bitmap.rb', line 38

def h
  @buffer.h
end

#primitive_bufferObject



53
54
55
# File 'lib/tea/c_bitmap.rb', line 53

def primitive_buffer
  @buffer
end

#wObject

Get the width of the Bitmap in pixels.



33
34
35
# File 'lib/tea/c_bitmap.rb', line 33

def w
  @buffer.w
end