Moved some drawing code into separate functions
This commit is contained in:
@@ -100,78 +100,11 @@ def benchmark_draw_post_pixel(arg1, arg2):
|
|||||||
draw_image(splash_filepath, 0, image_y, window_width, image_h)
|
draw_image(splash_filepath, 0, image_y, window_width, image_h)
|
||||||
|
|
||||||
if result_dict:
|
if result_dict:
|
||||||
x = 0.5 * window_width
|
_draw_benchmark_has_run(image_y, ui_scale, window_width, window_height)
|
||||||
y = 0.70 * window_height
|
|
||||||
|
|
||||||
score = 0
|
|
||||||
for name_stats in G.result_dict["scenes"]:
|
|
||||||
stat = name_stats['stats']
|
|
||||||
if stat["result"] == "OK":
|
|
||||||
score += stat["total_render_time"]
|
|
||||||
else:
|
|
||||||
score = -1
|
|
||||||
|
|
||||||
if score >= 0:
|
|
||||||
blf.size(font_id, int(32 * ui_scale), 72)
|
|
||||||
draw_text_center("Your Time: {}".format(
|
|
||||||
util.humanReadableTimeDifference(score)), x, y, shadow=True)
|
|
||||||
else:
|
|
||||||
blf.size(font_id, int(18 * ui_scale), 72)
|
|
||||||
draw_text_center("Unfortunately, crash happened :(", x, y, shadow=True)
|
|
||||||
blf.size(font_id, int(24 * ui_scale), 72)
|
|
||||||
draw_text_center("You can still share data of succeeded scenes!",
|
|
||||||
x, y - 26 * ui_scale, shadow=True)
|
|
||||||
|
|
||||||
x = 50.0 * ui_scale
|
|
||||||
y = image_y - (image_y - 52 * ui_scale - 18 * 3 * ui_scale) * 0.5
|
|
||||||
blf.size(font_id, int(12 * ui_scale), 72)
|
|
||||||
draw_text_multiline(BLURB_TEXT, x, y)
|
|
||||||
elif result_stats or result_platform or progress_status:
|
elif result_stats or result_platform or progress_status:
|
||||||
blf.size(font_id, int(12 * ui_scale), 72)
|
_draw_benchmark_is_running(image_y, result_platform, result_stats, ui_scale, window_width)
|
||||||
|
|
||||||
x = 50.0 * ui_scale
|
|
||||||
y = image_y - 20 * ui_scale
|
|
||||||
|
|
||||||
# Stats
|
|
||||||
if result_platform:
|
|
||||||
draw_text_multiline(result_platform, 0.5 * window_width + x, y)
|
|
||||||
if result_stats:
|
|
||||||
draw_text_multiline(result_stats, x, y)
|
|
||||||
|
|
||||||
# Progress
|
|
||||||
progress_x = 0.0
|
|
||||||
progress_y = image_y + 1
|
|
||||||
progress_w = window_width * G.current_progress
|
|
||||||
progress_h = 15.0 * ui_scale
|
|
||||||
progress_color = [0.8, 1.0, 1.0, 0.2]
|
|
||||||
|
|
||||||
draw_rect(progress_x, progress_y, progress_w, progress_h, progress_color)
|
|
||||||
|
|
||||||
# Current status
|
|
||||||
if G.progress_status:
|
|
||||||
blf.size(font_id, int(18 * ui_scale), 72)
|
|
||||||
draw_text_multiline(G.progress_status,
|
|
||||||
progress_x + 8.0 * ui_scale,
|
|
||||||
progress_y + progress_h + int(22 * ui_scale),
|
|
||||||
shadow=True)
|
|
||||||
else:
|
else:
|
||||||
# Title
|
_draw_introduction(image_y, ui_scale, window_width, window_height)
|
||||||
x = 0.5 * window_width
|
|
||||||
y = 0.70 * window_height
|
|
||||||
|
|
||||||
blf.size(font_id, int(32 * ui_scale), 72)
|
|
||||||
draw_text_center("Blender Benchmark 1.0 Beta", x, y, shadow=True)
|
|
||||||
|
|
||||||
y -= 32 * ui_scale
|
|
||||||
|
|
||||||
blf.size(font_id, int(12 * ui_scale), 72)
|
|
||||||
draw_text_center("Free and Open Data for everyone.",
|
|
||||||
x, y, shadow=True)
|
|
||||||
|
|
||||||
x = 50.0 * ui_scale
|
|
||||||
y = image_y - (image_y - 52 * ui_scale - 18 * 3 * ui_scale) * 0.5
|
|
||||||
blf.size(font_id, int(12 * ui_scale), 72)
|
|
||||||
draw_text_multiline(WELCOME_TEXT, x, y)
|
|
||||||
|
|
||||||
# Bottom bar
|
# Bottom bar
|
||||||
bottom_x = 0
|
bottom_x = 0
|
||||||
@@ -196,3 +129,83 @@ def benchmark_draw_post_pixel(arg1, arg2):
|
|||||||
draw_image(logo_filepath,
|
draw_image(logo_filepath,
|
||||||
logo_padding, logo_padding,
|
logo_padding, logo_padding,
|
||||||
logo_width, logo_height)
|
logo_width, logo_height)
|
||||||
|
|
||||||
|
|
||||||
|
def _draw_introduction(image_y, ui_scale, window_width, window_height):
|
||||||
|
"""Draw title and welcome text."""
|
||||||
|
|
||||||
|
x = 0.5 * window_width
|
||||||
|
y = 0.70 * window_height
|
||||||
|
blf.size(font_id, int(32 * ui_scale), 72)
|
||||||
|
draw_text_center("Blender Benchmark 1.0 Beta", x, y, shadow=True)
|
||||||
|
|
||||||
|
y -= 32 * ui_scale
|
||||||
|
blf.size(font_id, int(12 * ui_scale), 72)
|
||||||
|
draw_text_center("Free and Open Data for everyone.",
|
||||||
|
x, y, shadow=True)
|
||||||
|
|
||||||
|
x = 50.0 * ui_scale
|
||||||
|
y = image_y - (image_y - 52 * ui_scale - 18 * 3 * ui_scale) * 0.5
|
||||||
|
blf.size(font_id, int(12 * ui_scale), 72)
|
||||||
|
draw_text_multiline(WELCOME_TEXT, x, y)
|
||||||
|
|
||||||
|
|
||||||
|
def _draw_benchmark_is_running(image_y, result_platform, result_stats, ui_scale, window_width):
|
||||||
|
"""Draw while the benchmark is running."""
|
||||||
|
|
||||||
|
blf.size(font_id, int(12 * ui_scale), 72)
|
||||||
|
x = 50.0 * ui_scale
|
||||||
|
y = image_y - 20 * ui_scale
|
||||||
|
|
||||||
|
# Stats
|
||||||
|
if result_platform:
|
||||||
|
draw_text_multiline(result_platform, 0.5 * window_width + x, y)
|
||||||
|
if result_stats:
|
||||||
|
draw_text_multiline(result_stats, x, y)
|
||||||
|
|
||||||
|
# Progress
|
||||||
|
progress_x = 0.0
|
||||||
|
progress_y = image_y + 1
|
||||||
|
progress_w = window_width * G.current_progress
|
||||||
|
progress_h = 15.0 * ui_scale
|
||||||
|
progress_color = [0.8, 1.0, 1.0, 0.2]
|
||||||
|
draw_rect(progress_x, progress_y, progress_w, progress_h, progress_color)
|
||||||
|
|
||||||
|
# Current status
|
||||||
|
if G.progress_status:
|
||||||
|
blf.size(font_id, int(18 * ui_scale), 72)
|
||||||
|
draw_text_multiline(G.progress_status,
|
||||||
|
progress_x + 8.0 * ui_scale,
|
||||||
|
progress_y + progress_h + int(22 * ui_scale),
|
||||||
|
shadow=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _draw_benchmark_has_run(image_y, ui_scale, window_width, window_height):
|
||||||
|
"""Draw submit button and other after-running stuff."""
|
||||||
|
|
||||||
|
x = 0.5 * window_width
|
||||||
|
y = 0.70 * window_height
|
||||||
|
|
||||||
|
score = 0
|
||||||
|
for name_stats in G.result_dict["scenes"]:
|
||||||
|
stat = name_stats['stats']
|
||||||
|
if stat["result"] == "OK":
|
||||||
|
score += stat["total_render_time"]
|
||||||
|
else:
|
||||||
|
score = -1
|
||||||
|
|
||||||
|
if score >= 0:
|
||||||
|
blf.size(font_id, int(32 * ui_scale), 72)
|
||||||
|
draw_text_center("Your Time: {}".format(
|
||||||
|
util.humanReadableTimeDifference(score)), x, y, shadow=True)
|
||||||
|
else:
|
||||||
|
blf.size(font_id, int(18 * ui_scale), 72)
|
||||||
|
draw_text_center("Unfortunately, crash happened :(", x, y, shadow=True)
|
||||||
|
blf.size(font_id, int(24 * ui_scale), 72)
|
||||||
|
draw_text_center("You can still share data of succeeded scenes!",
|
||||||
|
x, y - 26 * ui_scale, shadow=True)
|
||||||
|
|
||||||
|
x = 50.0 * ui_scale
|
||||||
|
y = image_y - (image_y - 52 * ui_scale - 18 * 3 * ui_scale) * 0.5
|
||||||
|
blf.size(font_id, int(12 * ui_scale), 72)
|
||||||
|
draw_text_multiline(BLURB_TEXT, x, y)
|
||||||
|
Reference in New Issue
Block a user