def draw_bar(value, max_value, x, y, width)
percent = value.to_f / max_value.to_f
w = (width * percent).to_i
if percent < 0.25 # in the red
bitmap = RPG::Cache.picture("red_left")
self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
color = Color.new(225, 81, 78, 255)
self.contents.fill_rect(x + bitmap.width, y, w, 1, color)
color = Color.new(222, 59, 55, 255)
self.contents.fill_rect(x + bitmap.width, y + 1, w, 1, color)
color = Color.new(219, 43, 39, 255)
self.contents.fill_rect(x + bitmap.width, y + 2, w, 4, color)
color = Color.new(200, 39, 36, 255)
self.contents.fill_rect(x + bitmap.width, y + 6, w, 1, color)
color = Color.new(159, 31, 28, 255)
self.contents.fill_rect(x + bitmap.width, y + 7, w, 1, color)
bitmap = RPG::Cache.picture("red_right")
self.contents.blt(x + w, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
elsif percent < 0.5 # yellow
bitmap = RPG::Cache.picture("yellow_left")
self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
color = Color.new(229, 207, 87, 255)
self.contents.fill_rect(x + bitmap.width, y, w, 1, color)
color = Color.new(225, 201, 65, 255)
self.contents.fill_rect(x + bitmap.width, y + 1, w, 1, color)
color = Color.new(223, 197, 50, 255)
self.contents.fill_rect(x + bitmap.width, y + 2, w, 4, color)
color = Color.new(204, 180, 46, 255)
self.contents.fill_rect(x + bitmap.width, y + 6, w, 1, color)
color = Color.new(162, 143, 36, 255)
self.contents.fill_rect(x + bitmap.width, y + 7, w, 1, color)
bitmap = RPG::Cache.picture("yellow_right")
self.contents.blt(x + w, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
else # green
bitmap = RPG::Cache.picture("green_left")
self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
color = Color.new(71, 202, 140, 255)
self.contents.fill_rect(x + bitmap.width, y, w, 1, color)
color = Color.new(47, 195, 85, 255)
self.contents.fill_rect(x + bitmap.width, y + 1, w, 1, color)
color = Color.new(30, 190, 71, 255)
self.contents.fill_rect(x + bitmap.width, y + 2, w, 4, color)
color = Color.new(27, 174, 65, 255)
self.contents.fill_rect(x + bitmap.width, y + 6, w, 1, color)
color = Color.new(22, 138, 52, 255)
self.contents.fill_rect(x + bitmap.width, y + 7, w, 1, color)
bitmap = RPG::Cache.picture("green_right")
self.contents.blt(x + w + bitmap.width, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
end
end