109 lines
2.7 KiB
MonkeyC
109 lines
2.7 KiB
MonkeyC
import Toybox.Graphics;
|
|
import Toybox.Lang;
|
|
import Toybox.WatchUi;
|
|
|
|
class IMark extends Drawable {
|
|
|
|
var CenterShift as [Float, Float];
|
|
var Color as ColorType;
|
|
var InnerRadius as Float = 0.9;
|
|
var Radius as Float;
|
|
var Seconds as Number;
|
|
|
|
typedef MarkParams as {
|
|
:Identifier as Object,
|
|
:Seconds as Number,
|
|
:Color as ColorType,
|
|
:HandsParams as IHands.HandsParams,
|
|
};
|
|
|
|
enum MarkType {
|
|
START_MARK,
|
|
PRIMARY_MARK,
|
|
SECONDARY_MARK,
|
|
TERTIARY_MARK,
|
|
}
|
|
|
|
enum MarkStyleType {
|
|
LINE_MARK,
|
|
DOUBLE_LINE_MARK,
|
|
DOT_MARK,
|
|
ARABIC_MARK,
|
|
ROMAN_MARK,
|
|
EMPTY_MARK,
|
|
}
|
|
|
|
static function getMark(style as MarkStyleType, options as MarkParams) as IMark? {
|
|
switch (style) {
|
|
case LINE_MARK:
|
|
return new LineMark(options);
|
|
case DOUBLE_LINE_MARK:
|
|
return new DoubleLineMark(options);
|
|
case DOT_MARK:
|
|
return new DotMark(options);
|
|
case ARABIC_MARK:
|
|
return new ArabicMark(options);
|
|
case ROMAN_MARK:
|
|
return new RomanMark(options);
|
|
case EMPTY_MARK:
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function initialize(options as MarkParams) {
|
|
Drawable.initialize({:identifier => options[:Identifier]});
|
|
|
|
CenterShift = getOrElse(getOrElse(options[:HandsParams], {})[:CenterShift], [0.0, 0.0]);
|
|
Color = getOrElse(options[:Color], Graphics.COLOR_WHITE);
|
|
Radius = getOrElse(options[:Radius], 1.0);
|
|
Seconds = options[:Seconds];
|
|
}
|
|
|
|
function draw(dc as Dc) as Void {
|
|
var center = getCenter(dc, CenterShift);
|
|
var length = min(center[0], center[1]);
|
|
drawMark(dc, center[0], center[1], length);
|
|
}
|
|
|
|
function drawMark(dc as Dc, x as Float, y as Float, length as Float) as Void {}
|
|
|
|
function getAngle() as Float {
|
|
return Math.toRadians(Seconds * 6.0 - 90);
|
|
}
|
|
|
|
function getHours() as Number? {
|
|
if (Seconds % 5 != 0) {
|
|
return null;
|
|
}
|
|
|
|
var hours = Seconds / 5;
|
|
if (hours == 0) {
|
|
return 12;
|
|
}
|
|
|
|
return hours;
|
|
}
|
|
|
|
function getMarkType() as MarkType {
|
|
switch (Seconds) {
|
|
case 0:
|
|
return START_MARK;
|
|
case 15:
|
|
case 30:
|
|
case 45:
|
|
return PRIMARY_MARK;
|
|
case 5:
|
|
case 10:
|
|
case 20:
|
|
case 25:
|
|
case 35:
|
|
case 40:
|
|
case 50:
|
|
case 55:
|
|
return SECONDARY_MARK;
|
|
default:
|
|
return TERTIARY_MARK;
|
|
}
|
|
}
|
|
} |