Files
LonaRPG-Online-Games/ModScripts/Unused/3_GimpTxt.rb.DIS
T
2026-10-29 21:59:06 +04:00

25 lines
861 B
Plaintext

#Made by Teravisor
#Allows 2_LonaBitmapChanger.rb to read palettes exported from GIMP Palette->right click->"Export as"->"Text file..."
module BitmapChanger
class << self
alias_method :read_palette_gimptxt, :read_palette #first name must be unique among all mods
def read_palette(file_path, file_extension)
return read_gimptxt(file_path) if file_extension == ".txt"
return read_palette_gimptxt(file_path, file_extension) #change this to same name used above in alias_method
end
def read_gimptxt(file_path)
#magic to convert file into [R,G,B,R,G,B,...] array and return it
#Input: file with lines #RRGGBB\n in hex
result = []
IO.read(file_path).lines.each{|line|
r = line[1..2].to_i(16)
g = line[3..4].to_i(16)
b = line[5..6].to_i(16)
result << r << g << b
}
return result
end
end
end