Class: Tea::Bitmap

Inherits:
Object
  • Object
show all
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

Methods included from Primitive

#[], #[]=, #circle, #clear, #line, #rect

Methods included from ImageSaving

#save

Methods included from Grabbing

#grab, #grabbing_clip

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.



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_bufferObject



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

def blitting_buffer
  @buffer
end

#clipping_bufferObject



57
58
59
# File 'lib/tea/c_bitmap.rb', line 57

def clipping_buffer
  @buffer
end

#grabbing_bufferObject



62
63
64
# File 'lib/tea/c_bitmap.rb', line 62

def grabbing_buffer
  @buffer
end

#hObject

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_bufferObject



67
68
69
# File 'lib/tea/c_bitmap.rb', line 67

def image_saving_buffer
  @buffer
end

#optimize_for_screenObject

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_bufferObject



72
73
74
# File 'lib/tea/c_bitmap.rb', line 72

def primitive_buffer
  @buffer
end

#wObject

Get the width of the Bitmap in pixels.



35
36
37
# File 'lib/tea/c_bitmap.rb', line 35

def w
  @buffer.w
end