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

feat: Expose paint from svgComponent to set opacity and have opacity effects #2092

Merged
merged 11 commits into from
Oct 21, 2022

Conversation

dipakp2726
Copy link
Contributor

@dipakp2726 dipakp2726 commented Oct 17, 2022

Description

currently you can't set opacity on svgComponent as its paint is private.
exposed paint from svgComponent Using HasPaint Mixin to so can get paint and set opacity and have opacity effects

usage

 final android = SvgComponent(
      svg: svgInstance,
      position: Vector2.all(100),
      size: Vector2.all(100),
    );

 android.paint.color =   android.paint.color.withOpacity(.6);

Checklist

  • The title of my PR starts with a [Conventional Commit] prefix (fix:, feat:, docs: etc).
  • I have followed the [Contributor Guide] when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • No, this PR is not a breaking change.

Related Issues

closes #2091 set opacity on SvgComponent

@dipakp2726 dipakp2726 changed the title feat : expose paint from svg to set opacity feat: expose paint from svg to set opacity Oct 17, 2022
@ufrshubham
Copy link
Member

I think a better idea would be to make SvgComponent use HasPaint so that it works with OpacityEffect as well.

@dipakp2726
Copy link
Contributor Author

dipakp2726 commented Oct 17, 2022

ok i will add it with HasPaint

@dipakp2726 dipakp2726 changed the title feat: expose paint from svg to set opacity feat: expose paint from svgComponent to set opacity and have opacity effects Oct 17, 2022
@dipakp2726 dipakp2726 changed the title feat: expose paint from svgComponent to set opacity and have opacity effects feat: expose paint from svgComponent to set opacity Oct 17, 2022
@dipakp2726 dipakp2726 changed the title feat: expose paint from svgComponent to set opacity feat: expose paint from svgComponent to set opacity and have opacity effects Oct 17, 2022
@dipakp2726
Copy link
Contributor Author

exposed paint With HasPaint mixin

Copy link
Member

@ufrshubham ufrshubham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since SvgComponent now has a paint, we can get rid of _paint from Svg

packages/flame_svg/lib/svg_component.dart Outdated Show resolved Hide resolved
packages/flame_svg/lib/svg_component.dart Show resolved Hide resolved
packages/flame_svg/lib/svg.dart Outdated Show resolved Hide resolved
packages/flame_svg/lib/svg.dart Outdated Show resolved Hide resolved
packages/flame_svg/lib/svg_component.dart Outdated Show resolved Hide resolved
Copy link
Contributor Author

@dipakp2726 dipakp2726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took default value of paint from here

@dipakp2726 dipakp2726 requested a review from spydon October 21, 2022 07:35
@spydon spydon changed the title feat: expose paint from svgComponent to set opacity and have opacity effects feat: Expose paint from svgComponent to set opacity and have opacity effects Oct 21, 2022
@spydon spydon enabled auto-merge (squash) October 21, 2022 12:22
@spydon spydon merged commit bedacd0 into flame-engine:main Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set opacity on SvgComponent
4 participants