Skip to content

Instantly share code, notes, and snippets.

@daseyb
Created July 24, 2013 05:39
Show Gist options
  • Save daseyb/6068285 to your computer and use it in GitHub Desktop.
Save daseyb/6068285 to your computer and use it in GitHub Desktop.
//_pos is in pixel coordinates in a quad
float2 offsetFunc(float2 _pos)
{
//distance from the center (the quad is (radius + width) * 2 pixels wide)
_pos -= radius + width;
_pos /= scale;
float x = length(_pos);
//function, made in GeoGebra: http://imgur.com/zMbqAcs
float val = cos((x - currentRadius)/(width/PI)) * strength/2 + strength/2;
if(abs(x - currentRadius) > width)
val = 0;
return normalize(_pos) * val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment