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 有偿求苍穹外卖环境配置
  • ¥15 代码在keil5里变成了这样怎么办啊,文件图像也变了,
  • ¥20 Ue4.26打包win64bit报错,如何解决?(语言-c++)
  • ¥15 clousx6整点报时指令怎么写
  • ¥30 远程帮我安装软件及库文件
  • ¥15 关于#自动化#的问题:如何通过电脑控制多相机同步拍照或摄影(相机或者摄影模组数量大于60),并将所有采集的照片或视频以一定编码规则存放至规定电脑文件夹内
  • ¥20 深信服vpn-2050这台设备如何配置才能成功联网?
  • ¥15 Arduino的wifi连接,如何关闭低功耗模式?
  • ¥15 Android studio 无法定位adb是什么问题?
  • ¥15 C#连接不上服务器,