加入这个试试,没试过不知道对不对(*x
class Bitmap def invert self.process_color do |color_arr| color_arr.size.times do |i| color_arr[i].red = 255-color_arr[i].red color_arr[i].green = 255-color_arr[i].green color_arr[i].blue = 255-color_arr[i].blue end end self end end
class Bitmap
def invert
self.process_color do |color_arr|
color_arr.size.times do |i|
color_arr[i].red = 255-color_arr[i].red
color_arr[i].green = 255-color_arr[i].green
color_arr[i].blue = 255-color_arr[i].blue
end
end
self
end
end
|