You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
912 B
28 lines
912 B
3 years ago
|
class ScaledPosition {
|
||
|
static int getWidth(
|
||
|
double screenwidth, double videowidth, double screenposition) {
|
||
|
int scaledWidth;
|
||
|
if (screenwidth < videowidth) {
|
||
|
scaledWidth = ((screenwidth / videowidth) * screenposition).round();
|
||
|
} else if (screenwidth == videowidth) {
|
||
|
scaledWidth = screenposition.round();
|
||
|
} else {
|
||
|
scaledWidth = ((videowidth / screenwidth) * screenposition).round();
|
||
|
}
|
||
|
return scaledWidth;
|
||
|
}
|
||
|
|
||
|
static int getHeight(
|
||
|
double screenheight, double videoheight, double screenposition) {
|
||
|
int scaledHeight;
|
||
|
if (screenheight < videoheight) {
|
||
|
scaledHeight = ((screenheight / videoheight) * screenposition).round();
|
||
|
} else if (screenheight == videoheight) {
|
||
|
scaledHeight = screenposition.round();
|
||
|
} else {
|
||
|
scaledHeight = ((videoheight / screenheight) * screenposition).round();
|
||
|
}
|
||
|
return scaledHeight;
|
||
|
}
|
||
|
}
|