Skip to content

Instantly share code, notes, and snippets.

@bigstark
Created April 6, 2017 17:02
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 bigstark/da686779d465fddbc4a0f371faa9da7a to your computer and use it in GitHub Desktop.
Save bigstark/da686779d465fddbc4a0f371faa9da7a to your computer and use it in GitHub Desktop.
// "positive" is increasing positively horizontally
private float[] getHorizontalCenter(int width, int height, boolean positive) {
float x = (width - 2 * radius) * (positive ? frame : 1 - frame) + radius;
float y = positive ? radius : height - radius;
return new float[] {x, y};
}
// "negative" is increasing negatively vertically
private float[] getVerticalCenter(int width, int height, boolean negative) {
float x = negative ? width - radius : radius;
float y = (height - 2 * radius) * (negative ? frame : 1 - frame) + radius;
return new float[] {x, y};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment