Closed ijlyttle closed 3 years ago
This is also a re-imagining of the API 😬
I think that we want to focus on a "class" of color spaces that I'll call Lab-100 class. These color spaces have:
Lab-100
Examples of these colorspaces are:
#' @param mat, `matrix` #' @param hex, `character` with S3 class `pth_hex`, representing a six-character hex code
To convert between different expressions of color:
#' @param color object with class `pth_hex`, `pth_mat` # @param ... additional parameters needed to define a color space #' if `NULL`, will look for `color_space` attribute on `color` pth_to_cielab <- function(color, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cielab` pth_to_cieluv <- function(color, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cieluv` pth_to_cam02ucs <- function(color, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cam02ucs` pth_to_cam16ucs <- function(color, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cam16ucs` pth_to_jzazbz100 <- function(color, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_jzazbz100` pth_to_hex <- function(color) # returns `character` with S3 class `pth_hex`
To create a structure:
#' These functions put classes onto existing structures and values. pth_new_cielab <- function(mat, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cielab` pth_new_cieluv <- function(mat, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cieluv` pth_new_cam02ucs <- function(mat, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cam02ucs` pth_new_cam16ucs <- function(mat, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_cam16ucs` pth_new_jzazbz100 <- function(mat, ...) # returns `matrix` with S3 classes `pth_mat`, `pth_jzazbz100` pth_new_hex <- function(hex) # returns `character` with S3 class `pth_hex`, representing a six-character hex code
Will also need helpers:
pth_to_cartesian <- function(mat, chroma_min = 1.e-4) # returns `matrix` pth_to_polar <- function(mat) # returns `matrix`
Let's think a bit about the S3 classes:
pth_mat: has three columns representing luminance, blue-yellow, green-red pth_cieluv: pth_mat that uses CIELUV color space, ... pth_hex: character representing a six-character hex code
pth_mat
pth_cieluv
pth_hex
character
This is also a re-imagining of the API 😬
I think that we want to focus on a "class" of color spaces that I'll call
Lab-100
class. These color spaces have:Examples of these colorspaces are:
To convert between different expressions of color:
To create a structure:
Will also need helpers:
Let's think a bit about the S3 classes:
pth_mat
: has three columns representing luminance, blue-yellow, green-redpth_cieluv
:pth_mat
that uses CIELUV color space, ...pth_hex
:character
representing a six-character hex code