From 206b27fbd17809772d3c47d7f911b97aca1be464 Mon Sep 17 00:00:00 2001 From: tylermorganwall Date: Mon, 23 Dec 2024 23:35:43 -0500 Subject: [PATCH] rayshader v0.38.6: Update rayimage dependency to fix text in HQ renders and scalebars --- DESCRIPTION | 6 +++--- R/render_highquality.R | 23 +++++++++-------------- R/render_scalebar.R | 2 +- man/render_highquality.Rd | 8 ++++---- man/render_scalebar.Rd | 2 +- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8df0b615..de48a728 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: rayshader Type: Package Title: Create Maps and Visualize Data in 2D and 3D -Version: 0.38.5 -Date: 2024-12-22 +Version: 0.38.6 +Date: 2024-12-23 Authors@R: person("Tyler", "Morgan-Wall", email = "tylermw@gmail.com",role = c("aut", "cph", "cre"), comment = c(ORCID = "0000-0002-3131-3814")) @@ -26,7 +26,7 @@ Imports: doParallel, utils, methods, terrainmeshr, - rayimage (>= 0.12.1), + rayimage (>= 0.14.4), rayvertex (>= 0.11.4), rayrender (>= 0.36.5) Suggests: diff --git a/R/render_highquality.R b/R/render_highquality.R index f2c11a42..4a3ab7ad 100644 --- a/R/render_highquality.R +++ b/R/render_highquality.R @@ -173,10 +173,10 @@ render_highquality = function(filename = NA, samples = 128, override_material = FALSE, cache_scene = FALSE, reset_scene_cache = FALSE, width = NULL, height = NULL, - text_angle = NULL, text_size = 6, text_offset = c(0,0,0), + text_angle = NULL, text_size = 12, text_offset = c(0,text_size/2,0), line_radius=0.5, point_radius = 0.5, smooth_line = FALSE, use_extruded_paths = FALSE, - scale_text_angle = NULL, scale_text_size = 6, scale_text_offset = c(0,0,0), + scale_text_angle = NULL, scale_text_size = 12, scale_text_offset = c(0,scale_text_size/2,0), title_text = NULL, title_offset = c(20,20), title_color = "black", title_size = 30, title_font = "sans", title_bar_color = NULL, title_bar_alpha = 0.5, @@ -434,9 +434,8 @@ render_highquality = function(filename = NA, samples = 128, x=temp_center[j,1] - bbox_center[1] + text_offset[1], y=temp_center[j,2] - bbox_center[2] + text_offset[2], z=temp_center[j,3] - bbox_center[3] + text_offset[3], - angle = anglevec, - text_height = text_size, - material = rayrender::diffuse(color = temp_color[j,1:3])) + angle = anglevec, + text_height = text_size, font_color = temp_color[j,1:3]) counter = counter + 1 } } @@ -528,11 +527,6 @@ render_highquality = function(filename = NA, samples = 128, temp_center = rgl.attrib(scalelabelids[i], "centers") temp_color = rgl.attrib(scalelabelids[i], "colors") for(j in seq_len(nrow(temp_label))) { - scalelabelfile = tempfile(fileext = ".png") - rayimage::add_title(matrix(0,ncol = nchar(temp_label[j,1])*60, nrow=60), - title_size = 60, - title_offset = c(0,0),title_text = temp_label, title_color = "white", - title_position = "center", filename = scalelabelfile) if(is.null(text_angle)) { anglevec = c(-phi,theta,0) } else { @@ -542,12 +536,11 @@ render_highquality = function(filename = NA, samples = 128, anglevec = text_angle } } - scalelabels[[counter]] = rayrender::xy_rect(x=temp_center[j,1] - bbox_center[1] + scale_text_offset[1], + scalelabels[[counter]] = rayrender::text3d(x=temp_center[j,1] - bbox_center[1] + scale_text_offset[1], y=temp_center[j,2] - bbox_center[2] + scale_text_offset[2], z=temp_center[j,3] - bbox_center[3] + scale_text_offset[3], - angle = anglevec, - xwidth = nchar(temp_label[j,1])*scale_text_size, ywidth = scale_text_size, - material = rayrender::diffuse(color = temp_color[j,1:3], alpha_texture = scalelabelfile)) + angle = anglevec, label = temp_label, + text_height = scale_text_size, font_color = temp_color[j,1:3]) counter = counter + 1 } } @@ -646,11 +639,13 @@ render_highquality = function(filename = NA, samples = 128, clamp_value = clamp_value, ...) if(has_title) { if(is.na(filename)) { + temp = rayimage::ray_read_image(temp) rayimage::add_title(temp, title_text = title_text, title_color = title_color, title_font = title_font, title_offset = title_offset, title_bar_alpha = title_bar_alpha, title_bar_color = title_bar_color, title_size = title_size, preview = TRUE) } else { + temp = rayimage::ray_read_image(temp) rayimage::add_title(temp, title_text = title_text, title_color = title_color, title_font = title_font, title_offset = title_offset, title_bar_alpha = title_bar_alpha, title_bar_color = title_bar_color, diff --git a/R/render_scalebar.R b/R/render_scalebar.R index 2e112855..4649acba 100644 --- a/R/render_scalebar.R +++ b/R/render_scalebar.R @@ -40,7 +40,7 @@ #'if(run_documentation()) { #'#This function works with `render_highquality()` #'render_highquality(lightdirection = 250, lightaltitude = 40, -#' scale_text_size = 24, clamp_value = 10, +#' scale_text_size = 36, clamp_value = 10, #' sample_method = "sobol_blue", samples = 128) #'render_scalebar(clear_scalebar = TRUE) #'} diff --git a/man/render_highquality.Rd b/man/render_highquality.Rd index c14895f9..e294c98c 100644 --- a/man/render_highquality.Rd +++ b/man/render_highquality.Rd @@ -25,15 +25,15 @@ render_highquality( width = NULL, height = NULL, text_angle = NULL, - text_size = 6, - text_offset = c(0, 0, 0), + text_size = 12, + text_offset = c(0, text_size/2, 0), line_radius = 0.5, point_radius = 0.5, smooth_line = FALSE, use_extruded_paths = FALSE, scale_text_angle = NULL, - scale_text_size = 6, - scale_text_offset = c(0, 0, 0), + scale_text_size = 12, + scale_text_offset = c(0, scale_text_size/2, 0), title_text = NULL, title_offset = c(20, 20), title_color = "black", diff --git a/man/render_scalebar.Rd b/man/render_scalebar.Rd index 71c58a79..0aa4b025 100644 --- a/man/render_scalebar.Rd +++ b/man/render_scalebar.Rd @@ -80,7 +80,7 @@ render_snapshot() if(run_documentation()) { #This function works with `render_highquality()` render_highquality(lightdirection = 250, lightaltitude = 40, - scale_text_size = 24, clamp_value = 10, + scale_text_size = 36, clamp_value = 10, sample_method = "sobol_blue", samples = 128) render_scalebar(clear_scalebar = TRUE) }