私はこのイメージを持っています:
範囲が[0、π]のα値もあります。基本的に、それは見える角度を表します。
画像に動的透明マスクを適用したいので、α が π/2 に等しい場合、左半分だけが表示されます。
このプロセスを考えて、各ピクセルの可視性を計算しました。
private boolean[][] getVisibilityArray(final int height, final int width, final double value) {
final boolean[][] visibility = new boolean[width][height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
final double xInSqrt = (width / 2) - x;
final double yInSqrt = height - y;
final double sumInSqrt = xInSqrt * xInSqrt + yInSqrt * yInSqrt;
final double hipotenusa = Math.sqrt(sumInSqrt);
final double adyacente = Math.abs((width / 2) - x);
final double cos = adyacente / hipotenusa;
double angle = Math.acos(cos);
if (x > width / 2) {
angle = Math.PI - angle;
}
visibility[x][y] = angle <= value;
}
}
return visibility;
}
ただし、ビットマップを生成して元のビットマップにマスクを適用することは、私の理解を超えています。
どうすればこの効果を達成できますか?