class Bitmap
def gradient_fill_rect(x, y, width, height, color1, color2,vertical = false,opacity = 255)
#gradient_fill_rect(x坐标,y坐标,矩形宽,矩形高,颜色1,颜色2,横(竖)填充,不透明度)
vertical == false ? step = width - x : step = height - y;color = color1;color.alpha = opacity
key_re = Math.sqrt(((color2.red - color1.red)/step)**2);key_gr = Math.sqrt(((color2.green - color1.green)/step)**2);key_bl = Math.sqrt(((color2.blue - color1.blue)/step)**2)
color2.red-color1.red>0 ? key_re=key_re : key_re= -key_re;color2.green-color1.green>0 ? key_gr=key_gr : key_gr= -key_gr;color2.blue-color1.blue>0 ? key_bl=key_bl : key_bl= -key_bl
if vertical == true
for i in y..(y+height)
self.fill_rect(x, y, width, 1, color)
y=y+1;color.red =color.red + key_re;color.green =color.green + key_gr;color.blue =color.blue + key_bl
end
else
for i in x..(x+width)
self.fill_rect(x, y, 1, height, color)
x=x+1;color.red =color.red + key_re;color.green =color.green + key_gr;color.blue =color.blue + key_bl
end
end
end
alias :bsucat_gradient_fill_rect :gradient_fill_rect
def gradient_fill_rect(x, y, width, height=false, color1 = 255, color2=nil,vertical = false,opacity = 255)
if x.instance_of?(Rect)
bsucat_gradient_fill_rect(x.x, x.y, x.width, x.height, y, width,height,color1)
else
bsucat_gradient_fill_rect(x, y, width, height, color1, color2,vertical = false,opacity = 255)
end
end
end
class Bitmap
def gradient_fill_rect(x, y, width, height, color1, color2,vertical = false,opacity = 255)
#gradient_fill_rect(x坐标,y坐标,矩形宽,矩形高,颜色1,颜色2,横(竖)填充,不透明度)
vertical == false ? step = width - x : step = height - y;color = color1;color.alpha = opacity
key_re = Math.sqrt(((color2.red - color1.red)/step)**2);key_gr = Math.sqrt(((color2.green - color1.green)/step)**2);key_bl = Math.sqrt(((color2.blue - color1.blue)/step)**2)
color2.red-color1.red>0 ? key_re=key_re : key_re= -key_re;color2.green-color1.green>0 ? key_gr=key_gr : key_gr= -key_gr;color2.blue-color1.blue>0 ? key_bl=key_bl : key_bl= -key_bl
if vertical == true
for i in y..(y+height)
self.fill_rect(x, y, width, 1, color)
y=y+1;color.red =color.red + key_re;color.green =color.green + key_gr;color.blue =color.blue + key_bl
end
else
for i in x..(x+width)
self.fill_rect(x, y, 1, height, color)
x=x+1;color.red =color.red + key_re;color.green =color.green + key_gr;color.blue =color.blue + key_bl
end
end
end
alias :bsucat_gradient_fill_rect :gradient_fill_rect
def gradient_fill_rect(x, y, width, height=false, color1 = 255, color2=nil,vertical = false,opacity = 255)
if x.instance_of?(Rect)
bsucat_gradient_fill_rect(x.x, x.y, x.width, x.height, y, width,height,color1)
else
bsucat_gradient_fill_rect(x, y, width, height, color1, color2,vertical = false,opacity = 255)
end
end
end