Skip to content

Instantly share code, notes, and snippets.

@skeeet
Forked from boredzo/gist:4604459
Created September 19, 2016 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skeeet/8cb0e34811229883d58f704640cc2658 to your computer and use it in GitHub Desktop.
Save skeeet/8cb0e34811229883d58f704640cc2658 to your computer and use it in GitHub Desktop.
Two-color angle gradient in Core Image
kernel vec4 coreImageKernel(__color startColor, __color endColor)
{
vec2 point = destCoord();
float angle = atan(point.y, point.x) + radians(180.0);
//Start from the upper middle, not the left middle
angle += radians(90.0);
angle = mod(angle, radians(360.0));
float fraction = angle / radians(360.0);
vec4 resultColor = startColor * (1.0 - fraction) + endColor * fraction;
return resultColor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment