#remotes::install_cran(c("anglr", "silicate"))
library(silicate)
library(anglr)
library(rgl)
## volcano is heightmap, doesn't exist in geo-space in R so we map it do the extent of
## these spatial polygons
poly <- silicate::minimal_mesh
# xmin : 0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
#' Create a list with a default value | |
#' | |
#' This behaves exactly like a 'list()' object, except if the requested value | |
#' does not exist, a default value is returned (instead of NULL). | |
#' | |
#' Similar to a `defaultdict` in Python | |
#' | |
#' @param value default value to return if item not in list | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
#' Detect special characters in a character vector of args | |
#' | |
#' This is implemented as a whitelist of characters to accept. The presence | |
#' of anything outside this whitelist is considered a 'special character' | |
#' | |
#' @param args character vector of args to check | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# A bunch of points | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
N <- 10 | |
point_coords <- cbind( | |
rep(seq(0, 1, length.out = N), times = N), | |
rep(seq(0, 1, length.out = N), each = N) | |
) | |
points <- sf::st_multipoint(point_coords) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Simple function to create a plot with N overlapping rectangles with | |
# each having an alpha of 1/N | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
stack_alpha <- function(N) { | |
plot_df <- tibble( | |
x = seq(0.45, 0.55, length.out = N), | |
y = seq(0.45, 0.55, length.out = N), | |
alpha = 1/N | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(minisvg) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Define filter with turbulence driving the displacmenet | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
my_filter <- stag$filter( | |
id = "displacementFilter", | |
x = "-30%", y = "-30%", width="160%", height="160%", | |
stag$feTurbulence( | |
type = "turbulence", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
#' Create a CSS ruleset | |
#' | |
#' Create a CSS ruleset consisting of a selector and one-or-more property declarations, | |
#' or, if no \code{.selector} is given, create an inline style string | |
#' | |
#' The list of included properties is not a complete list, but rather an | |
#' abbreviated list from | |
#' \url{https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Simple demo of a 10 argument function | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
nargs <- 10 | |
f <- function() {} | |
fargs <- as.pairlist(setNames(rep(1, nargs), paste0('v', seq(nargs)))) | |
formals(f) <- fargs | |
f | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressPackageStartupMessages({ | |
library(dplyr) | |
library(ggplot2) | |
library(metR) | |
library(tidyr) | |
}) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Load a black and white Mona Lisa. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
#' Inner recursive routine for solving Countdown numbers puzzle | |
#' | |
#' @param nums What numbers are left to select from? | |
#' @param value the current calculated value | |
#' @param expr the current readable expression | |
#' @param verbose output solutions as they are found? default: FALSE | |
#' | |
#' @return Character vector of solutions if any are found, otherwise NULL | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |