X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=scripts%2Fmaketex.py;h=916ce747c404f8b26210078a0e07b7d53f8b5fbf;hb=4db19012183dc1131c1e3bcc88a555132c245cae;hp=2e1069486585a252584993f0bc3217fcf8131fc3;hpb=7de9a53a36fd4cc2bb08739b25695d3054f0d22a;p=libs%2Fgl.git diff --git a/scripts/maketex.py b/scripts/maketex.py index 2e106948..916ce747 100755 --- a/scripts/maketex.py +++ b/scripts/maketex.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 def escape(str): result = "" @@ -8,10 +8,10 @@ def escape(str): elif c=='\\': result += '\\\\' elif ord(c)<0x20: - result += "\\%03o"%ord(c) + result += "\\{:03o}".format(ord(c)) else: result += c - return result; + return result def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None, srgb=False): from PIL import Image @@ -27,14 +27,14 @@ def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None, srgb=False): if srgb: fmt = "S"+fmt - result = "storage %s %d %d;\n"%(fmt, img.size[0], img.size[1]) - result += "filter %s;\n"%filter + result = "storage {} {} {};\n".format(fmt, img.size[0], img.size[1]) + result += "filter {};\n".format(filter) if "MIPMAP" in filter: result += "generate_mipmap true;\n" if anisotropy: - result += "max_anisotropy %d;\n"%anisotropy + result += "max_anisotropy {};\n".format(anisotropy) if wrap: - result += "wrap %s;\n"%wrap + result += "wrap {};\n".format(wrap) result += "raw_data \"" data = list(img.getdata()) for y in range(img.size[1]): @@ -68,5 +68,5 @@ if __name__=="__main__": out_fn = args.output if not out_fn: out_fn = os.path.splitext(args.image)[0]+".tex2d" - out = file(out_fn, "w") + out = open(out_fn, "w") out.write(make_tex(args.image, filter, args.anisotropy, args.wrap, args.srgb))