Files
wf/source/Hands/SimpleHands.mc
2025-11-06 18:00:29 +02:00

36 lines
1022 B
MonkeyC

import Toybox.Graphics;
import Toybox.Lang;
class SimpleHands extends IHands {
function initialize(options as IHands.HandsParams) {
IHands.initialize(options);
}
function drawHand(dc as Dc, x as Float, y as Float, angle as Float, length as Float, handType as IHands.HandType) as Void {
var color = getColor(handType);
angle = Math.toRadians(angle - 90);
length *= getLenght(handType);
dc.setColor(color, color);
dc.drawLine(x, y, x + length * Math.cos(angle), y + length * Math.sin(angle));
}
private function getColor(handType as IHands.HandType) as ColorType {
switch (handType) {
case SECONDS_HAND:
return SecondsColor;
default:
return Color;
}
}
private function getLenght(handType as IHands.HandType) as Float {
switch (handType) {
case HOURS_HAND:
return 0.7;
default:
return 1.0;
}
}
}