Shouldn't each be in the Array class, or at least each_with_index? It behaves differently between different Enumerable classes (in Hash, each must yield two values, and each_with_index doesn't exist)
EDIT: I feel like sharing my personal modifications to Bitmap.draw_slant_bar. This gives the bar a pleasing gradient:
#--------------------------------------------------------------------------
# * Draw Slant Bar (by SephirothSpawn)
#--------------------------------------------------------------------------
def draw_slant_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255),
end_color = Color.new(255, 255, 60, 255))
# Draw Border
for i in 0..height
self.fill_rect(x+i, y+height-i, width+1, 1, Color.new(50, 50, 50, 255))
end
# Draw Background
for i in 1...(height - 1)
r = 100 * (height - i) / height
g = 100 * (height - i) / height
b = 100 * (height - i) / height
a = 255
self.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
# Draws Bar
for i in 1...( (min.to_f / max.to_f) * width - 1).to_i
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
for j in 1..(height - 1)
r = r * (height - j) / height + (3 * r / 4) * j / height
g = g * (height - j) / height + (3 * g / 4) * j / height
b = b * (height - j) / height + (3 * b / 4) * j / height
self.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
Expand to see the code.