plectrum

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit adbbb28b0878d10daf3c7ca01f786f6763c0e9f2
parent ec16abe1cada4074464c217a84772ce1647a4574
Author: gstraube <gstraube@mailbox.org>
Date:   Sat, 21 Oct 2017 17:36:48 +0200

Round deviation to the nearest mark

Diffstat:
Mapp/src/main/java/com/github/cythara/CanvasPainter.java | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/src/main/java/com/github/cythara/CanvasPainter.java b/app/src/main/java/com/github/cythara/CanvasPainter.java @@ -136,7 +136,10 @@ class CanvasPainter { private void drawIndicator() { float deviation = (float) pitchDifference.deviation; - float xPos = x + (deviation * gaugeWidth / MAX_DEVIATION); + int rounded = Math.round(deviation); + int nearest = Math.round(rounded / 10f) * 10; + + float xPos = x + (nearest * gaugeWidth / MAX_DEVIATION); String text = "|"; canvas.drawText(text, xPos - numbersPaint.measureText(text) / 2F, y + 30, numbersPaint);