clpalettes: Retrieve color palette or palettes

Description Usage Arguments Details Value Author(s) References Examples

View source: R/clpalettes.r

Description

Retrieve a color palette or set of palletes from the COLOURlovers API.

Usage

1
2
3
clpalette(id, widths = FALSE, fmt = 'xml')

clpalettes(set = NULL, ..., fmt = 'xml')

Arguments

id

The COLOURlovers id (an integer) for a specific palette.

widths

A boolean indicating whether to include the color widths for the palette. Default is FALSE.

set

Optionally, a subset of COLOURlovers palettes. Allowed values are “new”, “top”, and “random”.

...

A named list of parameters passed to the API request. Allowed parameters are lover, hueOption, hex, hex_logic, keywords, keywordsExact, orderCol, sortBy, numResults, and resultOffset. Specifying orderCol overrules any argument to set. See details.

fmt

A format for the API response, one of “xml” (the default) or “json”. This has essentially no effect on function behavior.

Details

Retrieve details about a palette or set of palettes.

Specifying named arguments to ... allows the user to request a specific response, as follows:

lover: A character string containing a COLOURlovers username.

hueOption: A character vector containing one or more named hues to search by. Allowed values are: “red”, “orange”, “yellow”, “green”, “aqua”, “blue”, “violet”, “fuchsia”. Any other values other than these named colors will be ignored.

hex: A character vector containing up to five colors specified as hexidecimal representation (with or without a leading hash symbol). Excess colors will be ignored.

hex_logic: A character value containing either “AND” (the default) or “OR”, for whether the values in hex should be searched for with a boolean AND versus OR logic. Specifying “AND” will only return palettes with all requested colors.

keywords: A character string containing one or more keywords to search by.

keywordsExact: A boolean indicating search on keywords should be exact (TRUE) or not (FALSE, the API default).

orderCol: A character string containing a sort criterion. One of “dateCreated”, “score”, “name”, “numVotes”, “numViews”.

sortBy: A character string containing either “ASC” (for ascending by the orderCol criterion, the default) or “DSC” (for descending).

numResults: A numeric value indicating the number of results to return, with a maximum of 100. Default is 20.

resultOffset: A numeric value indicating the page of results to return, with page size specified in the numResults argument.

Value

A list of class “clpalette”. This should be the same regardless of the value of fmt.

Author(s)

Thomas J. Leeper

References

http://www.colourlovers.com/api/#palettes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
e <- function(e) NULL # function for tryCatch to fail in examples

# get a random palette
tryCatch( clpalettes('random'), error = e)

# download top palettes
tryCatch( clpalettes('top', fmt='json'), error = e)

# plot at a single palette
pid <- '113451'
p <- tryCatch( clpalette(pid, fmt='json'), error = e)
if(!is.null(p)) plot(p)

leeper/colourlovers documentation built on April 9, 2018, 10:11 p.m.