旋转+矩阵 + JSFL

发布于 2024-09-29 00:18:22 字数 907 浏览 0 评论 0原文

通过 JsFL 的 Flash 变换矩阵对我来说很重要:(

我必须编写一个 JsFL 脚本,在我的 Flash 场景上创建文本,并以随机角度旋转它。 想象一下我想创建并旋转一个“Hello World!”在 45 度时,我的代码看起来像这样:



rotateAngle = 45;

//creates my new text at x:0, y:0 coordinates
fl.getDocumentDOM().addNewText({left:0, top:0, right:10, bottom:10});
fl.getDocumentDOM().setTextString('Hello World!');

var mat = fl.getDocumentDOM().selection[0].matrix; //get the current matrix

// set rotation
mat.a = Math.cos( rotateAngle );
mat.b = Math.sin( rotateAngle);
mat.c = - Math.sin(rotateAngle);
mat.d = Math.cos( rotateAngle );

fl.getDocumentDOM().selection[0].matrix = mat; //apply new matrix


问题是:应用于我的文本的旋转是 58.3 而不是 45。

我必须承认我对矩阵有点菜鸟......所以我使用了“矩阵变换”旋转”在这里:http://www.sencentric.com/flash/tutorials/transformmatrix/

想法?

谢谢。

Flash Tranformation Matrix via JsFL are mean to me :(

I have to write a JsFL script that creates a text on my Flash scene, and rotate it with a random angle.
Imagine I want to create and rotate a "Hello World!" at 45 degrees, my code looks like that :



rotateAngle = 45;

//creates my new text at x:0, y:0 coordinates
fl.getDocumentDOM().addNewText({left:0, top:0, right:10, bottom:10});
fl.getDocumentDOM().setTextString('Hello World!');

var mat = fl.getDocumentDOM().selection[0].matrix; //get the current matrix

// set rotation
mat.a = Math.cos( rotateAngle );
mat.b = Math.sin( rotateAngle);
mat.c = - Math.sin(rotateAngle);
mat.d = Math.cos( rotateAngle );

fl.getDocumentDOM().selection[0].matrix = mat; //apply new matrix


the problem is : the rotation applied to my text is 58.3 instead of 45.

I have to admit that I'm kind of noob with matrix... so I used the "matrix transformation for rotation" here : http://www.senocular.com/flash/tutorials/transformmatrix/

Ideas ?

thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一直在等你来 2024-10-06 00:18:22

您是否尝试过用弧度而不是度数?

Have you tried with radians instead of degrees?

原谅我要高飞 2024-10-06 00:18:22

我很确定您也可以使用以下内容,而不是为了简单起见而通过矩阵。

var element = fl.getDocumentDOM().selection[0];
element.rotation = 45;

这也避免了必须转换为弧度,因为它需要度数作为输入值。

i'm pretty sure that you could also just use the following rather than go thru the matrix for the sake of simplicity.

var element = fl.getDocumentDOM().selection[0];
element.rotation = 45;

this avoids having to convert to radians as well since it takes degrees as an input value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文