Class: Bitmap

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

Overview

The bitmap class. Bitmaps are expressions of so-called graphics. Sprites (Sprite) and other objects must be used to display bitmaps on the screen.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fontFont

Gets the font used to draw a string with the #draw_text method.


7
8
9
# File 'lib/bitmap.rb', line 7

def font
  @font
end

#heightObject (readonly)

Gets the bitmap height.


13
14
15
# File 'lib/bitmap.rb', line 13

def height
  @height
end

#rectRect (readonly)

Gets the bitmap rectangle.


17
18
19
# File 'lib/bitmap.rb', line 17

def rect
  @rect
end

#widthObject (readonly)

Gets the bitmap width.


10
11
12
# File 'lib/bitmap.rb', line 10

def width
  @width
end

Instance Method Details

#blt(x, y, src_bitmap, src_rect, opacity = 255) ⇒ Object

Performs a block transfer from the src_bitmap box src_rect to the specified bitmap coordinates (x, y). Opacity can be set from 0 to 255.


56
57
58
# File 'lib/bitmap.rb', line 56

def blt(x, y, src_bitmap, src_rect, opacity = 255)
  raise "not implemented"
end

#clearObject

Clears the entire bitmap.


79
80
81
# File 'lib/bitmap.rb', line 79

def clear
  raise "not implemented"
end

#disposeObject

Frees the bitmap. If the bitmap has already been freed, does nothing.


37
38
39
40
41
# File 'lib/bitmap.rb', line 37

def dispose
  raise "not implemented"
  
  @disposed = true
end

#disposed?true, false


44
45
46
# File 'lib/bitmap.rb', line 44

def disposed?
  @disposed
end

#draw_text(x, y, width, height, str[, align]) ⇒ Object #draw_text(rect, str[, align]) ⇒ Object

Draws a string str in the bitmap box (x, y, width, height) or rect (Rect).

If the text length exceeds the box's width, the text width will automatically be reduced by up to 60 percent.

Horizontal text is left-aligned by default; set align to 1 to center the text and to 2 to right-align it. Vertical text is always centered.

As this process is time-consuming, redrawing the text with every frame is not recommended.


109
110
111
# File 'lib/bitmap.rb', line 109

def draw_text(*args)
  raise "not implemented"
end

#fill_rect(x, y, width, height, color) ⇒ Object #fill_rect(rect, color) ⇒ Object

Fills the bitmap box (x, y, width, height) or rect (Rect) with color (Color).


74
75
76
# File 'lib/bitmap.rb', line 74

def fill_rect(*args)
  raise "not implemented"
end

#get_pixel(x, y) ⇒ Object

Gets the Color at the specified pixel (x, y).


84
85
86
# File 'lib/bitmap.rb', line 84

def get_pixel(x, y)
  raise "not implemented"
end

#hue_change(hue) ⇒ Object

Changes the bitmap's hue within 360 degrees of displacement. This process is time-consuming. Furthermore, due to conversion errors, repeated hue changes may result in color loss.


95
96
97
# File 'lib/bitmap.rb', line 95

def hue_change(hue)
  raise "not implemented"
end

#initialize(filename) ⇒ Bitmap #initialize(width, height) ⇒ Bitmap

A new instance of Bitmap.

Overloads:

  • #initialize(filename) ⇒ Bitmap

    Loads the graphic file specified in filename and creates a bitmap object. Also automatically searches files included in RGSS-RTP and encrypted archives. File extensions may be omitted.

  • #initialize(width, height) ⇒ Bitmap

    Creates a bitmap object with the specified size.


27
28
29
30
31
32
33
34
# File 'lib/bitmap.rb', line 27

def intialize(*args)
  if args.size == 1
    load_file args[0]
  elsif args.size == 2
    @width = args[0]
    @height = args[1]
  end
end

#set_pixel(x, y, color) ⇒ Object

Sets the specified pixel (x, y) to the specified Color.


89
90
91
# File 'lib/bitmap.rb', line 89

def set_pixel(x, y, color)
  raise "not implemented"
end

#stretch_blt(dest_rect, src_bitmap, src_rect, opacity = 255) ⇒ Object

Performs a block transfer from the src_bitmap box src_rect to the specified bitmap box dest_rect (Rect). opacity can be set from 0 to 255.


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

def stretch_blt(dest_rect, src_bitmap, src_rect, opacity = 255)
  raise "not implemented"
end

#text_size(str) ⇒ Rect


115
116
117
# File 'lib/bitmap.rb', line 115

def text_size(str)
   raise "not implemented"
end