Last active
April 28, 2017 08:37
-
-
Save lgyjg/196e386f0e50b9a6edd8eb1f4205bc8a to your computer and use it in GitHub Desktop.
用点绘制黄金螺旋线
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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