Newly tracked file
R/mesh_pal.R
created.
R/image_pal.R
changed.
Other files ignored by Codecov
NAMESPACE
has changed.
DESCRIPTION
has changed.
1 | + | .quad_to_edge <- function(x) { |
|
2 | + | if (is.null(x)) return(NULL) |
|
3 | + | cbind(x[1:2, ], x[2:3, ], x[c(3, 1)]) |
|
4 | + | } |
|
5 | + | .tri_to_edge <- function(x) { |
|
6 | + | if (is.null(x)) return(NULL) |
|
7 | + | cbind(x[1:2, ], x[2:3, ], x[3:4, ], x[c(4, 1), ]) |
|
8 | + | ||
9 | + | } |
|
10 | + | ||
11 | + | mesh_pal <- function(x, col, ..., meshColor = NULL, pal_dim = 3L) { |
|
12 | + | if (missing(col)) { |
|
13 | + | col <- hcl.colors(24) |
|
14 | + | } |
|
15 | + | if (is.null(meshColor)) { |
|
16 | + | meshColor <- x$meshColor |
|
17 | + | } |
|
18 | + | scl <- function(x) { |
|
19 | + | x <- c(x) |
|
20 | + | x <- x[!is.na(x)] |
|
21 | + | (x - min(x))/diff(range(x)) |
|
22 | + | } |
|
23 | + | ||
24 | + | idx <- TRUE |
|
25 | + | if (meshColor == "faces") { |
|
26 | + | idx <- c(x$it, x$ib) |
|
27 | + | out <- col[1 + scl(x$vb[pal_dim, idx]) * length(col)] |
|
28 | + | ||
29 | + | } |
|
30 | + | if (meshColor == "edges") { |
|
31 | + | idx <- c(.tri_to_edge(x$it), .quad_to_edge(x$ib)) |
|
32 | + | ||
33 | + | out <- col[1 + scl(colMeans(matrix(x$vb[pal_dim, idx], 2))) * length(col)] |
|
34 | + | } |
|
35 | + | ## else vertices |
|
36 | + | out |
|
37 | + | } |
Files | Coverage |
---|---|
R | 94.33% |
Project Totals (6 files) | 94.33% |