initial commit

This commit is contained in:
2025-10-09 14:37:45 +03:00
commit d75a0b235d
15 changed files with 341 additions and 0 deletions

View File

@ -0,0 +1,48 @@
import Toybox.Graphics;
import Toybox.Lang;
class SimpleHands extends Hands {
var mColor as ColorType;
var mSecondsColor as ColorType;
typedef SimpleHandsParams as {
:HandsParams as Hands.HandsParams,
:Color as ColorType,
:SecondsColor as ColorType,
};
function initialize(options as SimpleHandsParams) {
Hands.initialize(getOrElse(options[:HandsParams], {}));
mColor = getOrElse(options[:Color], Graphics.COLOR_WHITE);
mSecondsColor = getOrElse(options[:SecondsColor], Graphics.COLOR_RED);
}
function drawHand(dc as Dc, x as Float, y as Float, angle as Float, length as Float, handType as Hands.HandType) as Void {
var rad = (angle - 90) * Math.PI / 180.0;
var color = getColor(handType);
length *= getLenght(handType);
dc.setColor(color, color);
dc.drawLine(x, y, x + length * Math.cos(rad), y + length * Math.sin(rad));
}
private function getColor(handType as Hands.HandType) as ColorType {
switch (handType) {
case Hands.SECONDS:
return mSecondsColor;
default:
return mColor;
}
}
private function getLenght(handType as Hands.HandType) as Float {
switch (handType) {
case Hands.HOURS:
return 0.6;
default:
return 0.9;
}
}
}