3

I am trying to draw a dynamic radar, but I can't get the cone shape to draw properly. I can get the two lines to work fine, but I can't get the shading between them to work.

My Goal:

enter image description here

What I am getting:

enter image description here

And this is my code:

paint.setColor(Color.WHITE);
RectF oval = new RectF(0,0,200,200);
canvas.drawArc(oval,(float)globalAzimuth+26, (float)globalAzimuth-26,false,paint);

globalAzimuth is the direction the phone is facing. The radar spins as the phone does. The lines spin fine and synchorinized, but the arc just gets bigger and is obviously terribly off.

Does anyone know how to do this?

1 Answer 1

1

It looks like you're treating the parameter sweepAngle as a stop angle. It should be the number of degrees to sweep, clockwise from startAngle.

From the docs:

sweepAngle : Sweep angle (in degrees) measured clockwise

Edit : It looks like you could use a constant 52 as the sweep angle, since you're just going 26 degrees in either direction from globalAzimuth(although your lines appear closer together than 52 degrees, so I'm not sure). If you do, you'll need to keep in mind that it goes clockwise, so your startAngle should be globalAzimuth - 26, rather than plus.

2
  • Thanks! This answered my question. Note: It is 52 degrees, but I manually drew the first pic so that probably isn't 52 degrees. Mar 7, 2013 at 22:35
  • That makes sense. I was staring at it for a minute, wondering how you were possibly getting that with a 52 degree spread. Glad I could help.
    – Geobits
    Mar 8, 2013 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.