Nov 21 2006

jQuery-Plugin – colorGradient

Veröffentlicht by . Filed under: jQuery

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.

32 responses so far

1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...
^

32 responses so far

  1. erobon 26 Apr 2007 at 2:43 pm

    Nice JQuery extension. :)

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

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

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

    thanks!

    erob

  2. Mathias Bankon 26 Apr 2007 at 3:00 pm

    You don’t need to use each to colorize your divs with the same gradient. Just use


    $(’div.footer-div’).colorize(’#fff’, ‘#000′, [1, 1, 1], ‘background-color’);

  3. erobon 05 Mai 2007 at 5:11 pm

    Tried that, it doesnt quite work here. Well, it *does* colorize all the divs using the linear algorithm, but I would like to repeat the same “linear” gradient for each matched elements…

    Is their something I missed ?

    Thanks a lot :)

    JQuery (1.1.2) version: $Date: 2007-05-01 22:41:57 -0400 (Mar, 01 mai 2007) $

  4. Mathias Bankon 05 Mai 2007 at 5:20 pm

    Well, I think, I don’t understand your problem. You have divs with class “footer-div” And you want to colorize these divs from one color to another? Or do you want to colorize other elements in these divs?

  5. Travis Dahlon 14 Jun 2007 at 3:53 am

    Yeah, i am having no luck getting a gradient background on a div. Could you include this on your example page if it works? This is awesome!

  6. Mathias Bankon 14 Jun 2007 at 7:33 pm

    Do you want a gradient background for one div? Than, this extension won’t help. You need an image to achieve this. This extension helps you to create a gradient with more than one div.

  7. Brandon Aaronon 27 Jun 2007 at 5:17 am

    Hey Mathias and Travis … I just created a new plugin for jQuery that adds a configurable gradient to the background of an element without the use of images. You can find it here: http://blog.brandonaaron.net/2007/06/26/new-plugin-gradient/

  8. [...] colorGradient, de Mathias Bank, nos permitirá crear gradientes entre dos colores dados, tanto por método lineal como trigonométrico. [...]

  9. [...] 14. ColorGradient ~ cria gradient em elementos com as cores selecionadas. [...]

  10. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  11. onnClick » Lista de Plugins jQueryon 30 Apr 2009 at 7:03 pm

    [...] ColorGradient – cria gradient em elementos com as cores [...]

  12. [...] ColorGradient – cria gradient em elementos com as cores [...]

  13. [...] colorGradient Extends jQuery to calculate colors using two different colors and a transformation method. It also allows to set these colors to given elements, using jQuery syntax. [...]

  14. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  15. 40 Plugins jQuery « Sinhorinhoon 16 Okt 2009 at 6:21 pm

    [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  16. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  17. 40 plugins para jquery | Renan Limaon 19 Okt 2009 at 12:06 pm

    [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  18. [...] Mathias Bank » jQuery-Plugin – colorGradient [...]

  19. [...] Mathias Bank » jQuery-Plugin – colorGradient [...]

  20. [...] Mathias Bank » jQuery-Plugin – colorGradient [...]

  21. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  22. [...] ColorGradient [...]

  23. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  24. [...] Mathias Bank » jQuery-Plugin – colorGradient [...]

  25. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  26. [...] Mathias Bank » jQuery-Plugin – colorGradient [...]

  27. [...] Mathias Bank » jQuery-Plugin – colorGradient [...]

  28. [...] ColorGradient ~ cria gradient em elementos com as cores [...]

  29. [...] 14. ColorGradient ~ cria gradient em elementos com as cores selecionadas. [...]

  30. [...] 14. ColorGradient ~ cria gradiente em elementos com as cores selecionadas. [...]

  31. Nuevos plugins para jQuery | MarcosBLon 21 Jul 2011 at 9:37 am

    [...] hermano de jqModal, es un plugin para añadir efectos de arrastrar y soltar (darg & drop)colorGradient, de Mathias Bank, nos permitirá crear gradientes entre dos colores dados, tanto por método lineal [...]

  32. Os Melhores Plugins jQuery | Escola PHPon 14 Nov 2011 at 7:45 pm

    [...] ColorGradient: cria gradient em elementos com as cores selecionadas. [...]

Trackback URI | Comments RSS

Hinterlasse eine Antwort