 |
|
 |
Palette |
|
|
| CSM |
Oct 26 2008, 01:17 AM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
Someone showed me an online color picker one day (from somewhere that they copied and ran on their own server). My first question was "Is it Canvas?" and after investigation "No. Fail." which prompted a "Could you even create one in Canvas?" So, you probably know at this point what I spent my time trying to do ... My final result can be seen here: Canvas Color ChooserYou can drag the mouse inside the single-hue gradient area, as well as click, but because the update process for that area is slightly slower, you can only click inside the hue gradient area. Now, with that said, I'm also a Widget developer, and save for using new Frame() instead if document.createElement("div") and using onMouseUp instead of onmouseup ... the code is essentially the same! So you can guess what I did ... Download PaletteIt is as simple looking as the online version, and it also resets each time the Widget is loaded (just like the browser). The code for colorbox.js is slightly different (major difference: having to use onMouseDrag instead of the mash of 3 events in the browser). The color js files are the same. They were taken from the latest JwL source and edited to make them more efficient for creating loads of them. There are already color-chooser based apps on the web and in the gallery, but this is the first I know of to use Canvas!
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
| g6auc |
Oct 26 2008, 03:58 PM
|

Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322

|
QUOTE(CSM @ Oct 26 2008, 01:17 AM)  It is as simple looking as the online version, and it also resets each time the Widget is loaded (just like the browser). Very nice, but the widget version has a few blemishes. When I type data into the fields and press RETURN/ENTER, the data appears to disappear, I assume because the RETURN is not being rejected. Also, the Hex field will not allow the alphabetic hex digits to be input. The fields do not update as the other fields are changed. This on Mac OS X 10.4.11 and K 4.5.2x10A50.
|
|
|
|
|
| CSM |
Oct 26 2008, 08:38 PM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
QUOTE(g6auc @ Oct 26 2008, 10:58 AM)  Very nice, but the widget version has a few blemishes.  Thanks. I figured there'd be at least a few, given the more than slight difference between the browser's forms and Y!WE's widgets. QUOTE(g6auc @ Oct 26 2008, 10:58 AM)  When I type data into the fields and press RETURN/ENTER, the data appears to disappear, I assume because the RETURN is not being rejected. It should be, I use single line text areas (I set the lines property to 1). I guess I could reject the key-press just in case. QUOTE(g6auc @ Oct 26 2008, 10:58 AM)  Also, the Hex field will not allow the alphabetic hex digits to be input. Oops. Yeah, I'll fix that. QUOTE(g6auc @ Oct 26 2008, 10:58 AM)  The fields do not update as the other fields are changed. Hm? All fields should update themselves appropriately after enter is pressed in one field. If I tried to update on the key-press, the slowness of updating the hue-gradient field would bite me. However, I'll look into seeing if the fields don't update at all.
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
| CSM |
Oct 26 2008, 09:07 PM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
Okay, I hope I fixed all the above bugs and uploaded it. Also, because the fields are all updated when you hit enter in one of the fields, that current field may update (and be different) due to rounding/floor errors. So to reduce that, I added a size option, and if you choose "large" the color picker will resize itself to 360 pixels, shifting the rounding errors off of the "hue" value.* The only way to prevent any rounding errors would be a board size of 3600 pixels ... too large for a Widget.
* Before, typing #ff00cc into the hex field would get it changed to #ff00d0, as hue is out of 360, and saturation and value are out of 100 (which the previously default board was a multiple of). With a board size of 360 pixels, the saturation and value will have floor/rounding errors, but the hex will now return what you typed in (or at least it should).
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
| g6auc |
Oct 26 2008, 10:53 PM
|

Posts: 4,265
Joined: 1-March 04
From: West Yorkshire, UK
Member No.: 2,322

|
QUOTE(CSM @ Oct 26 2008, 09:07 PM)  ... and if you choose "large" the color picker will resize itself to 360 pixels, shifting the rounding errors off of the "hue" value.* The only way to prevent any rounding errors would be a board size of 3600 pixels ... too large for a Widget.
...but the hex will now return what you typed in (or at least it should). Try "#808080". Changes to #7D7D7D. it would be nice®, if you supplied/assumed the # in the Hex: field, if the user omits it. I've hacked my copy.
|
|
|
|
|
| CSM |
Oct 26 2008, 11:21 PM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
QUOTE(g6auc @ Oct 26 2008, 05:53 PM)  Try "#808080". Changes to #7D7D7D. Maybe I should have said the larger size will make it better, not perfect. QUOTE(g6auc @ Oct 26 2008, 05:53 PM)  it would be nice®, if you supplied/assumed the # in the Hex: field, if the user omits it. I've hacked my copy. Okay, I suppose I can add that. There is a new version up, no changes except to work properly if the "#" is omitted.
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
| Cicerone Pavaloi |
Oct 27 2008, 12:50 PM
|

Posts: 562
Joined: 7-March 07
From: Iasi, Romania
Member No.: 20,296

|
QUOTE(CSM @ Oct 26 2008, 03:17 AM)  You can drag the mouse inside the single-hue gradient area, as well as click, but because the update process for that area is slightly slower, you can only click inside the hue gradient area. Maybe you can add dragging to the hue gradient area if you construct the color gradient using two gradients instead of the nested for loops. All you need is a vertical gradient from the color to white, then a horizontal gradient from black to transparent: CODE function paintColorGradient(ctx, width, height, hue) { var rgb = new Color(); var color = new HSV(); color.h = hue; color.s = 100; color.v = 100;
ctx.save(); ctx.scale(width / 100, height / 100); //vertical color gradient var grad = ctx.createLinearGradient(0, 0, 0, 100); grad.addColorStop(0, color.getRGB(rgb).getCanvasColor()); grad.addColorStop(1, "#FFF"); ctx.fillStyle = grad; ctx.fillRect(0, 0, 100, 100); //horizontal black gradient grad = ctx.createLinearGradient(0, 0, 100, 0); grad.addColorStop(0, "#000"); grad.addColorStop(1, "rgba(0,0,0,0)"); ctx.fillStyle = grad; ctx.fillRect(0, 0, 100, 100); ctx.restore(); } Note that you also need to set color.v to 100 before drawing the vertical gradient. Edit: And better use onMouseDown instead of onClick. This post has been edited by Cicerone Pavaloi: Oct 27 2008, 12:54 PM
|
|
|
|
|
| CSM |
Oct 27 2008, 02:58 PM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
QUOTE(Cicerone Pavaloi @ Oct 27 2008, 07:50 AM)  Maybe you can add dragging to the hue gradient area if you construct the color gradient using two gradients instead of the nested for loops. All you need is a vertical gradient from the color to white, then a horizontal gradient from black to transparent. I originally saw this employed by the image-based versions, I didn't immediately see a way to do it via Canavs. Why is it everyone always has the better idea? QUOTE(Cicerone Pavaloi @ Oct 27 2008, 07:50 AM)  And better use onMouseDown instead of onClick. I don't see why. If you push down, then release, you trigger the onClick. If you push then drag, you trigger the onDrag ... onMouseDown doesn't improve any of those features. Your code is faster, and overall looks better at all sizes. You win. The changes are in the update. The mouse-down location is recorded so you can't drag inside the hue area unless your drag originated from inside the strip. The web version will be updated shortly ...
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
| Cicerone Pavaloi |
Oct 27 2008, 03:49 PM
|

Posts: 562
Joined: 7-March 07
From: Iasi, Romania
Member No.: 20,296

|
QUOTE(CSM @ Oct 27 2008, 04:58 PM)  Why is it everyone always has the better idea? I do tend to think like a graphic designer first, then as a programmer. In this particular case, the designer won. QUOTE I don't see why. Because the average user is familiar with that behaviour. The system color choser reacts on mouse down, the Photoshop color choser too. Probably GIMP too.  QUOTE The mouse-down location is recorded so you can't drag inside the hue area unless your drag originated from inside the strip. That is nice, but it should work for hue area too.
|
|
|
|
|
| CSM |
Oct 27 2008, 04:07 PM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
QUOTE(Cicerone Pavaloi @ Oct 27 2008, 10:49 AM)  Because the average user is familiar with that behaviour. The system color chooser reacts on mouse down, the Photoshop color chooser too. Probably GIMP too.  Fine. onMouseDown calls onClick now (that was easiest). QUOTE(Cicerone Pavaloi @ Oct 27 2008, 10:49 AM)  That is nice, but it should work for hue area too. That's a feature. Not really ... I fixed it (in here and the web version). Took a bit to figure out what you meant.
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
| CSM |
Oct 27 2008, 04:37 PM
|

Posts: 2,386
Joined: 1-September 06
From: ̶O̶h̶i̶o̶ Washington
Member No.: 16,587

|
QUOTE(Cicerone Pavaloi @ Oct 27 2008, 11:30 AM)  Ok... Let me give you another reason why you should not use onClick (in this particular widget): If I start a drag in the color gradient, but end it over the hue gradient, there is a onClick event that goes to the hue gradient (and the other way around)...  That happens, but it shouldn't work at all! Plus, the onClick is due to the fact that this color chooser was originally non-dragable, but I made it so at the request of BOINCer. Now I can understand why onDrag isn't an official event listener for the browser ... not having it requires you to handle mouse down events yourself and you don't end up with this sort of [crud]. The differences are still annoying, however, as I definitely have way different code for Y!WE as I do for the browser now (wrt events). -- Edit -- Both versions updated, the on[cC]lick event was turned into a function, called mouseUpdate which all call instead, and the actual assignment of on[cC]lick to a function was removed.
A result of starting my server over, links from my posts may not work (especially those in the "temp" subdomain). If there is a link to something of which anyone would like to have a copy, personal message me with what you're looking for along with a way to provide this to you, and I'll see if I can find a copy. Thanks for your patience and understanding. - "Not just another open source project. Lend your talent and make a difference!" (Dead) - "The future is now." (No longer community site) (Domain has lapsed) Published: AtomicComicBlast, Barra de Lenguas, ComicWizard-4.0, MicroColors, PassGen, ScrabbleChecker, SoundBank, Uni, VisualWidget, WarpedReality Unavailable: Paradigm [clock], Puzzled, SecurityLogger, Wayback Widget Ready to be published: Cαlcυlατοr, CursorTails, Blackout, Block Puzzler, BombSquad, Palette, SnipIt ActiveDev: InactiveDev/Dead: BeatMod, Bubble Pop, Canvas Clock, Canvas Gauges, Canvas Pro, Clipboard, Crayon, Hermes, InTune, Konverter, Magic Deck, OverRuled, Outside, Slither, SystemBeat, Tetresque, Tetrad, Widget, WinSysRemote Dropped: BlankScreen, Document "Fixer", Intuitive [ -> Blackout], Motion Widget: HHGTTG CoDevelopment: Atmosphere, Block Puzzler, BombSquadMiniature Scripts: BinarySearchTree, Calendar, Canvas Gears, Checkbox, File-Browser, LinkedList/Stack, MDI Setup, MiniMax AI, PieGraph, ProgressBar, Slider widget, TabbedPane, Table, Tokenizer, TreeMenuJava+: Java Music Daemon, ScreenCapture JAR, Widget-Java/Server Bridge Example"Published" Texts: DynamicWidgetGuide Konfabulator Libraries: Color-space Library, Javable Widget ProjectWidget Tutorials: "Spawning" Widgets, JavaScript ClassesContests: Widget 4k - "Expanded" [not happening; canceled]Non-Widget Work: Hazlenut, Konspirators Online, PHP BB-Code Parser, ShortClient, Zap
|
|
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
|
 |