jQuery-Plugin – colorGradient

I needed a plugin, that will create a list of colors. This colors should be calculated by using two given colors (start and end color) and a calculation method like „linear“ or „trigonometrical“. So I have started to create a new jQuery plugin (yes, it makes fun), which could solve this. It extends jQuery with these functions:

  • hex2rgb
  • rgb2hex
  • checkRGB
  • checkHex
  • calculateColor
  • and other helper functions

I have also added a function to set the color at jQuery objects. You can call…

$(‚#list1 li‘).colorize(‚#ff1313‘, ‚#00F400‘, [1,1,1],“color“);

… to set the color attribute for all list elements in „#list1“ to colors, starting with ‚#ff1313‘, ending with ‚#00F400‘ and using linear transformation.

The code can be downloaded here. And there is also an example.

33 Kommentare zu “jQuery-Plugin – colorGradient

  1. Nice JQuery extension. :)

    Is their a way to make it working with .each ?

    Here’s my code:
    $(document).ready( function () {
    $(this).colorize(‚#fff‘, ‚#000‘, [1, 1, 1], ‚background-color‘);

    Is it possible to have all selected elements colorized using the same gradient ?



Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *