Title: | R Client for the COLOURlovers API |
---|---|
Description: | Provides access to the COLOURlovers <https://www.colourlovers.com/> API, which offers color inspiration and color palettes. |
Authors: | Andrew Heiss [aut, cre] , Thomas J. Leeper [aut] |
Maintainer: | Andrew Heiss <[email protected]> |
License: | GPL-2 |
Version: | 0.3.6 |
Built: | 2024-11-11 04:14:33 UTC |
Source: | https://github.com/andrewheiss/colourlovers |
Provides access to the COLOURlovers API for accessing colors and color palettes for use in R graphics.
Thomas J. Leeper
Retrieve a color or set of colors from the COLOURlovers API.
clcolors(set = NULL, ..., fmt = "xml") clcolor(hex, fmt = "xml")
clcolors(set = NULL, ..., fmt = "xml") clcolor(hex, fmt = "xml")
set |
Optionally, a subset of COLOURlovers colors. Allowed values are “new”, “top”, and “random”. |
... |
A named list of parameters passed to the API request. Allowed
parameters are |
fmt |
A format for the API response, one of “xml” (the default)
or “json”. This has essentially no effect on function behavior.
@return A list of class “clcolor”. This should be the same regardless
of the value of |
hex |
The six-character hexidemical representation of a single color. |
Retrieve details about a color our set of colors.
Specifying named arguments to ...
allows the user to request a
specific response, as follows:
lover
: A character string containing a COLOURlovers username.
hueRange
: A two-element numeric vector containing the upper and lower
bounds of a hue range. Allowed values are between 0 and 359, exclusive.
briRange
: A two-element numeric vector containing the upper and lower
bounds of a brightness range. Allowed values are between 0 and 99,
exclusive.
keywords
: A character string containing one or more keywords to
search by.
keywordExact
: 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.
Thomas J. Leeper
http://www.colourlovers.com/api/#colors
## Not run: # Get a random color clcolors('random') # Get a single color clcolor('6B4106') # Plot a single color clcolor(rgb(0,0,1), fmt = 'json') ## End(Not run)
## Not run: # Get a random color clcolors('random') # Get a single color clcolor('6B4106') # Plot a single color clcolor(rgb(0,0,1), fmt = 'json') ## End(Not run)
Retrieve a lover (user) or set of lovers from the COLOURlovers API.
cllovers(set = NULL, ..., fmt = "xml") cllover(user, comments = FALSE, fmt = "xml")
cllovers(set = NULL, ..., fmt = "xml") cllover(user, comments = FALSE, fmt = "xml")
set |
Optionally, a subset of COLOURlovers palettes. Allowed values are “new” and “top”. |
... |
A named list of parameters passed to the API request. Allowed
parameters are |
fmt |
A format for the API response, one of “xml” (the default) or “json”. This has essentially no effect on function behavior. |
user |
The COLOURlovers username for a specific user. |
comments |
A boolean indicating whether to include the last ten
comments for the user. Default is |
Retrieve details about a COLOURlovers user or users.
Specifying named arguments to ...
allows the user to request a
specific response, as follows:
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.
A list of class “cllover”, including details about one or
more users. This should be the same regardless of the value of fmt
.
Thomas J. Leeper
http://www.colourlovers.com/api/#lovers
## Not run: # Retrieve top users cllovers(set = 'top', fmt = 'json') # Retrieve a single user cllover('COLOURlovers', fmt = 'json') ## End(Not run)
## Not run: # Retrieve top users cllovers(set = 'top', fmt = 'json') # Retrieve a single user cllover('COLOURlovers', fmt = 'json') ## End(Not run)
Retrieve a color palette or set of palletes from the COLOURlovers API.
clpalettes(set = NULL, ..., fmt = "xml") clpalette(id, widths = FALSE, fmt = "xml")
clpalettes(set = NULL, ..., fmt = "xml") clpalette(id, widths = FALSE, fmt = "xml")
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 |
fmt |
A format for the API response, one of “xml” (the default) or “json”. This has essentially no effect on function behavior. |
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 |
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.
keywordExact
: 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.
A list of class “clpalette”. This should be the same
regardless of the value of fmt
.
Thomas J. Leeper
http://www.colourlovers.com/api/#palettes
## Not run: # Get a random palette clpalettes('random') # Download top palettes clpalettes('top', fmt = 'json') # Plot a single palette pid <- '113451' p <- clpalette(pid, fmt = 'json') plot(p) ## End(Not run)
## Not run: # Get a random palette clpalettes('random') # Download top palettes clpalettes('top', fmt = 'json') # Plot a single palette pid <- '113451' p <- clpalette(pid, fmt = 'json') plot(p) ## End(Not run)
Retrieve a pattern or set of patterns from the COLOURlovers API.
clpatterns(set = NULL, ..., fmt = "xml") clpattern(id, fmt = "xml")
clpatterns(set = NULL, ..., fmt = "xml") clpattern(id, fmt = "xml")
set |
Optionally, a subset of COLOURlovers patterns. Allowed values are “new”, “top”, and “random”. |
... |
A named list of parameters passed to the API request. Allowed
parameters are |
fmt |
A format for the API response, one of “xml” (the default) or “json”. This has essentially no effect on function behavior. |
id |
The COLOURlovers id (an integer) for a specific pattern. |
Retrieve details about a pattern or set of patterns.
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.
keywordExact
: 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.
A list of class “clpattern”. This should be the same
regardless of the value of fmt
.
Thomas J. Leeper
http://www.colourlovers.com/api/#patterns
## Not run: # Get a random pattern clpatterns('random') # Plot a single pattern p <- clpattern('1451', fmt = 'json') plot(p) ## End(Not run)
## Not run: # Get a random pattern clpatterns('random') # Plot a single pattern p <- clpattern('1451', fmt = 'json') plot(p) ## End(Not run)
Plot a color, palette, or pattern color pie or PNG image in a plotting device
clpng(x, ask = TRUE, ...) clpie(x, ask = TRUE, ...) ## S3 method for class 'clcolor' plot(x, type = "png", ...)
clpng(x, ask = TRUE, ...) clpie(x, ask = TRUE, ...) ## S3 method for class 'clcolor' plot(x, type = "png", ...)
x |
A colourlovers color, palette, or pattern object. |
ask |
A boolean indicating if plots should be presented interactively
or all at once (default is |
... |
Ignored. |
type |
One of “png” (the default) or “pie”. |
Plot a colourlovers PNG image in a new plotting window.
The x
object is invisibly returned.
Thomas J. Leeper
## Not run: # Plot a color clpng co <- clcolor(rgb(0, 0, 1)) plot(co) # Plot a pattern clpng p <- clpattern('1451') plot(p) clpng(p) # Plot colors from a palette p <- clpalette('113451') plot(p, type = 'pie') clpie(p) # Plot multiple palettes (interactively) p <- clpalettes('top') plot(p) # PNG images plot(p, type = 'pie') # pie chart swatches ## End(Not run)
## Not run: # Plot a color clpng co <- clcolor(rgb(0, 0, 1)) plot(co) # Plot a pattern clpng p <- clpattern('1451') plot(p) clpng(p) # Plot colors from a palette p <- clpalette('113451') plot(p, type = 'pie') clpie(p) # Plot multiple palettes (interactively) p <- clpalettes('top') plot(p) # PNG images plot(p, type = 'pie') # pie chart swatches ## End(Not run)
Primarily an internal function for executing API calls.
clquery(type, set = NULL, query = NULL, fmt = "xml", ...)
clquery(type, set = NULL, query = NULL, fmt = "xml", ...)
type |
An API type. One of “colors”, “palettes”, “patterns”, “lovers”, or “stats”. |
set |
A further subtype of the API |
query |
An optional character string specifying additional query parameters. |
fmt |
A format for the API response, one of “xml” (the default) or “json”. |
... |
Ignored. |
Primarily for internal use.
A list reflecting the API response. This should be the same
regardless of the vale of fmt
.
Thomas J. Leeper
Retrieve basic statistics from the COLOURlovers API.
clstats(type, fmt = "xml")
clstats(type, fmt = "xml")
type |
An API type. One of “colors”, “palettes”, “patterns”, or “lovers”. |
fmt |
A format for the API response, one of “xml” (the default) or “json”. This has essentially no effect on function behavior. |
Retrieve total numbers of colors, palettes, patterns, or lovers.
A numeric value of class “clstats”. This should be the same
regardless of the value of fmt
.
Thomas J. Leeper
http://www.colourlovers.com/api/#stats
## Not run: clstats('colors') clstats('palettes') clstats('patterns') clstats('lovers') ## End(Not run)
## Not run: clstats('colors') clstats('palettes') clstats('patterns') clstats('lovers') ## End(Not run)
Extract a list of colors from a COLOURlovers object
swatch(x, ...)
swatch(x, ...)
x |
A colourlovers color, palette, or pattern object. |
... |
Ignored. |
Extract color(s) from a colourlovers object.
A list of character vectors containing hexidecimal representations of colors.
Thomas J. Leeper
## Not run: # Get top colors swatch(clcolors('top')) # Get colors from a specific palette swatch(clpalette('113451')) # Get colors from specific pattern swatch(clpattern('1451')) ## End(Not run)
## Not run: # Get top colors swatch(clcolors('top')) # Get colors from a specific palette swatch(clpalette('113451')) # Get colors from specific pattern swatch(clpattern('1451')) ## End(Not run)