initial commit
This commit is contained in:
78
source/Background/Marks/IMark.mc
Normal file
78
source/Background/Marks/IMark.mc
Normal file
@ -0,0 +1,78 @@
|
||||
import Toybox.Graphics;
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
|
||||
class IMark extends Drawable {
|
||||
|
||||
var CenterShift as [Float, Float];
|
||||
var Color as ColorType;
|
||||
var Radius as Float;
|
||||
var Seconds as Number;
|
||||
|
||||
typedef MarkParams as {
|
||||
:Identifier as Object,
|
||||
:Type as MarkType,
|
||||
:Seconds as Number,
|
||||
:Color as ColorType,
|
||||
:HandsParams as IHands.HandsParams,
|
||||
};
|
||||
|
||||
enum MarkType {
|
||||
START_MARK,
|
||||
PRIMARY_MARK,
|
||||
SECONDARY_MARK,
|
||||
TERTIARY_MARK,
|
||||
}
|
||||
|
||||
enum MarkStyleType {
|
||||
LINE_MARK,
|
||||
DOT_MARK,
|
||||
ARABIC_MARK,
|
||||
}
|
||||
|
||||
static function getMark(style as MarkStyleType) as IMark {
|
||||
switch (style) {
|
||||
case LINE_MARK:
|
||||
default:
|
||||
return new LineMark({});
|
||||
}
|
||||
}
|
||||
|
||||
function initialize(options as MarkParams) {
|
||||
Drawable.initialize({:identifier => options[:Identifier]});
|
||||
|
||||
CenterShift = getOrElse(getOrElse(options[:HandsParams], {}), [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);
|
||||
drawMark(dc, center[0], center[1]);
|
||||
}
|
||||
|
||||
function drawMark(dc as Dc, x as Float, y as Float) as Void {}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
source/Background/Marks/LineMark.mc
Normal file
20
source/Background/Marks/LineMark.mc
Normal file
@ -0,0 +1,20 @@
|
||||
import Toybox.Graphics;
|
||||
import Toybox.Lang;
|
||||
import Toybox.WatchUi;
|
||||
|
||||
class LineMark extends IMark {
|
||||
|
||||
var InnerRadius as Float = 0.9;
|
||||
|
||||
function initialize(options as IMark.MarkParams) {
|
||||
IMark.initialize(options);
|
||||
}
|
||||
|
||||
function drawMark(dc as Dc, x as Float, y as Float) as Void {
|
||||
var angle = Math.toRadians(Seconds * 6.0);
|
||||
|
||||
dc.setColor(Color, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawLine(x + InnerRadius * Math.cos(angle), y + InnerRadius * Math.sin(angle),
|
||||
x + Radius * Math.cos(angle), y + Radius * Math.sin(angle));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user