Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
svg color inside fabricjs canvas not changing

i'm trying to change svg path's fill which is inside fabricjs canvas.

enter image description here

using this function

function changeColor(material) {

    console.log(svgGroup[0].fill)
    console.log(material);
    if (material == 'base') {
        svgGroup[0].fill = '#000000';
        console.log(svgGroup[0].fill)
    }
    texture.needsUpdate = true;
    object.children[0].material = textureMaterial;
    canvas.renderAll();
}

but it doesn't updated automatically

enter image description here

anyone have any idea why? any thought would be helpful

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i found the solution, the problem iwas i didn't set the color correctly. instead of doing this

svgGroup[0].fill = '#000000';

it should've use this

svgGroup._objects.forEach(obj => {
    if (obj.id == material) {
        obj.set('fill', color);
    }
});

that way it is rendered when renderAll() is called

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda