-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathggblend-package.R
62 lines (62 loc) · 1.87 KB
/
ggblend-package.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#' Blending and compositing for ggplot2
#'
#' @docType package
#' @name ggblend-package
#' @aliases ggblend
#'
#' @description
#'
#' \pkg{ggblend} is an R package that adds support for R 4.2 blend modes
#' (e.g. `"multiply"`, `"overlay"`, etc) to \pkg{ggplot2}.
#'
#' @details
#'
#' The primary support for blending is provided by the `blend()` function,
#' which can be used to augment [ggplot()] layers/geoms or lists of
#' layers/geoms in a [ggplot()] specification.
#'
#' For example, one can replace something like this:
#'
#' ```
#' df |>
#' ggplot(aes(x, y)) +
#' geom_X(...) +
#' geom_Y(...) +
#' geom_Z(...)
#' ```
#'
#' With something like this:
#'
#' ```
#' df |>
#' ggplot(aes(x, y)) +
#' geom_X(...) +
#' geom_Y(...) |> blend("multiply") +
#' geom_Z(...)
#' ```
#'
#' In order to apply a "multiply" blend to the layer with `geom_Y(...)`.
#'
#' @section Package options:
#'
#' The following global options can be set using [options()] to modify the
#' behavior of \pkg{ggblend}:
#'
#' - `"ggblend.check_blend"`: If `TRUE` (default), [blend()] will warn if
#' you attempt to use a blend mode not supported by the current graphics
#' device, as reported by `dev.capabilities()$compositing`. Since this check
#' can be unreliable on some devices (they will report not support a blend
#' mode that they do support), you can disable this warning by setting this
#' option to `FALSE`.
#'
#' - `"ggblend.check_affine_transform"`: If `TRUE` (default), [affine_transform()] will warn if
#' you attempt to use a blend mode not supported by the current graphics
#' device, as reported by `dev.capabilities()$transformation`. Since this check
#' can be unreliable on some devices (they will report not support a blend
#' mode that they do support), you can disable this warning by setting this
#' option to `FALSE`.
#'
#' @import grid
#' @import ggplot2
#' @import methods
NULL