python-refactor
LostQuasar 2 years ago
parent 0b7bac1a7a
commit d8c38cc0cd

@ -0,0 +1,2 @@
raster_images = true
raster_size = 512

@ -1,6 +1,6 @@
from svgutils.compose import * from svgutils.compose import *
from cairosvg import svg2png from cairosvg import svg2png
import toml import toml, os
CONFIG["svg.file_path"] = "../assets/" CONFIG["svg.file_path"] = "../assets/"
@ -8,6 +8,11 @@ with open("../definitions.toml", "r") as def_file:
definitions = toml.loads(def_file.read()) definitions = toml.loads(def_file.read())
with open("../designs.toml", "r") as design_file: with open("../designs.toml", "r") as design_file:
designs = toml.loads(design_file.read()) designs = toml.loads(design_file.read())
with open("../config.toml", "r") as config_file:
config = toml.loads(config_file.read())
os.makedirs("../output/vector/", exist_ok=True)
os.makedirs("../output/" + str(config["raster_size"]) + "/", exist_ok=True)
partsList = [] partsList = []
for key in designs: for key in designs:
@ -18,11 +23,12 @@ for key in designs:
svg_parts = [] svg_parts = []
for part in partsList: for part in partsList:
svg_parts.append(SVG(part)) svg_parts.append(SVG(part))
Figure( Figure("128","128", *svg_parts, SVG("credits.svg")).save("../output/vector/" + key + ".svg")
"128",
"128", if config["raster_images"]:
*svg_parts, svg2png(
SVG("credits.svg") url="../output/vector/" + key + ".svg",
).save("../output/vector/"+key+".svg") write_to="../output/" + str(config["raster_size"]) + "/" + key + ".png", output_width=config["raster_size"]
svg2png(url="../output/vector/"+key+".svg", write_to="../output/512/"+key+".png", output_width=512) )
print("Done!") print("Done!")
Loading…
Cancel
Save