Skip to content

Comments

Snowflakes fading#1

Open
lavafrai wants to merge 9 commits intoSkeptick:masterfrom
lavafrai:feat_snowflakes_fading
Open

Snowflakes fading#1
lavafrai wants to merge 9 commits intoSkeptick:masterfrom
lavafrai:feat_snowflakes_fading

Conversation

@lavafrai
Copy link

I think it should be useful in this library. Added the fading parameter, which determines that snowflakes should smoothly disappear.

image

@Skeptick
Copy link
Owner

Hi! Great suggestion!
The meaning of the fading parameter isn’t very clear. Perhaps it would make sense to use a value between 0f and 1f, where 0f means snowflakes have the minimum alpha value at the moment they appear, and 1f means snowflakes retain their maximum alpha value until they reach the bottom of the canvas.

Alternatively, we could even use two parameters: one for the starting point of fading and another for the endpoint where the alpha reaches 0.

Possible names could be fadeStartThreshold and fadeEndThreshold.

For example, if:

fadeStartThreshold = 0.5f
fadeEndThreshold = 0.8f

The snowflakes would start fading at the middle of the canvas height and become fully transparent at 80% of the canvas height.

@lavafrai
Copy link
Author

lavafrai commented Dec 12, 2024

Oh, yes, the first option looks smarter than the way I did it. I'm implementing it now

@lavafrai
Copy link
Author

Everything is ready. It seems to me a good solution to use fadeThreshold and fadeThresholdSpread.
fadeThreshold - point from 0 to 1 where snowflakes start to disappear
fadeThresholdSpread - the distance from fadeThreshold relative to the height of the view at which all snowflakes disappear

For exaplme with fadeThreshold == 1 any disappearances will be disabled and fadeThresholdSpread can be greater than 1 - fadeThreshold to make more smooth fades

image

@Skeptick
Copy link
Owner

Skeptick commented Dec 13, 2024

Great idea!
I reviewed the result. Due to the alphaOffset parameter, the snowflakes don’t change transparency smoothly enough and at some point their transparency changes suddenly. Maybe we could remove this parameter altogether? I don’t think any randomization is needed here.

2024-12-13.15.46.48.mov

@lavafrai
Copy link
Author

Truth. I didn't notice it on the dim screen. I think it's bad idea to remove this, since this way the fading begins to look unnatural, however, I solved the problem.

@Skeptick
Copy link
Owner

It’s also necessary to apply clipRect if fadeThreshold + fadeThresholdSpread < 1 to ensure the snowflakes don’t go beyond the boundaries.

2024-12-13.23.16.43.mov

@lavafrai lavafrai requested a review from Skeptick December 29, 2024 20:05
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.

2 participants