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: Added glow effect using maskFilter #2129

Merged
merged 20 commits into from
Oct 29, 2022

Conversation

dipakp2726
Copy link
Contributor

@dipakp2726 dipakp2726 commented Oct 28, 2022

Description

A new paint effect for glowing effects using maskFilter.

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 #1027

@munsterlander
Copy link
Contributor

How do I change the size and color of the glow effect? Glow is supposed to be like a neon light, right?

@dipakp2726
Copy link
Contributor Author

dipakp2726 commented Oct 28, 2022

Screen.Recording.2022-10-28.at.10.02.01.PM.mov
Screen.Recording.2022-10-28.at.10.19.04.PM.mov

@munsterlander
Copy link
Contributor

Awesome!

Copy link
Contributor

@st-pasha st-pasha left a comment

Choose a reason for hiding this comment

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

Very nice addition!

But it seems like this needs to have a well-considered documentation. For example, the effect applies to shapes but not sprites. It makes a certain paint glow -- so the component has to be drawing something with a paint. We need to investigate how it would apply to "stroke" paints, or to transparent paints (say, can I draw a transparent outline of a sprite and make that outline glow?)

packages/flame/lib/src/effects/glow_effect.dart Outdated Show resolved Hide resolved
packages/flame/lib/src/effects/glow_effect.dart Outdated Show resolved Hide resolved
@dipakp2726
Copy link
Contributor Author

dipakp2726 commented Oct 29, 2022

We need to investigate how it would apply to "stroke" paints

example on stroke paints

Screen.Recording.2022-10-29.at.9.09.28.AM.mov

@dipakp2726
Copy link
Contributor Author

say, can I draw a transparent outline of a sprite and make that outline glow?)

example on outline.
ps: it not exact outline.

Screen.Recording.2022-10-29.at.9.24.47.AM.mov

@spydon spydon changed the title feat: added glow effect using maskFilter feat: Added glow effect using maskFilter Oct 29, 2022
@spydon
Copy link
Member

spydon commented Oct 29, 2022

There should also be tests and docs for it (with an interactive example), but other than that it looks good!

@dipakp2726
Copy link
Contributor Author

Screen.Recording.2022-10-29.at.4.25.12.PM.mov

doc/flame/effects.md Outdated Show resolved Hide resolved
doc/flame/effects.md Outdated Show resolved Hide resolved
doc/flame/examples/lib/glow_effect.dart Outdated Show resolved Hide resolved
packages/flame/lib/src/effects/glow_effect.dart Outdated Show resolved Hide resolved
dipakp2726 and others added 3 commits October 29, 2022 20:03
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
@spydon spydon merged commit bcecd3c into flame-engine:main Oct 29, 2022
@st-pasha
Copy link
Contributor

Oh lol -- I just realized that this filter replaces the color with a glow. So if you had a shape with a solid color before, that color will now disappear and there will only be glow.

Perhaps we could mark this effect as @experimental for now, and then figure out whether we need a different approach, or just document this behavior carefully?

@dipakp2726
Copy link
Contributor Author

dipakp2726 commented Oct 30, 2022

if we use BlurStyle.solid then both color and glow will stay.

@st-pasha
Copy link
Contributor

Yeah, but it would hardly look like a glow then -- more like a blurred-out shape.
For a "real" glow I think we need a second paint.

@spydon
Copy link
Member

spydon commented Oct 30, 2022

Oh lol -- I just realized that this filter replaces the color with a glow. So if you had a shape with a solid color before, that color will now disappear and there will only be glow.

Perhaps we could mark this effect as @experimental for now, and then figure out whether we need a different approach, or just document this behavior carefully?

We should make the effect target a color then right? So that the component can have several colors defined.
It doesn't really fit that well in with how the PaintProvider is created in this PR.
Any ideas of how to improve on this?

@st-pasha
Copy link
Contributor

I guess the first thing we have to acknowledge is that "glow effect" is not an Effect. We use the term "Effect" to describe a change in some property over time. At the same time, a glow "effect" is a static change in appearance of the target.
A more appropriate term here would probably be Decoration

@spydon
Copy link
Member

spydon commented Oct 30, 2022

Maybe it could be modified to be pulsating or such? But yeah, maybe this shouldn't have been an effect at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Glow effect
4 participants