Wednesday, February 28, 2007

Colornitpicking


One of the basic things I want to do with the visual editor/composer is instant easy-to-grok visual changes, for instance choosing _just_ the right sublime background color for an element.

Recently I had been using the rather plain colorpicker in the current dojo branch. Not incredibly simple to use (but OK, what the hey. It's no TreeV3, so who am I to complain?) but lacking in choices. After that I found a colorpicker with a larger variety of colors to choose from, but still it wasn't enough.

Then I saw what I knew I had wanted all along, a 'photoshop' style colorpicker. In Javascript.

The first one I found was NoFunc's DHTML ColorPicker, at http://www.nofunc.com/DHTML_Color_Picker/ which is lightning fast and the closest thing to assembler I've ever seen done in Javascript. I tried hard for over two days to make an infotron blueprint out of it, but it was just over my horizon. Go ahead. Check the source. make my day :)

The second stop was a completely wonderful article at webreference.com called "How to create a color picker in javascript". It's really well written and it produces the above result, and then some. Read it at its entirety at http://www.webreference.com/programming/javascript/mk/column3/index.html

I had to undo some rather advanced stuff that mark Kahn, the author, had done to speed up things a bit (a micro- templating engine which stored a cached copy of elements) to make it work. Maybe I'll redo it when I'm smart enough :)

Anyway, the point is that I know have a nearly-correct (I've broken the "minitoolbar" functionality somehow) Industrial strength colorpicker for all created elements in the editor, and that feels just great.

No comments: