Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#1413 closed enhancement (fixed)

Allow 360/100/100 input for dojo.gfx.color.hsv2rgb

Reported by: [email protected] Owned by: Tom Trenka
Priority: high Milestone:
Component: General Version: 0.3
Keywords: Cc:
Blocked By: Blocking:


This patch allows other input/output ranges for the HSV values passed in to dojo.gfx.color.hsv.

I work on the Web UI for the Cosmo calendaring project at OSAF (I've submitted some patches through Adam Peller), and the colors swatches for various calendars in the UI have to be programmatically generated according to a specific set of hues. Both Photoshop and GIMP use 0-360 for hue, and 0-100 ranges for saturation and value, but dojo.gfx.color.hsv2rgb uses 0-255 for all of them.

This patch allows you to pass in an object with input/output range options so you can do input in 360/100/100, 360/1.0/1.0, etc. You can also have it output the RGV values as a percent or a decimal number. The opts object works like this:

{ 'inputRange': [360, 100, 100] }

{ 'inputRange': [360, 100, 100], 'outputRange': 100 }

{ 'inputRange': [360, 1, 1], 'outputRange': 100 }

You can pass an inputRange, an outputRange, or both. The default with no opts parameter is still 255/255/255 outputting to 255.

I'm happy to write a bunch of tests to confirm the output, and also to write the reverse for rgb2hsv, but I just wanted to see first if the approach of passing in options like this is something y'all are interested in.

Attachments (1)

dojo_gfx_color_hsv-mde-20060907.patch (2.1 KB) - added by [email protected] 15 years ago.
Patch for dojo.gfx.color.hsv2rgb

Download all attachments as: .zip

Change History (3)

Changed 15 years ago by [email protected]

Patch for dojo.gfx.color.hsv2rgb

comment:1 Changed 15 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

Merged with modifications.

comment:2 Changed 15 years ago by Tom Trenka

Resolution: fixed

(In [5558]) Fixes #1413 with modifications and typo corrections to the patch.

Note: See TracTickets for help on using tickets.