Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suspect wrong color filter mode #31

Open
xloc opened this issue May 19, 2022 · 4 comments
Open

suspect wrong color filter mode #31

xloc opened this issue May 19, 2022 · 4 comments
Labels
good first issue Good for newcomers

Comments

@xloc
Copy link

xloc commented May 19, 2022

I had a problem when using the color property to re-color the image and found changing the blend mode from srcATop to srcIn fix the problem for me. Is this a bug?

if use color

Container(
  decoration: const BoxDecoration(
    image: DecorationImage(
      image: Svg(
        'assets/grid.svg', 
        size: Size.square(40), 
        color: Colors.black12,
      ),
      repeat: ImageRepeat.repeat,
    ),
  ),
  child: Center(child: Text("Hello", style: TextStyle(fontSize: 80))),
)

image

if change it to srcIn

Container(
  decoration: const BoxDecoration(
    image: DecorationImage(
      image: Svg('assets/grid.svg', size: Size.square(40)),
      repeat: ImageRepeat.repeat,
      colorFilter: ColorFilter.mode(Colors.black12, BlendMode.srcIn),
    ),
  ),
  child: Center(child: Text("Hello", style: TextStyle(fontSize: 80))),
)

image

@yang-f
Copy link
Owner

yang-f commented May 30, 2022

What is the specific problem? Can you describe it in detail?

@xloc
Copy link
Author

xloc commented May 30, 2022

Yes. If you see the example above, I was attempting to use an svg as the background, and I wanted to recolor the strokes to a mild color Colors.black12. I tried to use the color attribute of Svg to recolor the image, but that didn't work. The strokes are still in black. My expectation is the below one where the grid lines are colored in light gray.

@yang-f
Copy link
Owner

yang-f commented Jun 1, 2022

Can u provide the source code of grid.svg

@yang-f yang-f added the good first issue Good for newcomers label Jun 1, 2022
@xloc
Copy link
Author

xloc commented Jun 6, 2022

Sure. Here it is

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32"
  fill="none" stroke="#000000" stroke-opacity="0.04">
  <path d="M0 .5H31.5V32" />
</svg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants