Draw shadow under the text
This commit is contained in:
@@ -78,20 +78,31 @@ def viewport_size():
|
||||
bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport)
|
||||
return viewport[2], viewport[3]
|
||||
|
||||
def draw_text_center(text, x, y):
|
||||
def draw_text_center(text, x, y, shadow=False):
|
||||
dim = blf.dimensions(font_id, text)
|
||||
cx = x - int(dim[0]/2)
|
||||
cy = y - int(dim[1]/2)
|
||||
if shadow:
|
||||
delta = 1
|
||||
blf.color(font_id, 0.2, 0.2, 0.2, 1.0)
|
||||
blf.position(font_id, cx + delta, cy - delta, 0)
|
||||
blf.draw(font_id, text)
|
||||
blf.color(font_id, 1.0, 1.0, 1.0, 1.0)
|
||||
blf.position(font_id, cx, cy, 0)
|
||||
|
||||
blf.draw(font_id, text)
|
||||
|
||||
def draw_text_multiline(text, x, y):
|
||||
def draw_text_multiline(text, x, y, shadow=False):
|
||||
ui_scale = bpy.context.user_preferences.system.ui_scale
|
||||
height = int(blf.dimensions(font_id, "Dummy Text")[1])
|
||||
space = int(8 * ui_scale)
|
||||
|
||||
for line in text.split('\n'):
|
||||
if shadow:
|
||||
delta = 1
|
||||
blf.color(font_id, 0.2, 0.2, 0.2, 1.0)
|
||||
blf.position(font_id, x + delta, y - height - delta, 0)
|
||||
blf.draw(font_id, line)
|
||||
blf.color(font_id, 1.0, 1.0, 1.0, 1.0)
|
||||
blf.position(font_id, x, y - height, 0)
|
||||
blf.draw(font_id, line)
|
||||
y -= height + space
|
||||
@@ -152,12 +163,13 @@ def benchmark_draw_post_pixel(arg1, arg2):
|
||||
if score >= 0:
|
||||
blf.size(font_id, int(32 * ui_scale), 72)
|
||||
draw_text_center("Your time {}" . format(
|
||||
util.humanReadableTimeDifference(score)), x, y)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
@@ -189,19 +201,21 @@ def benchmark_draw_post_pixel(arg1, arg2):
|
||||
blf.size(font_id, int(18 * ui_scale), 72)
|
||||
draw_text_multiline(global_progress_status,
|
||||
progress_x + 8.0 * ui_scale,
|
||||
progress_y + progress_h + int(22 * ui_scale))
|
||||
progress_y + progress_h + int(22 * ui_scale),
|
||||
shadow=True)
|
||||
else:
|
||||
# Title
|
||||
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", x, y)
|
||||
draw_text_center("Blender Benchmark 1.0", x, y, shadow=True)
|
||||
|
||||
y -= 32 * ui_scale
|
||||
|
||||
blf.size(font_id, int(12 * ui_scale), 72)
|
||||
draw_text_center("Explore the results on opendata.blender.org", x, y)
|
||||
draw_text_center("Explore the results on opendata.blender.org",
|
||||
x, y, shadow=True)
|
||||
|
||||
x = 50.0 * ui_scale
|
||||
y = image_y - (image_y - 52 * ui_scale - 18 * 3 * ui_scale) * 0.5
|
||||
|
Reference in New Issue
Block a user