简体   繁体   English

draw2d touch(js)用图形旋转端口和边界框

[英]draw2d touch (js) rotate ports and bounding box with figure

It seems that draw2d rotates only the inner content of a figure when I rotate it. 看来draw2d在旋转时只旋转图形的内部内容。 For example using this function; 例如使用此功能;

         function rotate (angle, figure){
            if(!isNaN(parseFloat(angle)) && isFinite(angle)){
                figure.setRotationAngle(angle%360);
            }

with say, 60 as angle value, makes the following rotation on a label with 4 hybrid ports: 比方说,60作为角度值,在带有4个混合端口的标签上进行以下旋转:

在轮换之前

旋转后

How can I properly rotate a figure with every component of it? 如何正确旋转图形的每个部分? You know, with ports and everything. 你知道,港口和一切。

There is a small hack that i have done in order to rotate the content part. 为了旋转内容部分,我做了一个小小的黑客攻击。 If you look at the rotated element in the DOM, it will have an attribute named "transform" with value "matrix('some values')". 如果你看看DOM中的旋转元素,它将有一个名为“transform”的属性,其值为“matrix('some values')”。 Something like this : transform="matrix(0.5,-0.866025404,0.866025404,0.5,217.9572965841818,726.3312936065454)" Now with this part, what you can do is that whenever your rotation code is called, you can copy the transform attribute from the selected figure and add it to the content part.then It will behave like the rotated element. 像这样的东西: transform="matrix(0.5,-0.866025404,0.866025404,0.5,217.9572965841818,726.3312936065454)"现在有了这个部分,你可以做的是,无论何时调用旋转代码,你都可以复制选定的变换属性将数字添加到内容部分。然后它将像旋转的元素一样。 example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM