旋转+矩阵 + JSFL
通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过用弧度而不是度数?
Have you tried with radians instead of degrees?
我很确定您也可以使用以下内容,而不是为了简单起见而通过矩阵。
这也避免了必须转换为弧度,因为它需要度数作为输入值。
i'm pretty sure that you could also just use the following rather than go thru the matrix for the sake of simplicity.
this avoids having to convert to radians as well since it takes degrees as an input value.