I also noticed this thing everywhere where a full screen circle is involved. It kind of makes sense. The screens have a pair number of pixels in both dimensions. When you draw a circle using width/2, height…
Fractional seems to work at least in the simulator where I tried (probably fenix6 or fr955). It doesn't round it, cause you can see the difference in a few pixels as you add/subtract let's say 0.25.…
sec = ( clockTime.sec / 60.0) * Math.PI * 2;
var xh = 55*Math.sin(sec) ; var yh = -55*Math.cos(sec);
dc.fillCircle(center_x+xh,center_y+yh,7);
I know this is an old post, but it was helpful, thanks
Perhaps this will help someone else:
I had to add 0.5 to xh for the 30s position to be correct, otherwise it was off by a pixel on a Venu2. I think because it has a larger radius than the watches for which the Analog sample was written for, where I saw this adjustment. The adjustment throws off the 40s position by a pixel, which I think is less noticeable and unless you use a magnifier you probably wouldn't see it on a real device.
Also, the Analog sample in the 6.4.2 sdk is missing this piece, so the second hand won't show when the app starts.
I also noticed this thing everywhere where a full screen circle is involved. It kind of makes sense. The screens have a pair number of pixels in both dimensions. When you draw a circle using width/2, height/2 as the origin then you are half a pixel to the right and half a pixel down from the actual middle point.
I think this formula yields more accurate results. Credit to github.com/.../garmin-seaside for the formula. This is a shortened version, there's detailed explanation in his source code.
private function drawSecDot(dc, seconds, radius) {
var angle = (seconds * 6 + 270) * (Math.PI / 180);
var x = Math.cos(angle) * radius;
var y = Math.sin(angle) * radius;
dc.drawLine(_devCenter, _devCenter, x + _devCenter, y + _devCenter);
dc.fillCircle(x + _devCenter, y + _devCenter, 4);
}
I also noticed this thing everywhere where a full screen circle is involved. It kind of makes sense. The screens have a pair number of pixels in both dimensions. When you draw a circle using width/2, height/2 as the origin then you are half a pixel to the right and half a pixel down from the actual middle point.
The general solution to drawing a perfectly centred circle is to draw 4 circles, each one centred around one of the 4 pixels in the center of the screen. For me, this produces results pretty close to native circles.
I had to add 0.5 to xh for the 30s position to be correct
I'm curious whether using fractional coordinates actually works? When I tried using fractional coordinates with FR245 and drawCircle(), it didn't work. Maybe it works with newer devices which have a GPU and built-in antialiasing, but I'm 100% it wouldn't work on older devices.
I think they get rounded up / down. I don't recall the exact number but adding 0.5 to it was enough for it to be rounded up to the expected x value in this case.
I've also seen interesting results with drawing my own rectangles depending on whether the height / width is an even or odd number, e.g. being a pixel off, which I think is expected since you're in between whole numbers.