Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Safia Saci
rosePigs
Commits
35b2313b
Commit
35b2313b
authored
Jun 07, 2021
by
Safia Saci
Browse files
Upload New File
parent
2302d566
Changes
1
Hide whitespace changes
Inline
Side-by-side
meanColors.R
0 → 100644
View file @
35b2313b
#' mean_color
#'
#' @param mycolors vector of colors
#'
#' @return a color
#'
#' @examples
#' mean_color(c("#000000FF", "#FFFFFFFF", "#FFFF00FF", "#FF0000FF"))
#'
#'
mean_color
<-
function
(
mycolors
)
{
R
<-
strtoi
(
x
=
substr
(
mycolors
,
2
,
3
),
base
=
16
)
G
<-
strtoi
(
x
=
substr
(
mycolors
,
4
,
5
),
base
=
16
)
B
<-
strtoi
(
x
=
substr
(
mycolors
,
6
,
7
),
base
=
16
)
alpha
<-
strtoi
(
x
=
substr
(
mycolors
,
8
,
9
),
base
=
16
)
return
(
grDevices
::
rgb
(
red
=
round
(
mean
(
R
)),
green
=
round
(
mean
(
G
)),
blue
=
round
(
mean
(
B
)),
alpha
=
round
(
mean
(
alpha
)),
maxColorValue
=
255
)
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment