question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infection mode does not apply color on image shapes

See original GitHub issue

Describe the bug When infection mode is enabled, particles.shape.type = ‘image’, and images that have the replaceColor = true property, the infection stages do not apply color to the particles.

To Reproduce Steps to reproduce the behavior:

  1. Use SVG images and set 'replaceColor: true
  2. Enable infections
  3. Set particle type to image.
  4. Observe no color change for infected particles.

Expected behavior Particles with SVG and replaceColor should change color when infected.

Screenshots Observation of no coloring on nodes: image Changing type to ‘circle’: image

Desktop (please complete the following information):

  • OS: Linux KDE Plasma X11, Windows 10
  • Browser Chrome, Firefox
  • Version
    • Chrome 84.x
    • Firefox 80.x
    • Edge 18.x

Additional context Tested tsParticles versions: 1.17.0, 1.17.10, 1.18.0-alpha.14

This Official CodePen suggests this is fault of upgrades in Chrome / FireFox.

Options Object:

{
      fpsLimit: 60,
      infection: {
        enable: true,
        infections: 10,
        cure: true,
        stages: [
          {
            color: "#ff0000",
            duration: 10
          },
          {
            color: "#00ff00",
            duration: 10,
            rate: 0
          },
          {
            color: "#ffffff",
            duration: 1,
            rate: 0,
            infectedStage: 0
          }
        ]
      },
      particles: {
        number: {
          value: 70,
          density: {
            enable: true,
            value_area: 800
          }
        },
        color: {
          value: "#ffffff"
        },
        shape: {
          // type: "circle",
          type: 'image',
          image: [
            {
              src: "https://particles.matteobruni.it/images/sars-cov-2.png",
              // src: "/img/landingpage/desktop-gray_900.svg",
              replaceColor: true
            }

          ]
        },
        opacity: {
          value: 0.8,
          random: false,
          anim: {
            enable: false,
            speed: 3,
            opacity_min: 0.1,
            sync: false
          }
        },
        size: {
          value: 15,
          random: false,
          anim: {
            enable: false,
            speed: 20,
            size_min: 0.1,
            sync: false
          }
        },
        line_linked: {
          enable: false,
          distance: 150,
          color: "#ffffff",
          opacity: 0.4,
          width: 1
        },
        move: {
          collisions: true,
          enable: true,
          speed: 10,
          direction: "none",
          random: false,
          straight: false,
          out_mode: "bounce",
          attract: {
            enable: false,
            rotateX: 600,
            rotateY: 1200
          }
        }
      },
      interactivity: {
        detect_on: "canvas",
        events: {
          onhover: {
            enable: false,
            mode: "repulse"
          },
          onclick: {
            enable: false,
            mode: "push"
          },
          resize: true
        },
        modes: {
          grab: {
            distance: 400,
            line_linked: {
              opacity: 1
            }
          },
          bubble: {
            distance: 400,
            size: 40,
            duration: 2,
            opacity: 0.8,
            speed: 3
          },
          repulse: {
            distance: 200
          },
          push: {
            particles_nb: 4
          },
          remove: {
            particles_nb: 2
          }
        }
      },
      retina_detect: true
    }```

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
matteobrunicommented, Jan 5, 2022

So changing svg colors through replaceColor is not supported? In that case, I will probably switch to the char type instead of image and use the Font Awesome font.

Exactly, images are good for performances when they are static since there’s less to draw on the canvas, but every color change is an image to load and that loading is bad at runtime.

Using the font could be good, but try to see if the performances are still good since the text is a bit slower than the image

0reactions
Redsebcommented, Jan 5, 2022

So changing svg colors through replaceColor is not supported? In that case, I will probably switch to the char type instead of image and use the Font Awesome font.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Color and Shape Settings - Esko
Trap Color Intensity. By default, PowerTrapper uses the full color of the object to spread in the trap (100% trap color intensity). However,...
Read more >
Add fills to text and shape layers – Figma Help Center
Paints are colors, gradients, or images. Fills are just one of the ways you can use paints in Figma. Apply paints to text...
Read more >
Use basic color controls in Motion - Apple Support
In Motion, the color controls set the color of objects such as shapes, text, replicators, particles, and gradients.
Read more >
Add a fill or effect to a shape or text box - Microsoft Support
Do one of the following: To add or change a fill color, click the color you want. To choose no color, click No...
Read more >
Apply colors and gradients | Illustrator on the iPad
Fill color is the color contained in the shape object and stroke is the border of the shape object. The fill or stroke...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found