View
 

Color Library

Page history last edited by Mark Gibson 2 mos ago

 

type: utility

release: 0.0

priority: low

status: in development

documentation: http://www.adaptavist.com/display/jQuery/Colour+Library

demo: http://www.adaptavist.com/display/jQuery/Colour+Library+Demo

 

 


 

1 - Description:

 

A common set of functions for colour manipulation, that should be utilitised by UI widgets wherever required, and also for use independently of the UI core.

 

The ColorPicker widget will require a set of  functions for parsing, and writing CSS colour definitions, as well as convertions between colour spaces (ie. RGB, HSV, HSL, etc).

 

The Effects core uses a set of colour related functions internally, these could be promoted into this library for re-use elsewhere. 

 


 

2 - Visual Design:

 

N/A

 


 

 

3 - Functional Specifications/Requirements:

 

(Detailed description of how the script will be structured: defaults, options, architecture, extensibility, etc.)

 


 

4 - Markup & Style:

 

    N/A

 


 

5 - Latest version of plugin:

 

The current development efforts for this have been moved to github:

 

http://github.com/jollytoad/jquery.color

 


 

6 - Open issues being discussed

 

  • Should all values be normalized to floating point 0..1 range?
    • I believe it makes sense for Hue, Saturation, Lightness, Value, and Alpha channels.
    • What about Red, Green and Blue, usually these are 0..255, but internal workings could be greatly simplified by also normalizing to 0..1 - and using 0..255 range just for parsing or writing.
    • The current implementation use floating point 0..1 for HSV & Alpha, and integer 0..255 for RGB.

 

  • How should we represent a colour?
    • Array of channel values (eg [1,0,0])?
    • An object that extends an Array?
    • An object with properties named for each channel?
    • The implementation uses an array of channel values - known as a colour tuple - channel values are retrieved using standard array syntax.

 

  • Should we use methods or functions?
    • $.color.RGBtoHSV([1,0,0]), $.color.toHex([1,0,0])
    • $.Color('#fff').toHSV(), $.Color([1,0,0]).toString('hex')
    • BOTH! The implementation defines functions in colour space namespaces (eg. jQuery.color.RGB) for use with colour tuples, AND a jQuery.Color object that sits on top of these.

 

 

 

 

Comments (5)

profile picture

Carsten Klein said

at 1:13 pm on Aug 13, 2009


please also support quadruples as the color value, including the alpha transparency for a given color.

see my comment @ color picker for some more info

profile picture

Mark Gibson said

at 5:00 am on Aug 27, 2009

The current library already supports this for all of the implement colour spaces (ie RGB, HSV). See the docs for more details: http://www.adaptavist.com/display/free/jQuery+Colour+Library

profile picture

Carsten Klein said

at 1:14 pm on Aug 13, 2009

please also implement named properties for the set of components of a given color, i.e. .red, .green, .blue, .alpha etc.

profile picture

Mark Gibson said

at 5:14 am on Aug 27, 2009

The colour tuples have a fixed order, so i'm not sure this is entirely necessary as it would just add extra complication and overhead - ie. having to set the properties and maintain the properties - if getter/setter overrides were supported in all browser this would be easy - but they aren't. Instead we could introduce getter methods, eg: $.Color('#fff').red();
This would have the added advantage of the automatic colour space conversion, so you could extract any component regardless of the colour space.

profile picture

gero3 said

at 1:33 pm on Nov 20, 2009

i am adding full support for Hsl on my repo on github

will try to add setter and getter methods like html does it

You don't have permission to comment on this page.