├── LICENSE ├── README.md ├── farbtastic ├── CHANGELOG.html ├── LICENSE.txt ├── README.html ├── demo1.html ├── demo2.html ├── farbtastic.css ├── farbtastic.js ├── marker.png ├── mask.png └── wheel.png ├── index.html ├── puzzle.png └── rainbow.html /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 2, June 1991 4 | 5 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 6 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Lesser General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | 125 | Thus, it is not the intent of this section to claim rights or contest 126 | your rights to work written entirely by you; rather, the intent is to 127 | exercise the right to control the distribution of derivative or 128 | collective works based on the Program. 129 | 130 | In addition, mere aggregation of another work not based on the Program 131 | with the Program (or with a work based on the Program) on a volume of 132 | a storage or distribution medium does not bring the other work under 133 | the scope of this License. 134 | 135 | 3. You may copy and distribute the Program (or a work based on it, 136 | under Section 2) in object code or executable form under the terms of 137 | Sections 1 and 2 above provided that you also do one of the following: 138 | 139 | a) Accompany it with the complete corresponding machine-readable 140 | source code, which must be distributed under the terms of Sections 141 | 1 and 2 above on a medium customarily used for software interchange; or, 142 | 143 | b) Accompany it with a written offer, valid for at least three 144 | years, to give any third party, for a charge no more than your 145 | cost of physically performing source distribution, a complete 146 | machine-readable copy of the corresponding source code, to be 147 | distributed under the terms of Sections 1 and 2 above on a medium 148 | customarily used for software interchange; or, 149 | 150 | c) Accompany it with the information you received as to the offer 151 | to distribute corresponding source code. (This alternative is 152 | allowed only for noncommercial distribution and only if you 153 | received the program in object code or executable form with such 154 | an offer, in accord with Subsection b above.) 155 | 156 | The source code for a work means the preferred form of the work for 157 | making modifications to it. For an executable work, complete source 158 | code means all the source code for all modules it contains, plus any 159 | associated interface definition files, plus the scripts used to 160 | control compilation and installation of the executable. However, as a 161 | special exception, the source code distributed need not include 162 | anything that is normally distributed (in either source or binary 163 | form) with the major components (compiler, kernel, and so on) of the 164 | operating system on which the executable runs, unless that component 165 | itself accompanies the executable. 166 | 167 | If distribution of executable or object code is made by offering 168 | access to copy from a designated place, then offering equivalent 169 | access to copy the source code from the same place counts as 170 | distribution of the source code, even though third parties are not 171 | compelled to copy the source along with the object code. 172 | 173 | 4. You may not copy, modify, sublicense, or distribute the Program 174 | except as expressly provided under this License. Any attempt 175 | otherwise to copy, modify, sublicense or distribute the Program is 176 | void, and will automatically terminate your rights under this License. 177 | However, parties who have received copies, or rights, from you under 178 | this License will not have their licenses terminated so long as such 179 | parties remain in full compliance. 180 | 181 | 5. You are not required to accept this License, since you have not 182 | signed it. However, nothing else grants you permission to modify or 183 | distribute the Program or its derivative works. These actions are 184 | prohibited by law if you do not accept this License. Therefore, by 185 | modifying or distributing the Program (or any work based on the 186 | Program), you indicate your acceptance of this License to do so, and 187 | all its terms and conditions for copying, distributing or modifying 188 | the Program or works based on it. 189 | 190 | 6. Each time you redistribute the Program (or any work based on the 191 | Program), the recipient automatically receives a license from the 192 | original licensor to copy, distribute or modify the Program subject to 193 | these terms and conditions. You may not impose any further 194 | restrictions on the recipients' exercise of the rights granted herein. 195 | You are not responsible for enforcing compliance by third parties to 196 | this License. 197 | 198 | 7. If, as a consequence of a court judgment or allegation of patent 199 | infringement or for any other reason (not limited to patent issues), 200 | conditions are imposed on you (whether by court order, agreement or 201 | otherwise) that contradict the conditions of this License, they do not 202 | excuse you from the conditions of this License. If you cannot 203 | distribute so as to satisfy simultaneously your obligations under this 204 | License and any other pertinent obligations, then as a consequence you 205 | may not distribute the Program at all. For example, if a patent 206 | license would not permit royalty-free redistribution of the Program by 207 | all those who receive copies directly or indirectly through you, then 208 | the only way you could satisfy both it and this License would be to 209 | refrain entirely from distribution of the Program. 210 | 211 | If any portion of this section is held invalid or unenforceable under 212 | any particular circumstance, the balance of the section is intended to 213 | apply and the section as a whole is intended to apply in other 214 | circumstances. 215 | 216 | It is not the purpose of this section to induce you to infringe any 217 | patents or other property right claims or to contest validity of any 218 | such claims; this section has the sole purpose of protecting the 219 | integrity of the free software distribution system, which is 220 | implemented by public license practices. Many people have made 221 | generous contributions to the wide range of software distributed 222 | through that system in reliance on consistent application of that 223 | system; it is up to the author/donor to decide if he or she is willing 224 | to distribute software through any other system and a licensee cannot 225 | impose that choice. 226 | 227 | This section is intended to make thoroughly clear what is believed to 228 | be a consequence of the rest of this License. 229 | 230 | 8. If the distribution and/or use of the Program is restricted in 231 | certain countries either by patents or by copyrighted interfaces, the 232 | original copyright holder who places the Program under this License 233 | may add an explicit geographical distribution limitation excluding 234 | those countries, so that distribution is permitted only in or among 235 | countries not thus excluded. In such case, this License incorporates 236 | the limitation as if written in the body of this License. 237 | 238 | 9. The Free Software Foundation may publish revised and/or new versions 239 | of the General Public License from time to time. Such new versions will 240 | be similar in spirit to the present version, but may differ in detail to 241 | address new problems or concerns. 242 | 243 | Each version is given a distinguishing version number. If the Program 244 | specifies a version number of this License which applies to it and "any 245 | later version", you have the option of following the terms and conditions 246 | either of that version or of any later version published by the Free 247 | Software Foundation. If the Program does not specify a version number of 248 | this License, you may choose any version ever published by the Free Software 249 | Foundation. 250 | 251 | 10. If you wish to incorporate parts of the Program into other free 252 | programs whose distribution conditions are different, write to the author 253 | to ask for permission. For software which is copyrighted by the Free 254 | Software Foundation, write to the Free Software Foundation; we sometimes 255 | make exceptions for this. Our decision will be guided by the two goals 256 | of preserving the free status of all derivatives of our free software and 257 | of promoting the sharing and reuse of software generally. 258 | 259 | NO WARRANTY 260 | 261 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 262 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 263 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 264 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 265 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 266 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 267 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 268 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 269 | REPAIR OR CORRECTION. 270 | 271 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 272 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 273 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 274 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 275 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 276 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 277 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 278 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 279 | POSSIBILITY OF SUCH DAMAGES. 280 | 281 | END OF TERMS AND CONDITIONS 282 | 283 | How to Apply These Terms to Your New Programs 284 | 285 | If you develop a new program, and you want it to be of the greatest 286 | possible use to the public, the best way to achieve this is to make it 287 | free software which everyone can redistribute and change under these terms. 288 | 289 | To do so, attach the following notices to the program. It is safest 290 | to attach them to the start of each source file to most effectively 291 | convey the exclusion of warranty; and each file should have at least 292 | the "copyright" line and a pointer to where the full notice is found. 293 | 294 | 295 | Copyright (C) 296 | 297 | This program is free software; you can redistribute it and/or modify 298 | it under the terms of the GNU General Public License as published by 299 | the Free Software Foundation; either version 2 of the License, or 300 | (at your option) any later version. 301 | 302 | This program is distributed in the hope that it will be useful, 303 | but WITHOUT ANY WARRANTY; without even the implied warranty of 304 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 305 | GNU General Public License for more details. 306 | 307 | You should have received a copy of the GNU General Public License 308 | along with this program; if not, write to the Free Software 309 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 310 | 311 | 312 | Also add information on how to contact you by electronic and paper mail. 313 | 314 | If the program is interactive, make it output a short notice like this 315 | when it starts in an interactive mode: 316 | 317 | Gnomovision version 69, Copyright (C) year name of author 318 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 319 | This is free software, and you are welcome to redistribute it 320 | under certain conditions; type `show c' for details. 321 | 322 | The hypothetical commands `show w' and `show c' should show the appropriate 323 | parts of the General Public License. Of course, the commands you use may 324 | be called something other than `show w' and `show c'; they could even be 325 | mouse-clicks or menu items--whatever suits your program. 326 | 327 | You should also get your employer (if you work as a programmer) or your 328 | school, if any, to sign a "copyright disclaimer" for the program, if 329 | necessary. Here is a sample; alter the names: 330 | 331 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 332 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 333 | 334 | , 1 April 1989 335 | Ty Coon, President of Vice 336 | 337 | This General Public License does not permit incorporating your program into 338 | proprietary programs. If your program is a subroutine library, you may 339 | consider it more useful to permit linking proprietary applications with the 340 | library. If this is what you want to do, use the GNU Lesser General 341 | Public License instead of this License. 342 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Gradientifier 2 | ============= 3 | 4 | A tool that genreates color ramps for pixel art by simulating lighting conditions 5 | 6 | Licensing 7 | ========= 8 | My original intent was to release this code under the more liberal MIT license, however since I'm linking to farbtastic (which is GPLed), this code needs to be GPLed as well. If you want to use this code under the MIT license, you have my permission to do so if you remove the dependency on farbtastic and replace it with another color picker. 9 | 10 | Holy crap, what do all these crazy sliders to?? 11 | =============================================== 12 | 13 | Note that the below documentation is for rainbow mode. 14 | 15 | Tint Color: 16 | It is possible to tint your entire rainbow at once with a single color. Just change this color to whatever you want to use to tint the palette, and adjust the "Tint" slider under "Rainbow controls" until it's tinted as much as you want it to be. 17 | 18 | Highlight color & Ambient color: 19 | These two sliders control the overall lighting conditions. The "highlight" is a bright overhead light, which affects color where your object is lit brightly, while the "ambient light" is the light from the surroundings, which affects the color of shadows. Generally, your highlight color should be brighter than your ambient color, or your results may not make a lot of sense. 20 | 21 | Selected rainbow color: 22 | You can select a rainbow color by clicking on that color in the rainbow. Then, you can use this color picker to change that color to whatver you'd like. 23 | 24 | Reflectivity: 25 | A little bit of theory about lighting is necessary to understand this. When you shine a light on a completely non-reflective object, the color of the object will be the red, green, and blue compoents of the objects color times the red, green, and blue components of the color of the light. This means the following things: 26 | 27 | * If you shine a completely blue light on a completely red object, the color of the object will appear to be black, because the color of your light is rgb(0, 0, 1) and the color of your object is rgb(1, 0, 0), so the multiplied color will be rgb(0, 0, 0). 28 | * If you shine a completely blue light on a completely white object, the color of the object will appear to be blue, because the color of your light is rgb(0, 0, 1) and the color of your object is rgb(1, 1, 1), so the multiplied color will be rgb(0, 0, 1). 29 | 30 | Essentially, the way it works when you light a colored object is that the object absorbs all of the component colors in the light, except for the color of the object itself, which is reflected back. 31 | 32 | However, reflection changes the dynamic a little bit. If an object is 100% reflective, it acts like a perfect mirror and bounces all light back without absorbing any. For our purposes, that means we return a weighted average of the color of the object as if it's lit by the light, and the color of the light itself. If an object is completely reflected, the object's color doesn't matter at all, and it acts like a mirror. 33 | 34 | Illumination: 35 | The illumination slider controls how much of the object is lit by the light source versus the ambient light. An object with low illumination will be mostly dark, but with a bright highlight. An object with high illumination will be mostly bright, but will still have a dark shadow. Generally, the illumination slider is best used for creating dark, dramatic lighting with bright highlights. 36 | 37 | Highlight multiplier: 38 | A little bit more theory is necessary here. When you display pixels on a computer screen, the brightness of the rgb components of the pixel are clamped between the minimum and maximum intensity that your screen can put out. While it's impossible for anything to be darker than black, in the real world, there's no practical limit to how bright a light source can be. The Highlight Multiplier slider increases the intensity of your highlight color to values above 1 for the purpose of color ramp calculations. After the color ramp is calculated, the values for the ramp are then clamped to a maximum of 1. Be careful when adjusting the highlight multiplier, as it can make your ramps very bright very quickly. It's often best used in conjunction with darker illumination, to bring out the color of the light in your highlights. 39 | 40 | Brightness: 41 | This slider makes your entire ramp (both shadows and highlights) darker or lighter. 42 | 43 | Contrast: 44 | This slider widens the contrast between your shadows and highlights. 45 | 46 | Tint: 47 | This slider tints your entire rainbow with the selected tint color. 48 | 49 | Desaturate: 50 | This slider tints your entire rainbow with white. 51 | 52 | Darken: 53 | This slider tints your entire rainbow with black. 54 | 55 | For instance, if you want to make your rainbow more grey, you could slide the desaturate slider and the darken slider both part way up, or you could select a grey tint color and use the tint slider. Technically the Desaturate and Darken sliders are somewhat redundant, but they allow you to make quick adjustments without messing with your tint. 56 | 57 | So I like my palette, now what? 58 | =============================== 59 | 60 | Right click on the swatches and save the image, then load it into your favorite pixel editing program. Note that the top colors in the swatch image are always your rainbow colors, and aren't part of the DB32 palette. They are provided for reference, because it's not always obvious from looking at a color ramp what the perceived color will be. 61 | -------------------------------------------------------------------------------- /farbtastic/CHANGELOG.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | Farbtastic: Changelog 5 | 6 |

Farbtastic: Changelog

7 | 8 |

1.2 - 2007/01/08

9 |
    10 |
  • Fixed bug with linking multiple fields with the same value.
  • 11 |
12 |

1.1 - 2006/10/27

13 |
    14 |
  • Work around for the transparent PNGs in Internet Explorer.
  • 15 |
  • Better mouse handling code to accomodate CSS-based layouts better.
  • 16 |
17 |

1.0 - 2006/07/14

18 |
    19 |
  • Initial release.
  • 20 |
21 | 22 |

More info on Acko.net.

23 |

Created by Steven Wittens.

24 | 25 | 26 | -------------------------------------------------------------------------------- /farbtastic/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 2, June 1991 4 | 5 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 6 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Lesser General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | 125 | Thus, it is not the intent of this section to claim rights or contest 126 | your rights to work written entirely by you; rather, the intent is to 127 | exercise the right to control the distribution of derivative or 128 | collective works based on the Program. 129 | 130 | In addition, mere aggregation of another work not based on the Program 131 | with the Program (or with a work based on the Program) on a volume of 132 | a storage or distribution medium does not bring the other work under 133 | the scope of this License. 134 | 135 | 3. You may copy and distribute the Program (or a work based on it, 136 | under Section 2) in object code or executable form under the terms of 137 | Sections 1 and 2 above provided that you also do one of the following: 138 | 139 | a) Accompany it with the complete corresponding machine-readable 140 | source code, which must be distributed under the terms of Sections 141 | 1 and 2 above on a medium customarily used for software interchange; or, 142 | 143 | b) Accompany it with a written offer, valid for at least three 144 | years, to give any third party, for a charge no more than your 145 | cost of physically performing source distribution, a complete 146 | machine-readable copy of the corresponding source code, to be 147 | distributed under the terms of Sections 1 and 2 above on a medium 148 | customarily used for software interchange; or, 149 | 150 | c) Accompany it with the information you received as to the offer 151 | to distribute corresponding source code. (This alternative is 152 | allowed only for noncommercial distribution and only if you 153 | received the program in object code or executable form with such 154 | an offer, in accord with Subsection b above.) 155 | 156 | The source code for a work means the preferred form of the work for 157 | making modifications to it. For an executable work, complete source 158 | code means all the source code for all modules it contains, plus any 159 | associated interface definition files, plus the scripts used to 160 | control compilation and installation of the executable. However, as a 161 | special exception, the source code distributed need not include 162 | anything that is normally distributed (in either source or binary 163 | form) with the major components (compiler, kernel, and so on) of the 164 | operating system on which the executable runs, unless that component 165 | itself accompanies the executable. 166 | 167 | If distribution of executable or object code is made by offering 168 | access to copy from a designated place, then offering equivalent 169 | access to copy the source code from the same place counts as 170 | distribution of the source code, even though third parties are not 171 | compelled to copy the source along with the object code. 172 | 173 | 4. You may not copy, modify, sublicense, or distribute the Program 174 | except as expressly provided under this License. Any attempt 175 | otherwise to copy, modify, sublicense or distribute the Program is 176 | void, and will automatically terminate your rights under this License. 177 | However, parties who have received copies, or rights, from you under 178 | this License will not have their licenses terminated so long as such 179 | parties remain in full compliance. 180 | 181 | 5. You are not required to accept this License, since you have not 182 | signed it. However, nothing else grants you permission to modify or 183 | distribute the Program or its derivative works. These actions are 184 | prohibited by law if you do not accept this License. Therefore, by 185 | modifying or distributing the Program (or any work based on the 186 | Program), you indicate your acceptance of this License to do so, and 187 | all its terms and conditions for copying, distributing or modifying 188 | the Program or works based on it. 189 | 190 | 6. Each time you redistribute the Program (or any work based on the 191 | Program), the recipient automatically receives a license from the 192 | original licensor to copy, distribute or modify the Program subject to 193 | these terms and conditions. You may not impose any further 194 | restrictions on the recipients' exercise of the rights granted herein. 195 | You are not responsible for enforcing compliance by third parties to 196 | this License. 197 | 198 | 7. If, as a consequence of a court judgment or allegation of patent 199 | infringement or for any other reason (not limited to patent issues), 200 | conditions are imposed on you (whether by court order, agreement or 201 | otherwise) that contradict the conditions of this License, they do not 202 | excuse you from the conditions of this License. If you cannot 203 | distribute so as to satisfy simultaneously your obligations under this 204 | License and any other pertinent obligations, then as a consequence you 205 | may not distribute the Program at all. For example, if a patent 206 | license would not permit royalty-free redistribution of the Program by 207 | all those who receive copies directly or indirectly through you, then 208 | the only way you could satisfy both it and this License would be to 209 | refrain entirely from distribution of the Program. 210 | 211 | If any portion of this section is held invalid or unenforceable under 212 | any particular circumstance, the balance of the section is intended to 213 | apply and the section as a whole is intended to apply in other 214 | circumstances. 215 | 216 | It is not the purpose of this section to induce you to infringe any 217 | patents or other property right claims or to contest validity of any 218 | such claims; this section has the sole purpose of protecting the 219 | integrity of the free software distribution system, which is 220 | implemented by public license practices. Many people have made 221 | generous contributions to the wide range of software distributed 222 | through that system in reliance on consistent application of that 223 | system; it is up to the author/donor to decide if he or she is willing 224 | to distribute software through any other system and a licensee cannot 225 | impose that choice. 226 | 227 | This section is intended to make thoroughly clear what is believed to 228 | be a consequence of the rest of this License. 229 | 230 | 8. If the distribution and/or use of the Program is restricted in 231 | certain countries either by patents or by copyrighted interfaces, the 232 | original copyright holder who places the Program under this License 233 | may add an explicit geographical distribution limitation excluding 234 | those countries, so that distribution is permitted only in or among 235 | countries not thus excluded. In such case, this License incorporates 236 | the limitation as if written in the body of this License. 237 | 238 | 9. The Free Software Foundation may publish revised and/or new versions 239 | of the General Public License from time to time. Such new versions will 240 | be similar in spirit to the present version, but may differ in detail to 241 | address new problems or concerns. 242 | 243 | Each version is given a distinguishing version number. If the Program 244 | specifies a version number of this License which applies to it and "any 245 | later version", you have the option of following the terms and conditions 246 | either of that version or of any later version published by the Free 247 | Software Foundation. If the Program does not specify a version number of 248 | this License, you may choose any version ever published by the Free Software 249 | Foundation. 250 | 251 | 10. If you wish to incorporate parts of the Program into other free 252 | programs whose distribution conditions are different, write to the author 253 | to ask for permission. For software which is copyrighted by the Free 254 | Software Foundation, write to the Free Software Foundation; we sometimes 255 | make exceptions for this. Our decision will be guided by the two goals 256 | of preserving the free status of all derivatives of our free software and 257 | of promoting the sharing and reuse of software generally. 258 | 259 | NO WARRANTY 260 | 261 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 262 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 263 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 264 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 265 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 266 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 267 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 268 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 269 | REPAIR OR CORRECTION. 270 | 271 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 272 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 273 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 274 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 275 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 276 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 277 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 278 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 279 | POSSIBILITY OF SUCH DAMAGES. 280 | 281 | END OF TERMS AND CONDITIONS 282 | 283 | How to Apply These Terms to Your New Programs 284 | 285 | If you develop a new program, and you want it to be of the greatest 286 | possible use to the public, the best way to achieve this is to make it 287 | free software which everyone can redistribute and change under these terms. 288 | 289 | To do so, attach the following notices to the program. It is safest 290 | to attach them to the start of each source file to most effectively 291 | convey the exclusion of warranty; and each file should have at least 292 | the "copyright" line and a pointer to where the full notice is found. 293 | 294 | 295 | Copyright (C) 296 | 297 | This program is free software; you can redistribute it and/or modify 298 | it under the terms of the GNU General Public License as published by 299 | the Free Software Foundation; either version 2 of the License, or 300 | (at your option) any later version. 301 | 302 | This program is distributed in the hope that it will be useful, 303 | but WITHOUT ANY WARRANTY; without even the implied warranty of 304 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 305 | GNU General Public License for more details. 306 | 307 | You should have received a copy of the GNU General Public License 308 | along with this program; if not, write to the Free Software 309 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 310 | 311 | 312 | Also add information on how to contact you by electronic and paper mail. 313 | 314 | If the program is interactive, make it output a short notice like this 315 | when it starts in an interactive mode: 316 | 317 | Gnomovision version 69, Copyright (C) year name of author 318 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 319 | This is free software, and you are welcome to redistribute it 320 | under certain conditions; type `show c' for details. 321 | 322 | The hypothetical commands `show w' and `show c' should show the appropriate 323 | parts of the General Public License. Of course, the commands you use may 324 | be called something other than `show w' and `show c'; they could even be 325 | mouse-clicks or menu items--whatever suits your program. 326 | 327 | You should also get your employer (if you work as a programmer) or your 328 | school, if any, to sign a "copyright disclaimer" for the program, if 329 | necessary. Here is a sample; alter the names: 330 | 331 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 332 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 333 | 334 | , 1 April 1989 335 | Ty Coon, President of Vice 336 | 337 | This General Public License does not permit incorporating your program into 338 | proprietary programs. If your program is a subroutine library, you may 339 | consider it more useful to permit linking proprietary applications with the 340 | library. If this is what you want to do, use the GNU Lesser General 341 | Public License instead of this License. 342 | -------------------------------------------------------------------------------- /farbtastic/README.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | Farbtastic: jQuery color picker plug-in 5 | 6 |

Farbtastic: jQuery color picker plug-in

7 |

Farbtastic is a jQuery plug-in that can add one or more color picker widgets into a page. Each widget is then linked to an existing element (e.g. a text field) and will update the element's value when a color is selected.

8 | 9 |

Farbtastic uses layered transparent PNGs to render a saturation/luminance gradient inside of a hue circle. No Flash or pixel-sized divs are used.

10 | 11 |

Farbtastic was written by Steven Wittens and is licensed under the GPL.

12 | 13 |

Basic Usage

14 |
    15 |
  1. Include farbtastic.js and farbtastic.css in your HTML:
    16 |
    <script type="text/javascript" src="farbtastic.js"></script>
    <link rel="stylesheet" href="farbtastic.css" type="text/css" />
    17 |
  2. 18 |
  3. Add a placeholder div and a text field to your HTML, and give each an ID:
    19 |
    <form><input type="text" id="color" name="color" value="#123456" /></form>
    <div id="colorpicker"></div>
    20 |
  4. 21 |
  5. Add a ready() handler to the document which initializes the color picker and link it to the text field with the following syntax:
    22 |
    <script type="text/javascript">
      $(document).ready(function() {
        $('#colorpicker').farbtastic('#color');
      });
    </script>
    23 |
  6. 24 |
25 |

See demo1.html and demo2.html for an example (jquery.js is not included!).

26 |

Styling

27 |

The color picker is a block-level element and is 195x195 pixels large. You can control the position by styling your placeholder (e.g. floating it).

28 |

Note that the black/white gradients inside wheel.png and mask.png were generated programmatically and cannot be recreated easily in an image editing program.

29 |

Advanced Usage

30 |

jQuery Method

31 |
32 |
$(...).farbtastic()
33 | $(...).farbtastic(callback)
34 |
This creates color pickers in the selected objects. callback is optional and can be a:

35 |
    36 |
  • DOM Node, jQuery object or jQuery selector: the color picker will be linked to the selected element(s) by syncing the value (for form elements) and color (all elements).
  • 37 |
  • Function: this function will be called whenever the user chooses a different color.
38 |
39 |

Object

40 |
41 |
$.farbtastic(placeholder)
42 | $.farbtastic(placeholder, callback)
43 |
44 |
Invoking $.farbtastic(placeholder) is the same as using $(placeholder).farbtastic() except that the Farbtastic object is returned instead of the jQuery object. This allows you to use the Farbtastic methods and properties below.

45 |

Note that there is only one Farbtastic object per placeholder. If you call $.farbtastic(placeholder) twice with the same placeholder, you will get the same object back each time.

46 |

The optional callback argument behaves exactly as for the jQuery method.
47 |

48 |
49 | 50 | 51 |

Methods

52 |
53 |
.linkTo(callback)
54 |
Allows you to set a new callback. Any existing callbacks are removed. See above for the meaning of callback.
55 |
.setColor(string)
56 |
Sets the picker color to the given color in hex representation.
57 |
.setColor([h, s, l])
58 |
Sets the picker color to the given color in normalized HSL (0..1 scale).
59 |
60 |

Properties

61 |
62 |
.linked
63 |
The elements (jQuery object) or callback function this picker is linked to.
64 |
.color
65 |
Current color in hex representation.
66 |
.hsl
67 |
Current color in normalized HSL.
68 |
69 |
70 | 71 | -------------------------------------------------------------------------------- /farbtastic/demo1.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Farbtastic 6 | 7 | 8 | 9 | 15 | 16 | 17 |

jQuery Color Picker: Farbtastic

18 | 19 |
jQuery.js is not present. You must install jQuery in this folder for the demo to work.
20 | 21 |
22 |
23 |
24 | 25 |

More info on Acko.net.

26 |

Created by Steven Wittens.

27 | 28 | 29 | -------------------------------------------------------------------------------- /farbtastic/demo2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Farbtastic 6 | 7 | 8 | 9 | 21 | 22 | 40 | 41 | 42 |

jQuery Color Picker: Farbtastic

43 | 44 |
jQuery.js is not present. You must install jQuery in this folder for the demo to work.
45 | 46 |
47 |
48 |
49 |
50 |
51 | 52 |
53 | 54 |

More info on Acko.net.

55 |

Created by Steven Wittens.

56 | 57 | 58 | -------------------------------------------------------------------------------- /farbtastic/farbtastic.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Farbtastic Color Picker 1.2 3 | * © 2008 Steven Wittens 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | .farbtastic { 20 | position: relative; 21 | } 22 | .farbtastic * { 23 | position: absolute; 24 | cursor: crosshair; 25 | } 26 | .farbtastic, .farbtastic .wheel { 27 | width: 195px; 28 | height: 195px; 29 | } 30 | .farbtastic .color, .farbtastic .overlay { 31 | top: 47px; 32 | left: 47px; 33 | width: 101px; 34 | height: 101px; 35 | } 36 | .farbtastic .wheel { 37 | background: url(wheel.png) no-repeat; 38 | width: 195px; 39 | height: 195px; 40 | } 41 | .farbtastic .overlay { 42 | background: url(mask.png) no-repeat; 43 | } 44 | .farbtastic .marker { 45 | width: 17px; 46 | height: 17px; 47 | margin: -8px 0 0 -8px; 48 | overflow: hidden; 49 | background: url(marker.png) no-repeat; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /farbtastic/farbtastic.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Farbtastic Color Picker 1.2 3 | * © 2008 Steven Wittens 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | jQuery.fn.farbtastic = function (callback) { 21 | $.farbtastic(this, callback); 22 | return this; 23 | }; 24 | 25 | jQuery.farbtastic = function (container, callback) { 26 | var container = $(container).get(0); 27 | return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); 28 | } 29 | 30 | jQuery._farbtastic = function (container, callback) { 31 | // Store farbtastic object 32 | var fb = this; 33 | 34 | // Insert markup 35 | $(container).html('
'); 36 | var e = $('.farbtastic', container); 37 | fb.wheel = $('.wheel', container).get(0); 38 | // Dimensions 39 | fb.radius = 84; 40 | fb.square = 100; 41 | fb.width = 194; 42 | 43 | // Fix background PNGs in IE6 44 | if (navigator.appVersion.match(/MSIE [0-6]\./)) { 45 | $('*', e).each(function () { 46 | if (this.currentStyle.backgroundImage != 'none') { 47 | var image = this.currentStyle.backgroundImage; 48 | image = this.currentStyle.backgroundImage.substring(5, image.length - 2); 49 | $(this).css({ 50 | 'backgroundImage': 'none', 51 | 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" 52 | }); 53 | } 54 | }); 55 | } 56 | 57 | /** 58 | * Link to the given element(s) or callback. 59 | */ 60 | fb.linkTo = function (callback) { 61 | // Unbind previous nodes 62 | if (typeof fb.callback == 'object') { 63 | $(fb.callback).unbind('keyup', fb.updateValue); 64 | } 65 | 66 | // Reset color 67 | fb.color = null; 68 | 69 | // Bind callback or elements 70 | if (typeof callback == 'function') { 71 | fb.callback = callback; 72 | } 73 | else if (typeof callback == 'object' || typeof callback == 'string') { 74 | fb.callback = $(callback); 75 | fb.callback.bind('keyup', fb.updateValue); 76 | if (fb.callback.get(0).value) { 77 | fb.setColor(fb.callback.get(0).value); 78 | } 79 | } 80 | return this; 81 | } 82 | fb.updateValue = function (event) { 83 | if (this.value && this.value != fb.color) { 84 | fb.setColor(this.value); 85 | } 86 | } 87 | 88 | /** 89 | * Change color with HTML syntax #123456 90 | */ 91 | fb.setColor = function (color) { 92 | var unpack = fb.unpack(color); 93 | if (fb.color != color && unpack) { 94 | fb.color = color; 95 | fb.rgb = unpack; 96 | fb.hsl = fb.RGBToHSL(fb.rgb); 97 | fb.updateDisplay(); 98 | } 99 | return this; 100 | } 101 | 102 | /** 103 | * Change color with HSL triplet [0..1, 0..1, 0..1] 104 | */ 105 | fb.setHSL = function (hsl) { 106 | fb.hsl = hsl; 107 | fb.rgb = fb.HSLToRGB(hsl); 108 | fb.color = fb.pack(fb.rgb); 109 | fb.updateDisplay(); 110 | return this; 111 | } 112 | 113 | ///////////////////////////////////////////////////// 114 | 115 | /** 116 | * Retrieve the coordinates of the given event relative to the center 117 | * of the widget. 118 | */ 119 | fb.widgetCoords = function (event) { 120 | var x, y; 121 | var el = event.target || event.srcElement; 122 | var reference = fb.wheel; 123 | 124 | if (typeof event.offsetX != 'undefined') { 125 | // Use offset coordinates and find common offsetParent 126 | var pos = { x: event.offsetX, y: event.offsetY }; 127 | 128 | // Send the coordinates upwards through the offsetParent chain. 129 | var e = el; 130 | while (e) { 131 | e.mouseX = pos.x; 132 | e.mouseY = pos.y; 133 | pos.x += e.offsetLeft; 134 | pos.y += e.offsetTop; 135 | e = e.offsetParent; 136 | } 137 | 138 | // Look for the coordinates starting from the wheel widget. 139 | var e = reference; 140 | var offset = { x: 0, y: 0 } 141 | while (e) { 142 | if (typeof e.mouseX != 'undefined') { 143 | x = e.mouseX - offset.x; 144 | y = e.mouseY - offset.y; 145 | break; 146 | } 147 | offset.x += e.offsetLeft; 148 | offset.y += e.offsetTop; 149 | e = e.offsetParent; 150 | } 151 | 152 | // Reset stored coordinates 153 | e = el; 154 | while (e) { 155 | e.mouseX = undefined; 156 | e.mouseY = undefined; 157 | e = e.offsetParent; 158 | } 159 | } 160 | else { 161 | // Use absolute coordinates 162 | var pos = fb.absolutePosition(reference); 163 | x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x; 164 | y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y; 165 | } 166 | // Subtract distance to middle 167 | return { x: x - fb.width / 2, y: y - fb.width / 2 }; 168 | } 169 | 170 | /** 171 | * Mousedown handler 172 | */ 173 | fb.mousedown = function (event) { 174 | // Capture mouse 175 | if (!document.dragging) { 176 | $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); 177 | document.dragging = true; 178 | } 179 | 180 | // Check which area is being dragged 181 | var pos = fb.widgetCoords(event); 182 | fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square; 183 | 184 | // Process 185 | fb.mousemove(event); 186 | return false; 187 | } 188 | 189 | /** 190 | * Mousemove handler 191 | */ 192 | fb.mousemove = function (event) { 193 | // Get coordinates relative to color picker center 194 | var pos = fb.widgetCoords(event); 195 | 196 | // Set new HSL parameters 197 | if (fb.circleDrag) { 198 | var hue = Math.atan2(pos.x, -pos.y) / 6.28; 199 | if (hue < 0) hue += 1; 200 | fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]); 201 | } 202 | else { 203 | var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5)); 204 | var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5)); 205 | fb.setHSL([fb.hsl[0], sat, lum]); 206 | } 207 | return false; 208 | } 209 | 210 | /** 211 | * Mouseup handler 212 | */ 213 | fb.mouseup = function () { 214 | // Uncapture mouse 215 | $(document).unbind('mousemove', fb.mousemove); 216 | $(document).unbind('mouseup', fb.mouseup); 217 | document.dragging = false; 218 | } 219 | 220 | /** 221 | * Update the markers and styles 222 | */ 223 | fb.updateDisplay = function () { 224 | // Markers 225 | var angle = fb.hsl[0] * 6.28; 226 | $('.h-marker', e).css({ 227 | left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px', 228 | top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px' 229 | }); 230 | 231 | $('.sl-marker', e).css({ 232 | left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px', 233 | top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px' 234 | }); 235 | 236 | // Saturation/Luminance gradient 237 | $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5]))); 238 | 239 | // Linked elements or callback 240 | if (typeof fb.callback == 'object') { 241 | // Set background/foreground color 242 | $(fb.callback).css({ 243 | backgroundColor: fb.color, 244 | color: fb.hsl[2] > 0.5 ? '#000' : '#fff' 245 | }); 246 | 247 | // Change linked value 248 | $(fb.callback).each(function() { 249 | if (this.value && this.value != fb.color) { 250 | this.value = fb.color; 251 | } 252 | }); 253 | } 254 | else if (typeof fb.callback == 'function') { 255 | fb.callback.call(fb, fb.color); 256 | } 257 | } 258 | 259 | /** 260 | * Get absolute position of element 261 | */ 262 | fb.absolutePosition = function (el) { 263 | var r = { x: el.offsetLeft, y: el.offsetTop }; 264 | // Resolve relative to offsetParent 265 | if (el.offsetParent) { 266 | var tmp = fb.absolutePosition(el.offsetParent); 267 | r.x += tmp.x; 268 | r.y += tmp.y; 269 | } 270 | return r; 271 | }; 272 | 273 | /* Various color utility functions */ 274 | fb.pack = function (rgb) { 275 | var r = Math.round(rgb[0] * 255); 276 | var g = Math.round(rgb[1] * 255); 277 | var b = Math.round(rgb[2] * 255); 278 | return '#' + (r < 16 ? '0' : '') + r.toString(16) + 279 | (g < 16 ? '0' : '') + g.toString(16) + 280 | (b < 16 ? '0' : '') + b.toString(16); 281 | } 282 | 283 | fb.unpack = function (color) { 284 | if (color.length == 7) { 285 | return [parseInt('0x' + color.substring(1, 3)) / 255, 286 | parseInt('0x' + color.substring(3, 5)) / 255, 287 | parseInt('0x' + color.substring(5, 7)) / 255]; 288 | } 289 | else if (color.length == 4) { 290 | return [parseInt('0x' + color.substring(1, 2)) / 15, 291 | parseInt('0x' + color.substring(2, 3)) / 15, 292 | parseInt('0x' + color.substring(3, 4)) / 15]; 293 | } 294 | } 295 | 296 | fb.HSLToRGB = function (hsl) { 297 | var m1, m2, r, g, b; 298 | var h = hsl[0], s = hsl[1], l = hsl[2]; 299 | m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s; 300 | m1 = l * 2 - m2; 301 | return [this.hueToRGB(m1, m2, h+0.33333), 302 | this.hueToRGB(m1, m2, h), 303 | this.hueToRGB(m1, m2, h-0.33333)]; 304 | } 305 | 306 | fb.hueToRGB = function (m1, m2, h) { 307 | h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h); 308 | if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; 309 | if (h * 2 < 1) return m2; 310 | if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; 311 | return m1; 312 | } 313 | 314 | fb.RGBToHSL = function (rgb) { 315 | var min, max, delta, h, s, l; 316 | var r = rgb[0], g = rgb[1], b = rgb[2]; 317 | min = Math.min(r, Math.min(g, b)); 318 | max = Math.max(r, Math.max(g, b)); 319 | delta = max - min; 320 | l = (min + max) / 2; 321 | s = 0; 322 | if (l > 0 && l < 1) { 323 | s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); 324 | } 325 | h = 0; 326 | if (delta > 0) { 327 | if (max == r && max != g) h += (g - b) / delta; 328 | if (max == g && max != b) h += (2 + (b - r) / delta); 329 | if (max == b && max != r) h += (4 + (r - g) / delta); 330 | h /= 6; 331 | } 332 | return [h, s, l]; 333 | } 334 | 335 | // Install mousedown handler (the others are set on the document on-demand) 336 | $('*', e).mousedown(fb.mousedown); 337 | 338 | // Init color 339 | fb.setColor('#000000'); 340 | 341 | // Set linked elements/callback 342 | if (callback) { 343 | fb.linkTo(callback); 344 | } 345 | } -------------------------------------------------------------------------------- /farbtastic/marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lendrick/Gradientifier/5272deae4c66bfcbadb58a5e1e9adb4d88931918/farbtastic/marker.png -------------------------------------------------------------------------------- /farbtastic/mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lendrick/Gradientifier/5272deae4c66bfcbadb58a5e1e9adb4d88931918/farbtastic/mask.png -------------------------------------------------------------------------------- /farbtastic/wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lendrick/Gradientifier/5272deae4c66bfcbadb58a5e1e9adb4d88931918/farbtastic/wheel.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 319 | 320 | 321 | 322 | Hide/Show instructions
323 |
324 |

This page generates gradients for the Dawnbringer 32 color palette. A gradient is calculated by 325 | assuming that you have an object of a particular color, lit by a point light of a particular color 326 | to provide highlights, and ambient light of another color to illuminate shadows. The reflectivity 327 | slider makes the object more or less reflective. The more reflective an object is, the less its 328 | own color will figure into the color of the gradient.

329 | 330 |

The default values for the highlight and ambient color are meant to approximate daylight.

331 | 332 |

As a rule, the highlight should be fairly bright and the ambient light should be fairly dark.

333 | 334 |

Adjust the illumination slider to skew the palette toward light or shadows. Moving it to the 335 | left will result in bright colors, whereas moving it to the right will result in dark colors with 336 | dramatic highlights.

337 | 338 |

The highlight multiplier is meant to allow your highlight color to exceed an intensity of #ffffff 339 | for the purpose of calculating the gradient, which is good for highlights that need to be very bright 340 | but also saturated. The RGB values will be clamped to 255 in the final output. The default value 341 | (the slider all the way to the left) is a multiplier of 1.

342 |
343 | 344 |
345 | Object color:
346 | 347 |
348 |
349 |
350 | Highlight color:
351 | 352 |
353 |
354 |
355 | Ambient color:
356 | 357 |
358 |
359 |
360 | Reflectivity: (--> More reflective)
361 |
362 |
363 |
364 | Illumination: (--> Darker)
365 |
366 |
367 |
368 | Highlight Multiplier: (--> Brighter)
369 |
370 |
371 | 372 |
373 | Gradient:
374 |
375 |
376 |
377 |
378 | 379 |
380 | Preview:
381 |
382 | 383 |
384 | 385 | Download latest version from the GitHub repository. 386 | 387 | 388 | 389 | 390 | -------------------------------------------------------------------------------- /puzzle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lendrick/Gradientifier/5272deae4c66bfcbadb58a5e1e9adb4d88931918/puzzle.png -------------------------------------------------------------------------------- /rainbow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 555 | 556 | 557 | 558 | What do all these settings do?
559 |
560 | Tint color:
561 | 562 |
563 |
564 |
565 | Highlight color:
566 | 567 |
568 |
569 |
570 | Ambient color:
571 | 572 |
573 |
574 |
575 | Selected rainbow color:
576 | 577 |
578 |
579 |
580 | Adjust all colors:
581 |
582 | Reflectivity: (--> More reflective)
583 |
584 |
585 |
586 | Illumination: (--> Darker)
587 |
588 |
589 |
590 | Highlight Multiplier: (--> Brighter)
591 |
592 |
593 |
594 | Brightness:
595 |
596 |
597 |
598 | Contrast:
599 |
600 |
601 |
602 | Adjust selected color:
603 |
604 | Reflectivity: (--> More reflective)
605 |
606 |
607 |
608 | Illumination: (--> Darker)
609 |
610 |
611 |
612 | Highlight Multiplier: (--> Brighter)
613 |
614 |
615 |
616 | Brightness:
617 |
618 |
619 |
620 | Contrast:
621 |
622 |
623 |
624 | Rainbow controls:
625 |
626 | Tint (Rainbow --> Object color):
627 |
628 |
629 |
630 | Desaturate:
631 |
632 |
633 |
634 | Darken:
635 |
636 |
637 |
638 |
639 | Rainbow (before processing):
640 |
641 |

642 | Swatches:
643 |
644 | 645 |
646 |
647 | 648 |
649 | Preview:
650 |
651 | 652 |
653 | 654 | Download latest version from the GitHub repository. 655 | 656 | 657 | 658 | 659 | --------------------------------------------------------------------------------