doufen3134 2014-05-08 07:52
浏览 37
已采纳

在php中通过角度和距离获取阴影的x和y位置

I have a watermark on to the image and i want to create its shadow using php GD.how can i calculate the distance that how far is the shadow and at what position if i have only the angle and distance from the watermark

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

How can i calculate starting points of shadow($shadow_Pointx,$shadow_Pointy) by using $shadowAngle and $shadowdistance

enter image description here

  • 写回答

1条回答 默认 最新

  • dqe9657 2014-05-08 08:03
    关注

    How about this equation:

    $shadow_Pointx = $watermark_Pointx + ($shadowDistance/100 * $watermark_x * sin($shadowAngle))
    
    $shadow_Pointy = $watermark_Pointy + ($shadowDistance/100 * $watermark_y * cos($shadowAngle))
    

    By assuming 90 degree will set the shadow on the right side of the watermark, I guess the result should be 960,140..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接