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

Wrap time in AnimatedGradientFill to keep gradient smooth #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ using namespace metal;
// Get the same UV in the range -1 to 1, so that
// 0 is in the center.
half2 rp = uv * 2.0h - 1.0h;

// Wrap the time value to prevent it from becoming too large
float wrappedTime = fmod(time, 2.0 * 3.1415927);

// Calculate the angle top this pixel, adding in time
// so it's constantly changing.
half angle = atan2(rp.y, rp.x) + time;
half angle = atan2(rp.y, rp.x) + wrappedTime;

// Send back variations on the sine of that angle, so we
// get a range of colors. The use of abs() here avoids
Expand Down