javascript - How to find new coordinates of rectangle after rotation - Stack Overflow

Y coordinate of rectangle after rotation on canvas. As shown in image the rectangle will be rotated on

Y coordinate of rectangle after rotation on canvas. As shown in image the rectangle will be rotated on its center point axis. After rotation and canvas is restored I want to find the new X,Y coordinates like one shown in second image, before rotation points were 50,50 and after rotation they could be 62,40.

I found similar question so I took the images from there but that question is for some WPF and my requirement is JS. How to find coordinates of all corners of rectangle after rotation?

Y coordinate of rectangle after rotation on canvas. As shown in image the rectangle will be rotated on its center point axis. After rotation and canvas is restored I want to find the new X,Y coordinates like one shown in second image, before rotation points were 50,50 and after rotation they could be 62,40.

I found similar question so I took the images from there but that question is for some WPF and my requirement is JS. How to find coordinates of all corners of rectangle after rotation?

Share Improve this question edited May 23, 2017 at 12:12 CommunityBot 11 silver badge asked Feb 4, 2013 at 12:59 SandySandy 14.1k22 gold badges79 silver badges111 bronze badges 2
  • 4 @Doorknob A quick Google search doesn't really give the answer, or else I wouldn't have stumbled across this post! ;) I'm in a similar situation! – Rutwick Gangurde Commented Feb 6, 2013 at 7:23
  • stackoverflow./a/22511805/2106820 – Arfan Mirza Commented Mar 19, 2014 at 16:14
Add a ment  | 

1 Answer 1

Reset to default 6

I made a simple JavaScript transformation class for this exact purpose.

Using it you can transform arbitrary points by a transform of your making.

When you transform the canvas, transform the Transform object in the same way and then call transformPoint(x, y) to get back the appropriate coordinates.

So in your case calling transformPoint(50, 50) would return about [62, 40], etc.

https://github./simonsarris/Canvas-tutorials/blob/master/transform.js

Here's an example: http://jsfiddle/b2fEX/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744685417a4587886.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>