Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!