Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# from here:
# https://github.com/rstudio/gt/blob/ff878e10d21a3ba897c5f99801b796da8fb637fa/R/helpers.R#L2496-L2536
adjust_luminance <- function(colors, steps) {
stopifnot(steps < 2, steps > -2)
rgb_matrix <- t(grDevices::col2rgb(colors, alpha = TRUE)) / 255
alpha <- rgb_matrix[, "alpha"]
luv_matrix <-
grDevices::convertColor(rgb_matrix[, 1:3], "sRGB", "Luv")
h <- atan2(luv_matrix[, "v"], luv_matrix[, "u"]) * 180 / pi
c <- sqrt(luv_matrix[, "u"]^2 + luv_matrix[, "v"]^2)
@ratnanil
ratnanil / get_data.R
Last active April 4, 2024 23:05
Create Fishnet from swissAlti3D URLs
library(readr)
library(tidyr)
library(sf)
library(dplyr)
library(purrr)
library(glue)
ullr2poly <- function(xmin, ymin, xmax, ymax){
c(1,2,1,4,3,4,3,2,1,2) |>
sapply(\(x)c(xmin, ymin, xmax, ymax)[x]) |>
matrix(ncol = 2, byrow = TRUE) |>