Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Create a color scale from a single color

NotificationsYou must be signed in to change notification settings

dreamRs/colorscale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R6 api forchroma.js & an RStudio add-in to create a color scale from a single color.

Lifecycle: experimentalR build statusTravis build status

Installation

Install development version from GitHub with:

remotes::install_github("dreamRs/colorscale")

RStudio add-in

An add-in to create a color palette from a single color (largely inspired byhttps://github.com/hihayk/scale).

To launch the gadget use the "Addins" menu in RStudio or:

colorscale::addin_color_scale()

chroma.js API

Create a R6 class to access chroma.js methods:

library(colorscale)ch<-chroma$new("hotpink")ch$darken(2)ch$eval()#> [1] "#930058"hsl<-chroma$new()hsl$chroma.hsl(330,1,0.6)view_cols(hsl$eval())hsl$darken(seq(0.2,3,0.2))view_cols(hsl$eval())

Some methods have wrapper for easier use:

# Mixes two colorschroma_mix(color1="red",color2="blue")#> [1] "#800080"# Average between colorschroma_avg(colors= c("#ddd","yellow","red","teal"))#> [1] "#b79757"# Random colorschroma_random()#> [1] "#650a0c"chroma_random(10)#> [1] "#63e24b" "#909363" "#5a3d7d" "#41a505" "#8f5f13" "#df6535" "#da43d3" "#04fc8f" "#6ee31c" "#ac5c94"# Euclidean distance between two colorschroma_distance("#fff","#ff0")#> [1] 96.94758chroma_distance("#fff","#ff0","rgb")#> [1] 255

Convert color to specific color space:

ch<-chroma$new("orange")ch$hex()#> [1] "#ffa500"ch$rgb()#> [1] 255 165   0ch$hsl()#> [1] 38.82353  1.00000  0.50000ch$lab()#> [1] 74.93565 23.93317 78.94978ch$gl()#> [1] 1.0000000 0.6470588 0.0000000 1.0000000ch$css()#> [1] "rgb(255,165,0)"

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp