|
|
@ -90,12 +90,10 @@ class AHB_Render: |
|
|
|
# render lines in black, background in red, fill shapes in green |
|
|
|
# render lines in black, background in red, fill shapes in green |
|
|
|
# the green band contains the lines images, the red band contains the inverted alpha layer |
|
|
|
# the green band contains the lines images, the red band contains the inverted alpha layer |
|
|
|
self.set_render_lines((0.0, 0.0, 0.0), (0.0, 1.0, 0.0), mask_stages_below=mask_stages_below, mask_color=(1.0, 0.0, 1.0)) |
|
|
|
self.set_render_lines((0.0, 0.0, 0.0), (0.0, 1.0, 0.0), mask_stages_below=mask_stages_below, mask_color=(1.0, 0.0, 1.0)) |
|
|
|
Gui.ActiveDocument.ActiveView.saveImage(temp_lines_file_name, resolution[0], resolution[1], "#ff0000") |
|
|
|
Gui.ActiveDocument.ActiveView.saveImage(temp_lines_file_name, resolution[0]+2, resolution[1]+2, "#ff0000") |
|
|
|
|
|
|
|
|
|
|
|
self.set_render_outlines(mask_stages_below=mask_stages_below) |
|
|
|
self.set_render_outlines(mask_stages_below=mask_stages_below) |
|
|
|
Gui.ActiveDocument.ActiveView.saveImage(temp_shapes_file_name, resolution[0] * 2, resolution[1] * 2, "#ffffff") |
|
|
|
Gui.ActiveDocument.ActiveView.saveImage(temp_shapes_file_name, (resolution[0]+2) * 2, (resolution[1]+2) * 2, "#ffffff") |
|
|
|
|
|
|
|
|
|
|
|
self.reset_display() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lines_bands = Image.open(temp_lines_file_name).split() |
|
|
|
lines_bands = Image.open(temp_lines_file_name).split() |
|
|
|
lines = lines_bands[1] |
|
|
|
lines = lines_bands[1] |
|
|
@ -146,6 +144,9 @@ class AHB_Render: |
|
|
|
alpha_band |
|
|
|
alpha_band |
|
|
|
]) |
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# crop 1px borders |
|
|
|
|
|
|
|
result = result.crop((1, 1, result.size[0] - 1, result.size[1] - 1)) |
|
|
|
|
|
|
|
|
|
|
|
result.save(filename) |
|
|
|
result.save(filename) |
|
|
|
|
|
|
|
|
|
|
|
print("Rendered " + filename + " in " + str( |
|
|
|
print("Rendered " + filename + " in " + str( |
|
|
@ -157,6 +158,7 @@ class AHB_Render: |
|
|
|
from PIL import Image, ImageFilter |
|
|
|
from PIL import Image, ImageFilter |
|
|
|
import math |
|
|
|
import math |
|
|
|
from pivy import coin |
|
|
|
from pivy import coin |
|
|
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
render_main = False |
|
|
|
render_main = False |
|
|
|
render_stages = False |
|
|
|
render_stages = False |
|
|
@ -178,6 +180,7 @@ class AHB_Render: |
|
|
|
resolution = (3000,3000) |
|
|
|
resolution = (3000,3000) |
|
|
|
workbench.context.setAllStagesVisible(True) |
|
|
|
workbench.context.setAllStagesVisible(True) |
|
|
|
self.render(resolution, filename) |
|
|
|
self.render(resolution, filename) |
|
|
|
|
|
|
|
self.reset_display() |
|
|
|
img_full = Image.new('RGB', resolution, (255, 255, 255)) |
|
|
|
img_full = Image.new('RGB', resolution, (255, 255, 255)) |
|
|
|
img = Image.open(filename) |
|
|
|
img = Image.open(filename) |
|
|
|
img_full.paste(img, None, img.getchannel('A')) |
|
|
|
img_full.paste(img, None, img.getchannel('A')) |
|
|
@ -215,12 +218,13 @@ class AHB_Render: |
|
|
|
if prev_stage_id is not None: |
|
|
|
if prev_stage_id is not None: |
|
|
|
pass |
|
|
|
pass |
|
|
|
prev_stage_id = stage_id |
|
|
|
prev_stage_id = stage_id |
|
|
|
|
|
|
|
self.reset_display() |
|
|
|
|
|
|
|
|
|
|
|
if render_parts: |
|
|
|
if render_parts: |
|
|
|
rendered_references = [] |
|
|
|
rendered_references = [] |
|
|
|
max_resolution = 1500 |
|
|
|
max_length = 1500 |
|
|
|
max_length = 2000 |
|
|
|
max_resolution = 800 |
|
|
|
min_resolution = 250 |
|
|
|
min_resolution = 350 |
|
|
|
shutil.rmtree(dir + "/parts", ignore_errors=True) |
|
|
|
shutil.rmtree(dir + "/parts", ignore_errors=True) |
|
|
|
os.makedirs(dir + "/parts", exist_ok=True) |
|
|
|
os.makedirs(dir + "/parts", exist_ok=True) |
|
|
|
count = 0 |
|
|
|
count = 0 |
|
|
@ -285,25 +289,43 @@ class AHB_Render: |
|
|
|
cross_length = max(dimensions[0], dimensions[1] * 0.5) |
|
|
|
cross_length = max(dimensions[0], dimensions[1] * 0.5) |
|
|
|
cross_length = max(cross_length, main_length * 0.25 + cross_length * 0.8) |
|
|
|
cross_length = max(cross_length, main_length * 0.25 + cross_length * 0.8) |
|
|
|
|
|
|
|
|
|
|
|
main_length_pixels = max(min_resolution, int(math.sqrt(min(1.0, main_length / max_length)) * max_resolution)) |
|
|
|
main_length_pixels = max(min_resolution, int(math.pow(min(1.0, main_length / max_length), 0.3) * max_resolution)) |
|
|
|
cross_length_pixels = int(cross_length * main_length_pixels / main_length) |
|
|
|
cross_length_pixels = int(cross_length * main_length_pixels / main_length) |
|
|
|
|
|
|
|
|
|
|
|
cam.scaleHeight(0.05 + 0.95 * cross_length_pixels / main_length_pixels) |
|
|
|
cam.scaleHeight(0.05 + 0.95 * cross_length_pixels / main_length_pixels) |
|
|
|
|
|
|
|
|
|
|
|
resolution = (main_length_pixels, cross_length_pixels) |
|
|
|
resolution = (main_length_pixels, cross_length_pixels) |
|
|
|
|
|
|
|
|
|
|
|
part_filename = dir + "/parts/" + part_to_render.Base_Reference.upper().replace(' ', '-') + ".png" |
|
|
|
part_filename = dir + "/parts/" + re.sub('[^A-Z0-9_]', '-', part_to_render.Base_Reference.upper()) + ".png" |
|
|
|
self.render(resolution, part_filename) |
|
|
|
self.render(resolution, part_filename) |
|
|
|
|
|
|
|
|
|
|
|
bg = Image.new('RGB', resolution, (255, 255, 255)) |
|
|
|
image = Image.new('RGB', resolution, (255, 255, 255)) |
|
|
|
fg = Image.open(part_filename) |
|
|
|
fg = Image.open(part_filename) |
|
|
|
bg.paste(fg, None, fg.getchannel('A')) |
|
|
|
image.paste(fg, None, fg.getchannel('A')) |
|
|
|
bg.save(part_filename) |
|
|
|
#image.save(part_filename) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final_apsect_ratio = 2.0 # width/height |
|
|
|
|
|
|
|
final_resolution = (max_resolution, int(max_resolution / final_apsect_ratio)) |
|
|
|
|
|
|
|
final_size = image.size |
|
|
|
|
|
|
|
if final_size[0] > final_resolution[0]: |
|
|
|
|
|
|
|
final_size = (final_size[0] * final_resolution[0] / final_size[0], final_size[1] * final_resolution[0] / final_size[0]) |
|
|
|
|
|
|
|
if final_size[1] > final_resolution[1]: |
|
|
|
|
|
|
|
final_size = (final_size[0] * final_resolution[1] / final_size[1], final_size[1] * final_resolution[1] / final_size[1]) |
|
|
|
|
|
|
|
final_size = (int(final_size[0]), int(final_size[1])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if final_size[0] < image.size[0] or final_size[1] < image.size[1]: |
|
|
|
|
|
|
|
image.thumbnail(final_size, Image.ANTIALIAS) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final_image = Image.new('RGB', final_resolution, (255, 255, 255)) |
|
|
|
|
|
|
|
final_image.paste(image, (final_resolution[0] - final_size[0], int(final_resolution[1]/2 - final_size[1]/2))) |
|
|
|
|
|
|
|
final_image.save(part_filename) |
|
|
|
|
|
|
|
|
|
|
|
count = count + 1 |
|
|
|
count = count + 1 |
|
|
|
if count == 10: |
|
|
|
if count == 10: |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.reset_display() |
|
|
|
|
|
|
|
|
|
|
|
workbench.context.setAllStagesVisible(True) |
|
|
|
workbench.context.setAllStagesVisible(True) |
|
|
|
|
|
|
|
|
|
|
|
from ahb_command import AHB_CommandWrapper |
|
|
|
from ahb_command import AHB_CommandWrapper |
|
|
|