SymbolixAU / mapdeck
1

2
isHexColour <- function(cols){
3 1
  hexPattern <- "^#(?:[0-9a-fA-F]{3}){1,2}$|^#(?:[0-9a-fA-F]{4}){1,2}$"
4 1
  all(grepl(hexPattern, cols))
5
}
6

7
appendAlpha <- function( col ) {
8 1
	if( isHexColour( col ) ) {
9 1
		col <- unname(
10 1
			vapply(col, function(x) {
11 1
				ifelse(
12 1
					nchar(x) == 4
13 1
					, paste0(x, "F")
14 1
					, ifelse(
15 1
						nchar(x) == 7
16 1
						, paste0(x, "FF")
17 1
						, x
18
						)
19
					)
20
				},"" )
21
		)
22
	}
23 1
	return( col )
24
}

Read our documentation on viewing source code .

Loading