Skip to content

Instantly share code, notes, and snippets.

@lgyjg
Last active April 28, 2017 08:37
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 lgyjg/196e386f0e50b9a6edd8eb1f4205bc8a to your computer and use it in GitHub Desktop.
Save lgyjg/196e386f0e50b9a6edd8eb1f4205bc8a to your computer and use it in GitHub Desktop.
用点绘制黄金螺旋线
private void drawWithPoint(Canvas canvas, int deep) {
float x0 = this.getMeasuredWidth() / 2;
float y0 = this.getMeasuredHeight() / 2;
paint.setColor(Color.BLACK);
for (int i = 0; i < 6145; i++) {
double angle = i * Math.PI / 512;
double radius = 0.3 * angle;
int y = (int) Math.round(radius * angle * Math.cos(angle));
int x = (int) Math.round(radius * angle * Math.sin(angle));
canvas.drawPoint(x0 + x, y0 + y, paint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment