cheap_darken | R Documentation |
Helper functions to generate a “light” effect
for oblicubesGrob()
, grid.oblicubes()
, oblicuboidsGrob()
, and grid.oblicuboids()
.
darken_face()
is the default light
argument for oblicubesGrob()
, grid.oblicubes()
,
oblicuboidsGrob()
, and grid.oblicuboids()
.
cheap_darken()
is the default darkening function used by darken_face()
.
cheap_darken(col, amount) darken_face( face, col, top = 0, west = 0.2, east = 0.2, south = 0.4, north = 0.4, darken_fn = cheap_darken )
col |
Vector of colors to darken |
amount |
Fraction to darken by |
face |
Cube/cuboid face to color. One of "top", "west", "east", "south", or "north". |
top |
Amount to darken the "top" face. |
west |
Amount to darken the "west" face. |
east |
Amount to darken the "east" face. |
south |
Amount to darken the "south" face. |
north |
Amount to darken the "north" face. |
darken_fn |
Function to darken with. Should take two arguments:
the first should be the colour and the second should be numeric amount to darken by.
Default will be to use |
The light
argument of oblicubesGrob()
, grid.oblicubes()
, geom_oblicubes()
,
oblicuboidsGrob()
, grid.oblicuboids()
, and geom_oblicuboids()
needs a function that that takes two arguments: the first is face
one of its five faces:
"top", "west", "east", "south", or "north" and the second is col
the cube/cuboid's fill color
Vector of darkened colors.
demo_light <- function(light = darken_face, ...) { df <- data.frame(x=1, y=1, z=1) grid::grid.newpage() grid.oblicubes(df, ..., light=light, angle=45, lwd=4, vp = grid::viewport(0.25, 0.25, 0.5, 0.5)) grid.oblicubes(df, ..., light=light, angle=135, lwd=4, vp = grid::viewport(0.75, 0.25, 0.5, 0.5)) grid.oblicubes(df, ..., light=light, angle=-45, lwd=4, vp = grid::viewport(0.25, 0.75, 0.5, 0.5)) grid.oblicubes(df, ..., light=light, angle=-135, lwd=4, vp = grid::viewport(0.75, 0.75, 0.5, 0.5)) } demo_light() demo_light(fill = "gold") demo_light(light = function(face, col) darken_face(face, col, top = 0.3, west = 0.6, east = 0.6, south = 0.0, north = 0.0) ) demo_light(light = function(face, col) { n <- length(col) switch(face, top = rep_len("grey90", n), west = rep_len("red", n), east = rep_len("green", n), south = rep_len("blue", n), north = rep_len("yellow", n)) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.