doufen3134 2014-05-07 23: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 00: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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部