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; } } }