Hello,
I'm trying to draw a triangle/arrow/polygon with an orientation property that moves along the edge of round watch faces, but I can't seem to get it. I feel like I'm close but can't quite get it right. I'm trying to write code that is applicable to all round watch faces, kind of feel like I'm hardcoding numbers here that won't be robust or simply my approach is wrong? Should I be using layout.xml?
Thank you for your consideration and help.
//Currently this draws large triangle/polygons spanning from onside of the screen to the other with correct orientation.
//I'd like to draw smaller/configurable arrows.
_______CODE_________
function drawArrow(dc, cx, cy, screenSize, orientation) {
var radius = size/.3;
dc.setColor(colorInput, Graphics.COLOR_TRANSPARENT);
var pt1 = convertToCartesian(center_x, center_y, orientation, radius); //First point
var pt2 = convertToCartesian(center_x, center_y, (orientation + 171 * Math.PI/180), radius); //Second point with 171 number made it look good
var pt3 = convertToCartesian(center_x, center_y, (orientation + 189 * Math.PI/180), radius); //Second point with 189 number made it look good
dc.drawLine(pt1[0], pt1[1], pt2[0], pt2[1]);
dc.drawLine(pt2[0], pt2[1], pt3[0], pt3[1]);
dc.drawLine(pt1[0], pt1[1], pt3[0], pt3[1]);
}
function convertToCartesian(cx, cy, radian, radius) {
var x = cx - radius * Math.sin(radian);
var y = cy - radius * Math.cos(radian);
return [Math.ceil(x), Math.ceil(y)];
}