fix: Fade TextComponent shadows and fill together under OpacityEffect - #4042
Closed
Yasser-Ameur wants to merge 3 commits into
Closed
fix: Fade TextComponent shadows and fill together under OpacityEffect#4042Yasser-Ameur wants to merge 3 commits into
Yasser-Ameur wants to merge 3 commits into
Conversation
TextPaint.copyWithPaint only swapped the style's foreground for the component's paint, so shadows kept their alpha while the glyphs faded, and the first paint change replaced the text color with the default white paint. The shadows now scale with the paint's alpha, the paint starts from the style's color, and every paint change is derived from the renderer the user gave, which textRenderer now returns; the copy with the paint applied is paintedTextRenderer, used for drawing by TextComponent and TextBoxComponent. Closes flame-engine#4013
Member
|
This solution doesn't work for the following cases:
And since we already had an agent running for this issue, this PR has been superseded by #4043 which takes these things into consideration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When an
OpacityEffectruns on aTextComponentwhoseTextPaintstyle definesshadows, the glyphs fade but the shadows keep their original alpha, and the first paint change replaces the text colour with the component's default white paint, so coloured text snaps to white as the fade begins (#4013).TextPaint.copyWithPaintonly swapped the style'sforegroundfor the component's paint, sostyle.shadowsnever followed the paint's alpha. The component also derived each new renderer from the previous derived one, so any per-update scaling would have compounded.This PR:
TextPaint.copyWithPaint, keeping the paint itself as the foreground so colour filters and other paint properties still apply;textRenderernow returns that renderer rather than the last derived copy, which also makestextRenderer = textRenderer.copyWith(...)safe after an effect has run; the copy with the paint applied is the new@internalpaintedTextRenderer, used for drawing byTextComponentandTextBoxComponent;textRendereris set, so the fade starts from the text's own colour instead of white. Settingpaint.colorafterwards still overrides it; note that assigning a newtextRendererreseeds it.The new tests run
OpacityEffect.fadeOutfor half its duration and check that the fill keeps its RGB at half alpha and the shadow keeps its RGB at half its own alpha, then that both reach zero; and that atextRendererround-trip between two opacity changes keeps the original colour and shadow and scales only once. Both fail onmainand pass here.Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Closes #4013