samedi 27 juin 2015

Raphaeljs image change color

I'm using Raphael.js to manipulate svg...

I have a folder with many svgs, and when the user choose one svg, the element paper.image of the raphaeljs load this svg on the "div svg selected"... Ok, this works fine, but the second step is the user change the color of this svg... Maybe the second steps doesn't worked for me because the image tag doesn't accepts fill or stroke (correct?). I've looked on the documentation a way to place on a sgv tag or object but not worked... Someone can help me? I need to change the color of a SVG generated with Adobe illustrator. If somebody knows other library or how can I change the color on pure javascript... Any help will be very appreciated!

var corEscolhida ='';
var group =drawing.set();
var text = null, imagemBadge=null;

$(document).ready(function() {
    try{
       var drawing = Raphael( "drawing");
       text = drawing.text(280, 140, "Hello Word")
            .attr({
                'fill': "#040404",
                'font-size':'50px',
                'font-family':   FontLike();
             });
        group.push(text );
        imagemBadge=drawing.image(getBadger(), 100, 100, 100, 100);
        group.push(imagemBadge );
     }catch(err){
         console.log(err);
     }
 });
 $("[name='cores']").click(function () {
    corEscolhida = $(this).css('background-color');
    text.attr("fill", corEscolhida);//it's work

    imagemBadge.attr('stroke', corEscolhida);
    imagemBadge.attr('fill', corEscolhida);
 ![enter image description here][1]});

Aucun commentaire:

Enregistrer un commentaire