Hello, is it possible to get the real screen width on a y position or the real screen height on a x position on round watches?
Hello, is it possible to get the real screen width on a y position or the real screen height on a x position on round watches?
You have to calculate it yourself (for semiround watches this will be an approximation ofc).
This is my (terrible) code:
(:round) private function getWidth(y)
{
var radius = deviceWidth / 2;
//var angle = 2 * Math.toDegrees(Math.acos(1 - (y.toFloat() / radius))); // Angle = 2 * arccos(1 - height(y) / radius)
//return (2 * radius * Math.sin(Math.toRadians(angle) / 2)).toNumber();
return (2 * radius * Math.sin(Math.toRadians(2 * Math.toDegrees(Math.acos(1 - (y.toFloat() / radius)))) / 2)).toNumber();
}
(:semiround) private function getWidth(y)
{
if (y == 0)
{
return 121; //biggest hack in the world
}
// not quite right
var radius = deviceWidth / 2;
//var angle = 2 * Math.toDegrees(Math.acos(1 - (y.toFloat() / radius))); // Angle = 2 * arccos(1 - height(y) / radius)
//return (2 * radius * Math.sin(Math.toRadians(angle) / 2)).toNumber();
return (2 * radius * Math.sin(Math.toRadians(2 * Math.toDegrees(Math.acos(1 - (y.toFloat() / radius)))) / 2)).toNumber();
}
Thanks, the calculation work.
But (:round) and (:semiround) does not work. I've get the error "Duplicate declaration of symbol 'getWidth' in class 'SingleBikeFieldView'."
(:round) and (:semiround) are excludes annotations,
you have to set them in your jungle file.
I try that, but it does not work:
(:roundVersion) function getWidth(y) {
var radius = deviceWidth / 2;
return (2 * radius * Math.sin(Math.toRadians(2 * Math.toDegrees(Math.acos(1 - (y.toFloat() / radius)))) / 2)).toNumber();
}
(:regularVersion) function getWidth(y) {
return deviceWidth;
}# Configure paths based on screen shape round.resourcePath = $(base.resourcePath);resource-round semiround.resourcePath = $(base.resourcePath);resource-semiround rectangle.resourcePath = $(base.resourcePath);resource-rectangle # Say that all products exclude declarations # with the annotation :roundVersion base.excludeAnnotations = roundVersion # Now say that the round products exclude # the regular version round.excludeAnnotations = regularVersion
Where is my mistake?