java 获取矩形的坐标_拉伸后旋转矩形上的点坐标
发布日期:2021-10-25 22:55:58 浏览次数:2 分类:技术文章

本文共 1180 字,大约阅读时间需要 3 分钟。

好的,所以我似乎有工作代码,但我确信我可以做很多改进仍然是为了使它更有效等等 . 我现在也必须处理其他7个调整大小的句柄(这只是顶部 - 中间一个):

var RADIANS = Math.PI/180;

var rotated_coords = {x: coords.x, y: coords.y};

if (shape.rotate) {

var rads = -shape.rotate*RADIANS;

var middle = {x: shape.x + shape.w/2, y: shape.y + shape.h/2}; //

middle of rotation

var offset = {

x: middle.x - coords.x,

y: middle.y - coords.y

};

rotated_coords.x = middle.x - (offset.x * Math.cos(rads) - offset.y

* Math.sin(rads));

rotated_coords.y = middle.y - (offset.x * Math.sin(rads) + offset.y

* Math.cos(rads));

}

// 1. get centre before resize

var middle = {

x: shape.x + shape.w/2,

y: shape.y + shape.h/2

};

// 2. get bottom-middle of rotated shape

var bottom_middle = {

x: middle.x - shape.h/2 * sin_th,

y: middle.y + shape.h/2 * cos_th

};

// 3. resize (get difference in height, dh) from bottom-middle point

var dh = shape.y - rotated_coords.y;

// 4. get new centre point

var new_middle = {

x: bottom_middle.x + (shape.h + dh) / 2 * sin_th,

y: bottom_middle.y - (shape.h + dh) / 2 * cos_th

};

// 5. return to non-rotated top-left point

shape.x = new_middle.x - shape.w / 2;

shape.y = new_middle.y - (shape.h + dh) / 2;

// 6. set our new height

shape.h += dh;

转载地址:https://blog.csdn.net/weixin_32075843/article/details/114759207 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:java中date如何获取月份_Java:从Date获取月份整数
下一篇:java编辑pdf文本_Java编辑PDF写入文字 插入图片

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月22日 17时05分20秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

带你玩转属于自己的spring-boot-starter系列(三) 2019-04-27
基于SnowFlake算法如何让分库分表中不同的ID落在同一个库的算法的实现 2019-04-27
基于springboot的ShardingSphere5.X的分库分表的解决方案之分库解决方案(二) 2019-04-27
基于springboot的ShardingSphere5.X的分库分表的解决方案之分表解决方案(一) 2019-04-27
基于springboot的ShardingSphere5.X的分库分表的解决方案之关联查询解决方案(三) 2019-04-27
Linux文件管理参考 2019-04-27
FTP文件管理项目(本地云)项目日报(一) 2019-04-27
FTP文件管理项目(本地云)项目日报(二) 2019-04-27
FTP文件管理项目(本地云)项目日报(三) 2019-04-27
FTP文件管理项目(本地云)项目日报(七) 2019-04-27
FTP文件管理项目(本地云)项目日报(九) 2019-04-27
以练代学设计模式 -- FTP文件管理项目 2019-04-27
FTP文件管理项目(本地云)项目日报(十) 2019-04-27
学以致用设计模式 之 “组合模式” 2019-04-27
我用过的设计模式(7)--享元模式 2019-04-27
MySQL数据库从入门到实战应用(学习笔记一) 2019-04-27
MySQL数据库从入门到实战应用(学习笔记二) 2019-04-27
种树:二叉树、二叉搜索树、AVL树、红黑树、哈夫曼树、B树、树与森林 2019-04-27
【C++】攻克哈希表(unordered_map) 2019-04-27
转:【答学员问】- 该如何根据岗位学习相关技能 2019-04-27