2014-05-08 44 views
0

我對圖像有一個水印,我想用php創建它的陰影GD.how我可以計算距離,陰影有多遠以及在什麼位置位置,如果我有隻從水印通過角度和距離得到x和y的陰影位置php

for example 
$shadowAngle = 90;// in radian 
$shadowDistance = 100// in % means 100 percent away from watermark 

$watermark_x = 320; //width of watermark 
$watermark_y = 320; //height of watermark 

$watermark_Pointx = 640; // x of watermark on background Image 
$watermark_Pointy = 140; // y of watermark on background Image 

$shadow_Pointx = ? // x of shadow on background Image 
$shadow_Pointy = ? // y of shadow on background Image 

如何可以通過使用$ shadowAngle計算影子的開始點($ shadow_Pointx,$ shadow_Pointy)和$ shadowdistance

enter image description here

+0

100%?水印的寬度和高度? –

+0

'$ watermark_x'和'$ watermark_y'是水印的寬度和高度 – Anni

回答

1

角度和距離這個等式如何:

$shadow_Pointx = $watermark_Pointx + ($shadowDistance/100 * $watermark_x * sin($shadowAngle)) 

$shadow_Pointy = $watermark_Pointy + ($shadowDistance/100 * $watermark_y * cos($shadowAngle)) 

通過假設90度將設置陰影水印的右側,我想結果應該是960140 ..

什麼
+0

感謝這個方程爲我工作 – Anni

+0

希望你明白方程.. haha​​ha .. –

+0

at'$ shadowAngle = 0'我得到了影子在底部的水印如果我想在'$ shadowAngle = 0'上水印頂部的陰影 – Anni

相關問題