Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
for (i=0; i< 720; i++) {
angle = 0.1 * i;
x=(1+angle)*Math.cos(angle);
y=(1+angle)*Math.sin(angle);
context.lineTo(x, y);
}
public class SpiralView extends View{
public SpiralView(Context context){
super(context);
}
@Override
protected void onDraw(Canvas canvas){
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setStrokeWidth(2);
paint.setStyle(Paint.Style.STROKE);
canvas.drawPaint(paint);
paint.setColor(Color.parseColor("#da4747"));
super.onDraw(canvas);
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
int left = centerX - 20;
int right = centerX + 20;
int top = centerY - 20;
int bottom = centerY + 20;
int startAngle = 0;
int arcAngle = 180;
int amount = 20; // amount of twists
for(int i = 0; i < amount * 2; i++){
canvas.drawArc(left, top, right, bottom, startAngle, arcAngle, false, paint);
if(i%2 == 0){
right = right + 20;
top = top - 20;
}
else{
left = left - 20;
bottom = bottom + 20;
}
startAngle = startAngle + arcAngle;
}
}
}
for(int i = 0; i < amount * 2; i++){
canvas.drawArc(left, top, right, bottom, startAngle, arcAngle, false, paint);
top -= 10;
bottom += 10;
if(i%2 == 0){
right = right + 20;
}
else{
left = left - 20;
}
startAngle = startAngle + arcAngle;
}