#==============================================================================
# ** Color
#==============================================================================
class Color
#-------------------------------------------------------------------------
# * Color Between Memory
#-------------------------------------------------------------------------
@color_between = {}
#-------------------------------------------------------------------------
# * Name : Color Between
# Info : Gets Color Between Two colors given the percent
# Author : SephirothSpawn
# Call Info : Start Color, Finish Color, Percent
#-------------------------------------------------------------------------
def self.color_between(color_a, color_b, percent = 0.5)
# Gets Save Key
key = [color_a, color_b, percent]
if @color_between.has_key?(key)
return @color_between[key]
end
# Calculates New Color
r = Integer(color_a.red + (color_b.red - color_a.red) * percent)
g = Integer(color_a.green + (color_b.green - color_a.green) * percent)
b = Integer(color_a.blue + (color_b.blue - color_a.blue) * percent)
a = Integer(color_a.alpha + (color_b.alpha - color_a.alpha) * percent)
# Saves Color
@color_between[key] = Color.new(r, g, b, a)
# Returns Color
return @color_between[key]
end
end
#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
#-------------------------------------------------------------------------
# * Name : Draw Gradient Bar
# Info : Draws a Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nince Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_seph_gradient_bar(x, y, cur, max, width = 152, height = 8,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
self.fill_rect(x, y, width, height, b_color)
# Draws Bar
for i in 1...((cur / max.to_f) * (width - 1))
c = Color.color_between(s_color, e_color, (i / width.to_f))
self.fill_rect(x + i, y + 1, 1, height - 2, c)
end
end
#-------------------------------------------------------------------------
# * Name : Draw Reverse Gradient Bar
# Info : Draws a Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nine Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_seph_rev_gradient_bar(x, y, cur, max, width = 152, height = 8,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
self.fill_rect(x, y, width, height, b_color)
# Draws Bar
for i in 1...((cur / max.to_f) * (width - 1))
c = Color.color_between(s_color, e_color, (i / width.to_f))
self.fill_rect(x + width - 1 - i, y + 1, 1, height - 2, c)
end
end
#-------------------------------------------------------------------------
# * Name : Draw Slant Bar
# Info : Draws a slanted Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nine Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_slant_bar(x, y, cur, max, width = 152, height = 8,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
for i in 0..height
self.fill_rect(x + i, y + height - i, width - height, 1, b_color)
end
# Draws Bar
for i in 1...((cur / max.to_f) * (width - height - 1))
for j in 1...(height)
c = Color.color_between(s_color, e_color, (i / width.to_f))
self.fill_rect(x + i + j, y + height - j, 1, 1, c)
end
end
end
#-------------------------------------------------------------------------
# * Name : Draw Reverse Slant Bar
# Info : Draws a slanted Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nine Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_rev_slant_bar(x, y, cur, max, width = 152, height = 8,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
for i in 0..height
self.fill_rect(x + i, y + height - i, width - height, 1, b_color)
end
# Draws Bar
for i in 1...((cur / max.to_f) * (width - height - 1))
for j in 1...(height)
c = Color.color_between(s_color, e_color, (i / width.to_f))
self.fill_rect(x + width - 1 - i - j, y + j, 1, 1, c)
end
end
end
#-------------------------------------------------------------------------
# Name : Draw Circular Gradient Bar
# Info : Draws a Circular Gradient Bar
# Author : Trickster
# Call Info : Six to Nine Arguments
# Integer X, Y, Width, Height, Current, and Max
# Color start, finish, back all default to Black
# X and Y Define Position
# Width and Height defines dimensions
# Current Defines How Much of the Bar to Draw
# Max Defines the Maximum Value
# start, finish, back is the starting, ending, and back color
#-------------------------------------------------------------------------
def draw_trick_circular_bar(x, y, width, height, current, max,
start = Color.red, finish = Color.yellow, back = Color.black)
# Draw Background
radius = height / 2
# Draw Rectangle Center
fill_rect(x + radius, y, width - height, height, back)
# Draws Ends
(radius + 1).times do |x1|
# Get Y
y1 = Math.sqrt(radius ** 2 - (radius - x1) ** 2).round
# Draw Line of Back Color at Left Edge
fill_rect(x + x1, y - y1 + radius, 1, 2 * y1, back)
# Draw Line of Back Color at Right Edge
fill_rect(x + width - x1, y - y1 + radius, 1, 2 * y1, back)
end
# Get Percentage
percentage = current / max.to_f
# Return if not a finite number
return if not percentage.finite?
# Decrease Width and Height increase x and y
x, y, width, height = x + 2, y + 2, width - 4, height - 4
# Get new Radius
radius = height / 2
# Get Bar Width
barwidth = width * percentage
# Draws Left End
(radius + 1).times do |x1|
# Stop if Past Width
break if x1 > barwidth
# Get Y
y1 = Math.sqrt(radius ** 2 - (radius - x1) ** 2).round
# Get Color
color = Color.color_between(start, finish, (x1 / width.to_f))
# Draw Line
fill_rect(x + x1, y - y1 + radius, 1, 2 * y1, color)
end
# Run From Radius upto Rectangles End
(width - height + 1).times do |t|
# Get X1
x1 = t + radius
# Break if Past Width
break if x1 > barwidth
# Get Color
color = Color.color_between(start, finish, (x1 / width.to_f))
# Draw Line
fill_rect(x + x1, y, 1, height, color)
end
# Draws Right End
radius.times do |t|
# Get X
x1 = width - radius + t
# Stop if Past Width
break if x1 > barwidth
# Get Y
y1 = Math.sqrt(radius ** 2 - t ** 2).round
# Get Color
color = Color.color_between(start, finish, (x1 / width.to_f))
# Draw Line
fill_rect(x + x1, y - y1 + radius, 1, 2 * y1, color)
end
end
#-------------------------------------------------------------------------
# Name : Draw Reverse Circular Gradient Bar
# Info : Draws a Circular Gradient Bar
# Author : Trickster / SephirothSpawn
# Call Info : Six to Nine Arguments
# Integer X, Y, Width, Height, Current, and Max
# Color start, finish, back all default to Black
# X and Y Define Position
# Width and Height defines dimensions
# Current Defines How Much of the Bar to Draw
# Max Defines the Maximum Value
# start, finish, back is the starting, ending, and back color
#-------------------------------------------------------------------------
def draw_trick_rev_circular_bar(x, y, width, height, current, max,
start = Color.red, finish = Color.yellow, back = Color.black)
# Draw Background
radius = height / 2
# Draw Rectangle Center
fill_rect(x + radius, y, width - height, height, back)
# Draws Ends
(radius + 1).times do |x1|
# Get Y
y1 = Math.sqrt(radius ** 2 - (radius - x1) ** 2).round
# Draw Line of Back Color at Left Edge
fill_rect(x + x1, y - y1 + radius, 1, 2 * y1, back)
# Draw Line of Back Color at Right Edge
fill_rect(x + width - x1, y - y1 + radius, 1, 2 * y1, back)
end
# Get Percentage
percentage = current / max.to_f
# Return if not a finite number
return if not percentage.finite?
# Decrease Width and Height increase x and y
x, y, width, height = x + 2, y + 2, width - 4, height - 4
# Get new Radius
radius = height / 2
# Get Bar Width
barwidth = width * percentage
# Draws Left End
(radius + 1).times do |x1|
# Stop if Past Width
break if x1 > barwidth
# Get Y
y1 = Math.sqrt(radius ** 2 - (radius - x1) ** 2).round
# Get Color
color = Color.color_between(start, finish, (x1 / width.to_f))
# Draw Line
fill_rect(x + width - x1, y - y1 + radius, 1, 2 * y1, color)
end
# Run From Radius upto Rectangles End
(width - height + 1).times do |t|
# Get X1
x1 = t + radius
# Break if Past Width
break if x1 > barwidth
# Get Color
color = Color.color_between(start, finish, (x1 / width.to_f))
# Draw Line
fill_rect(x + width - x1, y, 1, height, color)
end
# Draws Right End
radius.times do |t|
# Get X
x1 = width - radius + t
# Stop if Past Width
break if x1 > barwidth
# Get Y
y1 = Math.sqrt(radius ** 2 - t ** 2).round
# Get Color
color = Color.color_between(start, finish, (x1 / width.to_f))
# Draw Line
fill_rect(x + width - x1, y - y1 + radius, 1, 2 * y1, color)
end
end
#-------------------------------------------------------------------------
# * Name : Draw Vertical Gradient Bar
# Info : Draws a Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nine Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_seph_v_gradient_bar(x, y, cur, max, width = 8, height = 152,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
self.fill_rect(x, y, width, height, b_color)
# Draws Bar
for i in 1...((cur / max.to_f) * (height - 1))
c = Color.color_between(s_color, e_color, (i / height.to_f))
self.fill_rect(x + 1, y + i, width - 2, 1, c)
end
end
#-------------------------------------------------------------------------
# * Name : Draw Vertical Reverse Gradient Bar
# Info : Draws a Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nine Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_seph_v_rev_gradient_bar(x, y, cur, max, width = 8, height = 152,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
self.fill_rect(x, y, width, height, b_color)
# Draws Bar
for i in 1...((cur / max.to_f) * (height - 1))
c = Color.color_between(s_color, e_color, (i / height.to_f))
self.fill_rect(x + 1, y + height - 1 - i, width - 2, 1, c)
end
end
#-------------------------------------------------------------------------
# * Name : Draw Vertical Slant Bar
# Info : Draws a slanted Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nice Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_v_slant_bar(x, y, cur, max, width = 8, height = 152,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
for i in 0..width
self.fill_rect(x + i, y + i, 1, height - width, b_color)
end
# Draws Bar
for i in 1...((cur / max.to_f) * (height - width - 1))
for j in 1...(width)
c = Color.color_between(s_color, e_color, (i / height.to_f))
self.fill_rect(x + j, y + i + j, 1, 1, c)
end
end
end
#-------------------------------------------------------------------------
# * Name : Draw Vertical Reverse Slant Bar
# Info : Draws a slanted Gradient Bar
# Author : SephirothSpawn
# Call Info : Four to Nine Arguments
# Integer x and y Defines Position
# Integer min and max Defines Dimensions of Bar
# Start Bar Color and End Color - Colors for Gradient Bar
# Background Bar Color
#-------------------------------------------------------------------------
def draw_v_rev_slant_bar(x, y, cur, max, width = 8, height = 152,
s_color = Color.red, e_color = Color.yellow, b_color = Color.black)
# Draw Border
for i in 0..width
self.fill_rect(x + i, y + i, 1, height - width, b_color)
end
# Draws Bar
for i in 1...( (cur / max.to_f) * (height - width - 1))
for j in 1...(width)
c = Color.color_between(s_color, e_color, (i / height.to_f))
self.fill_rect(x + width - j, y + height - i - j - 1, 1, 1, c)
end
end
end
#-------------------------------------------------------------------------
# Name : Draw Vertical Circular Gradient Bar
# Info : Draws a Circular Gradient Bar
# Author : Trickster / SephirothSpawn
# Call Info : Six to Nine Arguments
# Integer X, Y, Width, Height, Current, and Max
# Color start, finish, back all default to Black
# X and Y Define Position
# Width and Height defines dimensions
# Current Defines How Much of the Bar to Draw
# Max Defines the Maximum Value
# start, finish, back is the starting, ending, and back color
#-------------------------------------------------------------------------
def draw_trick_v_circular_bar(x, y, width, height, current, max,
start = Color.red, finish = Color.yellow, back = Color.black)
# Draw Background
radius = width / 2
# Draw Rectangle Center
fill_rect(x, y + radius, width, height - width, back)
# Draws Ends
(radius + 1).times do |y1|
# Get X
x1 = Math.sqrt(radius ** 2 - (radius - y1) ** 2).round
# Draw Line of Back Color at Left Edge
fill_rect(x - x1 + radius, y + y1, 2 * x1, 1, back)
# Draw Line of Back Color at Right Edge
fill_rect(x - x1 + radius, y + height - y1, 2 * x1, 1, back)
end
# Get Percentage
percentage = current / max.to_f
# Return if not a finite number
return if not percentage.finite?
# Decrease Width and Height increase x and y
x, y, width, height = x + 2, y + 2, width - 4, height - 4
# Get new Radius
radius = width / 2
# Get Bar Height
barheight = height * percentage
# Draws Top End
(radius + 1).times do |y1|
# Stop if Past Height
break if y1 > barheight
# Get T (Parameter)
t = radius - y1
# Get X
x1 = Math.sqrt(radius ** 2 - t ** 2).round
# Get Color
color = Color.color_between(start, finish, (y1 / height.to_f))
# Draw Line
fill_rect(x - x1 + radius, y + y1, 2 * x1, 1, color)
end
# Run From Radius upto Rectangles End
(height - width + 1).times do |t|
# Get Y1
y1 = t + radius
# Break if Past Width
break if y1 > barheight
# Get Color
color = Color.color_between(start, finish, (y1 / height.to_f))
# Draw Line
fill_rect(x, y + y1, width, 1, color)
end
# Draws Bottom End
radius.times do |t|
# Get Y
y1 = height - radius + t
# Get X
x1 = Math.sqrt(radius ** 2 - t ** 2).round
# Stop if Past Height
break if y1 > barheight
# Get Color
color = Color.color_between(start, finish, (y1 / height.to_f))
# Draw Line
fill_rect(x - x1 + radius, y + y1, 2 * x1, 1, color)
end
end
#-------------------------------------------------------------------------
# Name : Draw Vertical Reverse Circular Gradient Bar
# Info : Draws a Circular Gradient Bar
# Author : Trickster / SephirothSpawn
# Call Info : Six to Nine Arguments
# Integer X, Y, Width, Height, Current, and Max
# Color start, finish, back all default to Black
# X and Y Define Position
# Width and Height defines dimensions
# Current Defines How Much of the Bar to Draw
# Max Defines the Maximum Value
# start, finish, back is the starting, ending, and back color
#-------------------------------------------------------------------------
def draw_trick_v_rev_circular_bar(x, y, width, height, current, max,
start = Color.red, finish = Color.yellow, back = Color.black)
# Draw Background
radius = width / 2
# Draw Rectangle Center
fill_rect(x, y + radius, width, height - width, back)
# Draws Ends
(radius + 1).times do |y1|
# Get X
x1 = Math.sqrt(radius ** 2 - (radius - y1) ** 2).round
# Draw Line of Back Color at Left Edge
fill_rect(x - x1 + radius, y + y1, 2 * x1, 1, back)
# Draw Line of Back Color at Right Edge
fill_rect(x - x1 + radius, y + height - y1, 2 * x1, 1, back)
end
# Get Percentage
percentage = current / max.to_f
# Return if not a finite number
return if not percentage.finite?
# Decrease Width and Height increase x and y
x, y, width, height = x + 2, y + 2, width - 4, height - 4
# Get new Radius
radius = width / 2
# Get Bar Height
barheight = height * percentage
# Draws Bottom End
(radius + 1).times do |y1|
# Stop if Past Height
break if y1 > barheight
# Get X
x1 = Math.sqrt(radius ** 2 - (radius - y1) ** 2).round
# Get Color
color = Color.color_between(start, finish, (y1 / height.to_f))
# Draw Line
fill_rect(x - x1 + radius, y + height - y1, 2 * x1, 1, color)
end
# Run From Radius upto Rectangles End
(height - width + 1).times do |t|
# Get Y1
y1 = t + radius
# Break if Past Width
break if y1 > barheight
# Get Color
color = Color.color_between(start, finish, (y1 / height.to_f))
# Draw Line
fill_rect(x, y + height - y1, width, 1, color)
end
# Draws Bottom End
radius.times do |t|
# Get Y
y1 = radius - t
# Stop if Past Height
break if height - y1 > barheight
# Get X
x1 = Math.sqrt(radius ** 2 - t ** 2).round
# Get Color
color = Color.color_between(start, finish, ((height - y1) / height.to_f))
# Draw Line
fill_rect(x - x1 + radius, y + y1, 2 * x1, 1, color)
end
end
end