Files
wf/source/Hands/IHands.mc
2025-10-09 14:37:45 +03:00

51 lines
1.3 KiB
MonkeyC

import Toybox.Graphics;
import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;
class IHands extends Drawable {
private var mHoursLength = 1.0;
private var mMinutesLength = 1.0;
private var mSecondsLength = 1.0;
public enum HandType {
HOURS,
MINUTES,
SECONDS,
}
function initialize(options) {
WatchUi.Drawable.initialize(options);
}
function draw(dc as Dc) as Void {
var now = System.getClockTime();
var mid = getCenter(dc);
var length = min(mid[0], mid[1]);
System.println(mid);
System.println(length);
var hourAngle = (now.hour % 12 + now.min / 60.0) * 30.0;
drawHand(dc, mid[0], mid[1], hourAngle, length * mHoursLength, HOURS);
var minutesAngle = now.min * 6.0;
drawHand(dc, mid[0], mid[1], minutesAngle, length * mMinutesLength, MINUTES);
var secondsAngle = now.sec * 6.0;
drawHand(dc, mid[0], mid[1], secondsAngle, length * mSecondsLength, SECONDS);
}
function drawHand(
dc as Graphics.Dc,
x as Float,
y as Float,
angle as Float,
length as Float,
handType as HandType) {}
function getCenter(dc as Dc) as [Float, Float] {
return [dc.getWidth() / 2.0, dc.getHeight() / 2.0];
}
}