Giter Club home page Giter Club logo

simple-rgb's Introduction

SIMPLE-RGB

This library was designed to be used by another library which generates SVG files. It is currently focused on the small set of basic color manipulations (lightening, compliments, etc) you might use to generate a color palette for a GUI or web page.

(March 2019) The current all-singing, all-dancing color manipulation library is Dufy, which you should consider if you have serious color manipulation needs.

Package

The package name is :simple-rgb, with a single nickname, :rgb.

It depends on no other libraries, but you will need LIFT to run the unit tests.

Conditions and Restarts

[condition]
hsv-type-error
This condition is raised by hsv if any of the three values passed to it falls outside the range 0.0 through 1.0.

There are no restarts.

Functions

[function]
rgb r g b => rgb-vector
This is the only way to create a literal RGB value the rest of the library will accept. Each color element is an integer between 0 and 255. Anything outside this range, or of a non-integer type, will raise a type-error condition.

[function]
rgb= a b => boolean
Tests RGB equality.

[function]
hsv h s v => hsv-vector
This is the only way to create a literal HSV value the rest of the library will accept. Each of the values has to be a float between 0.0 and 1.0. A range or type problem will result in a hsv-type-error condition being raised.

Note that some HSV libraries represent the h element in degrees. This one does not.

[function]
mix-rgb a b &key (alpha 0.5) => rgb-vector
Blends two RGB colors. By default the mix is even, but by setting the :alpha keyword you can weight the mix, with 0.0 simply returning the first argument, 1.0 the second.

[function]
lighten-rgb a => rgb-vector
Lightens a color by mixing it with white with an alpha of 0.5. For different shading use mix-rgb directly.

[function]
darken-rgb a => rgb-vector
Darkens a color by mixing it with black with an alpha of 0.5. For different shading use mix-rgb directly.

[function]
greyscale-rgb a => rgb-vector
Converts a color to greyscale by setting each color element to the value 0.3r + 0.59g + 0.11b. See: Grayscale.

[function]
invert-rgb a => rgb-vector
Inverts a color.

[function]
complement-rgb a => rgb-vector
Creates the complement of the color using the forumla described at Adobe.

[function]
rgb->hsv a => hsv-vector
Converts an RGB value to HSV.

[function]
hsv->rgb a => rgb-vector
Converts and HSV value to RGB.

[function]
rotate-hsv a rotation => hsv-vector
Rotates the hue of a HSV color. The rotation is expressed in degrees, rather than the 0.0-1.0 range used by the rest of the library. Creating palettes of complimentary and contrasting colors is often thought of in terms of rotating a color wheel, and I've used degrees here since that's more natural for me, at least, to think about.

[function] rotate-rgb a rotation => rgb-vector
This convenience function is equivalent to:

(hsv->rgb (rotate-hsv (rgb->hsv a) rotation))

[function]
xmlify-rgb a &optional (stream nil) => x/html-color-string
Turns an RGB value into a string of the form #FFAADD. Optionally you can specify a stream designator of the sort format expects. By default it returns the string.

[function]
parse s => rgb-vector This converts an HTML color string into an RGB value.

simple-rgb's People

Contributors

bnmcgn avatar wmannis avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simple-rgb's Issues

Make functions inlineable

I would like to depend on simple-rgb in a place that requires hue-shifting RGB colors with high performance, therefore I would like to be able to locally inline the code for the relevant functions.

Please make rgb->hsv, hsv->rgb, rotate-hsv and rotate-rgb locally inlineable as per the CLHS example noted below.


The CLHS says:

To define a function f that is not inline by default but for which (declare (inline f)) will make f be locally inlined, the proper definition sequence is:

(declaim (inline f))
(defun f ...)
(declaim (notinline f))

Misnamed function COMPLIMENT-RGB

The function COMPLIMENT-RGB actually implements the "complement" 
procedure.  It should be renamed COMPLEMENT-RGB for correctness.

Attached is a patch affecting package.lisp, rgb.lisp and test-rgb.lisp to 
this effect.

As a precedent, note the use of "complement" in the Adobe docs 
http://livedocs.adobe.com/en_US/Illustrator/13.0/help.html?content=WS714a382cdf7
d304e7e07d0100196cbc5f-6288.html

Original issue reported on code.google.com by [email protected] on 30 Aug 2008 at 5:19

Attachments:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.