https://github.com/abhi9-akr/Radar-Secu ... blob/main/ Radar%20Security%20System/sketch_171117a/sketch_171117a.pde#L63
Код: Выделить всё
var TWO_PI : Float = (PI.toFloat() * 2.0f);
fun fromLTWH(left : Float, top : Float, width : Float, height : Float) : RectF {
return this.fromLTRB(left, top, left + width, top + height);
}
fun fromLTRB(left : Float, top : Float, right : Float, bottom : Float) : RectF {
return RectF(left, top, right, bottom);
}
fun arc(canvas: Canvas, x: Float, y: Float, width: Float, height: Float, startAngle: Float, sweepAngle: Float) {
var rect = fromLTWH((x - width / 2.0f), (y - height / 2.0f), width, height);
canvas.drawArc(rect, startAngle, sweepAngle, false, this)
}
Код: Выделить всё
arc(canvas, 0f, 0f, (width + 0.0f), (width + 0.0f), 0f, TWO_PI);
arc(canvas, 0f, 0f, (width * 0.20f), (width * 0.20f), 0f, TWO_PI);
arc(canvas, 0f, 0f, (width * 0.40f), (width * 0.40f), 0f, TWO_PI);
arc(canvas, 0f, 0f, (width * 0.60f), (width * 0.60f), 0f, TWO_PI);
arc(canvas, 0f, 0f, (width * 0.80f), (width * 0.80f), 0f, TWO_PI);
[img]https://i.stack.imgur .com/46kh8.png[/img]
Что не так с кодом? Почему круги не рисуются правильно?
Подробнее здесь: https://stackoverflow.com/questions/782 ... -correctly