Use this function to rescale a palette function, for example: clip a certain part of it.

rescaler_bezier(mat_luv, n = 21)

Arguments

mat_luv

matrix of LUV coordinates, control-points for Bézier spline.

n

numeric if rescale_path, number of equally-spaced Bézier points to calculate.

Value

A function with S3 class cpath_rescaler.

Details

A rescaler function:

  • must accept input between zero and one.

  • must provide an output between zero and one.

  • the output must to vary monotonically with the input.

Use rescaler_linear() create a new palette-function that uses part of the range of an existing palette-function.

Use rescaler_bezier() to rescale a Bézier palette-function to be more perceptually uniform. This uses fits a spline to equally-spaced points on the colorpath. The Bézier function makes some optimization calculations, so it may take a few seconds to run.

Examples

  # Input rescaler
  rlin <- rescaler_x(c(0.25, 0.75))

  # print for a preview
  print(rlin)
#> Rescaler function:
#>    input: 0.000 0.200 0.400 0.600 0.800 1.000 
#>   output: 0.250 0.350 0.450 0.550 0.650 0.750 

  # evaluate
  rlin(c(0, 0.5, 1))
#> [1] 0.25 0.50 0.75

  # Luminance rescaler
  pal_luv_blues <- pal_luv_bezier(mat_luv_blues)
  rlum <- rescaler_lum(c(40, 70), pal_luv_blues)

  # print for a preview
  print(rlum)
#> Rescaler function:
#>    input: 0.000 0.200 0.400 0.600 0.800 1.000 
#>   output: 0.257 0.322 0.386 0.451 0.516 0.580 

  # evaluate
  rlum(c(0, 0.5, 1))
#> [1] 0.2569183 0.4187022 0.5804860