2014-01-13 23:18:25 +11:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# This script updates icons from the SVG file
|
|
|
|
import os
|
2018-01-26 12:46:10 +11:00
|
|
|
import subprocess
|
2014-01-17 16:50:11 +01:00
|
|
|
import sys
|
2014-01-13 23:18:25 +11:00
|
|
|
|
2014-01-13 23:47:33 +11:00
|
|
|
def run(cmd):
|
2018-01-26 12:46:10 +11:00
|
|
|
print(" ", " ".join(cmd))
|
|
|
|
subprocess.check_call(cmd)
|
2014-01-13 23:47:33 +11:00
|
|
|
|
2018-01-26 12:46:10 +11:00
|
|
|
BASEDIR = os.path.abspath(os.path.dirname(__file__))
|
2014-01-13 23:18:25 +11:00
|
|
|
|
2018-07-12 09:13:18 +02:00
|
|
|
inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape")
|
|
|
|
blender_bin = os.environ.get("BLENDER_BIN", "blender")
|
2014-01-17 16:50:11 +01:00
|
|
|
|
|
|
|
if sys.platform == 'darwin':
|
|
|
|
inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script'
|
|
|
|
if os.path.exists(inkscape_app_path):
|
2017-12-13 16:54:45 +11:00
|
|
|
inkscape_bin = inkscape_app_path
|
2018-10-01 10:45:50 +02:00
|
|
|
blender_app_path = '/Applications/blender.app/Contents/MacOS/blender'
|
|
|
|
if os.path.exists(blender_app_path):
|
|
|
|
blender_bin = blender_app_path
|
2014-01-17 16:50:11 +01:00
|
|
|
|
2018-01-26 12:46:10 +11:00
|
|
|
cmd = (
|
|
|
|
inkscape_bin,
|
|
|
|
os.path.join(BASEDIR, "blender_icons.svg"),
|
|
|
|
"--export-width=602",
|
|
|
|
"--export-height=640",
|
|
|
|
"--without-gui",
|
|
|
|
"--export-png=" + os.path.join(BASEDIR, "blender_icons16.png"),
|
|
|
|
)
|
2014-01-13 23:47:33 +11:00
|
|
|
run(cmd)
|
2018-01-26 12:46:10 +11:00
|
|
|
|
|
|
|
cmd = (
|
|
|
|
inkscape_bin,
|
|
|
|
os.path.join(BASEDIR, "blender_icons.svg"),
|
|
|
|
"--export-width=1204",
|
|
|
|
"--export-height=1280",
|
|
|
|
"--without-gui",
|
|
|
|
"--export-png=" + os.path.join(BASEDIR, "blender_icons32.png"),
|
|
|
|
)
|
2014-01-13 23:47:33 +11:00
|
|
|
run(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
# For testing it can be good to clear all old
|
|
|
|
# rm ./blender_icons16/*.dat
|
|
|
|
# rm ./blender_icons32/*.dat
|
|
|
|
|
|
|
|
datatoc_icon_split_py = os.path.join(BASEDIR, "..", "..", "source", "blender", "datatoc", "datatoc_icon_split.py")
|
|
|
|
|
|
|
|
# create .dat pixmaps (which are stored in git)
|
|
|
|
cmd = (
|
2018-01-28 16:03:32 +11:00
|
|
|
blender_bin, "--background", "--factory-startup", "-noaudio",
|
2018-01-26 12:46:10 +11:00
|
|
|
"--python", datatoc_icon_split_py, "--",
|
|
|
|
"--image=" + os.path.join(BASEDIR, "blender_icons16.png"),
|
|
|
|
"--output=" + os.path.join(BASEDIR, "blender_icons16"),
|
|
|
|
"--output_prefix=icon16_",
|
|
|
|
"--name_style=UI_ICONS",
|
|
|
|
"--parts_x", "26", "--parts_y", "30",
|
|
|
|
"--minx", "3", "--maxx", "53", "--miny", "3", "--maxy", "8",
|
|
|
|
"--minx_icon", "2", "--maxx_icon", "2", "--miny_icon", "2", "--maxy_icon", "2",
|
|
|
|
"--spacex_icon", "1", "--spacey_icon", "1",
|
|
|
|
)
|
2014-01-13 23:47:33 +11:00
|
|
|
run(cmd)
|
|
|
|
|
|
|
|
cmd = (
|
2018-01-28 16:03:32 +11:00
|
|
|
blender_bin, "--background", "--factory-startup", "-noaudio",
|
2018-01-26 12:46:10 +11:00
|
|
|
"--python", datatoc_icon_split_py, "--",
|
|
|
|
"--image=" + os.path.join(BASEDIR, "blender_icons32.png"),
|
|
|
|
"--output=" + os.path.join(BASEDIR, "blender_icons32"),
|
|
|
|
"--output_prefix=icon32_",
|
|
|
|
"--name_style=UI_ICONS",
|
|
|
|
"--parts_x", "26", "--parts_y", "30",
|
|
|
|
"--minx", "6", "--maxx", "106", "--miny", "6", "--maxy", "16",
|
|
|
|
"--minx_icon", "4", "--maxx_icon", "4", "--miny_icon", "4", "--maxy_icon", "4",
|
|
|
|
"--spacex_icon", "2", "--spacey_icon", "2",
|
|
|
|
)
|
2014-01-13 23:47:33 +11:00
|
|
|
run(cmd)
|
|
|
|
|
2018-01-26 12:46:10 +11:00
|
|
|
os.remove(os.path.join(BASEDIR, "blender_icons16.png"))
|
|
|
|
os.remove(os.path.join(BASEDIR, "blender_icons32.png"))
|
2014-01-13 23:47:33 +11:00
|
|
|
|
|
|
|
# For testing, if we want the PNG of each image
|
|
|
|
# ./datatoc_icon_split_to_png.py ./blender_icons16/*.dat
|
|
|
|
# ./datatoc_icon_split_to_png.py ./blender_icons32/*.dat
|