Skip to content

Instantly share code, notes, and snippets.

@boredzo
Created January 23, 2013 11:04
Show Gist options
  • Save boredzo/4604459 to your computer and use it in GitHub Desktop.
Save boredzo/4604459 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