Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add palette capabilities: may_return_NA, accepts_native_output #372

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

zeehio
Copy link
Contributor

@zeehio zeehio commented Nov 6, 2022

This pull request (on top of #371) extends the definition of a palette by adding attributes to the palette function.

These attributes may be ignored if you don't care for them, but they can be used by the palette consumer (e.g. ggplot2) to be faster.

We define two new attributes on colour_ramp, gradient_n_pal, div_gradient_pal and seq_gradient_pal.

  • may_return_NA: If this attribute is set to FALSE, the palette consumer can safely assume that the palette won't return missing values (therefore skipping any check).
  • accepts_native_output: if this attribute is set to TRUE, the palette consumer can safely assume that the palette accepts an additional keyword argument named color_fmt which can take two values: "character" and "native". The palette consumer can call the palette with color_fmt = "native" to get colours in native format (as used in nativeRaster objects). The palette consumer can avoid the intermediate character representation of colours.

This is related to:

Proposed NEWS entry:

 * `colour_ramp`, `gradient_n_pal`, `div_gradient_pal` and `seq_gradient_pal` -based palettes 
   include additional attributes to let its user know that they are able to output colours in native
   format and whether or not they return missing values (#372, @zeehio)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant