Render.py not only updates images that have changed.

Added force build to gallery.py.
This commit is contained in:
Chris Palmer 2019-06-09 17:23:30 +01:00
parent 5af2302053
commit 50d3570be4
6 changed files with 10 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 KiB

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 204 KiB

View File

@ -29,12 +29,13 @@ from tests import do_cmd
import re
from shutil import copyfile
from tests import update_image
import sys
project_dir = '../..'
target_dir = 'gallery'
output_name = target_dir + '/readme.md'
def gallery():
def gallery(force):
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
@ -45,6 +46,8 @@ def gallery():
path = project_dir + '/' + project
print(project)
document = path + '/readme.md'
if force:
os.system('cd %s && make_all' % path)
if os.path.isfile(document):
with open(document, 'rt') as readme:
for line in readme.readlines():
@ -74,4 +77,4 @@ def gallery():
if __name__ == '__main__':
init()
gallery()
gallery(force = len(sys.argv) > 1 and sys.argv[1] == '-f')

View File

@ -24,7 +24,7 @@ from set_config import *
from exports import bom_to_parts
import os
import openscad
from tests import do_cmd
from tests import do_cmd, update_image
from deps import mtime
def render(target, type):
@ -59,8 +59,10 @@ def render(target, type):
f.write('color("lime") import("%s");\n' % part_file)
cam = "--camera=0,0,0,70,0,315,500" if type == 'stl' else "--camera=0,0,0,0,0,0,500"
render = "--preview" if type == 'stl' else "--render"
openscad.run("--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall", "-o", png_name, png_maker_name);
do_cmd(("magick "+ png_name + " -trim -resize 280x280 -background #ffffe5 -gravity Center -extent 280x280 -bordercolor #ffffe5 -border 10 " + png_name).split())
tmp_name = 'tmp.png'
openscad.run("--projection=p", "--imgsize=4096,4096", cam, render, "--autocenter", "--viewall", "-o", tmp_name, png_maker_name);
do_cmd(("magick "+ tmp_name + " -trim -resize 280x280 -background #ffffe5 -gravity Center -extent 280x280 -bordercolor #ffffe5 -border 10 " + tmp_name).split())
update_image(tmp_name, png_name)
os.remove(png_maker_name)
if __name__ == '__main__':