简体   繁体   English

在KineticJS滚轮上旋转文本

[英]Rotate text on KineticJS Wheel

I'm working on a HTML5 Canvas Wheel and have taken a look at the following link: http://www.html5canvastutorials.com/labs/html5-canvas-wheel-of-fortune/ 我正在研究HTML5帆布轮,并查看了以下链接: http : //www.html5canvastutorials.com/labs/html5-canvas-wheel-of-fortune/

I have changed the dimensions of the wheel so that one half is completely visible as opposed to one small section being visible. 我更改了轮子的尺寸,以使一半完全可见,而不是一小部分可见。
I'm attepmting to rotate the text on itself so that when an item is at the side of the wheel the text is straight horizontally not vertically. 我要旋转文本以便当某项位于滚轮的侧面时,文本在水平方向上是垂直的,而在垂直方向上是垂直的。

Everything I've tried thus far has been failure after failure. 到目前为止,我尝试过的一切都是失败之后的失败。 I've come across a JSFiddle ( http://jsfiddle.net/m1erickson/mqsY3/ ) on Stack Overflow with one solution (something like rotationDeg:textAngle ), however it uses a differnet version of KineticJS so doesn't work. 我在一个解决方案(类似于rotationDeg:textAngle )上的堆栈溢出中遇到了JSFiddle( http://jsfiddle.net/m1erickson/mqsY3/ ),但是它使用KineticJS的不同版本,因此不起作用。 When I change to that version of KineticJS everything else on my wheel breaks. 当我更改为KineticJS的那个版本时,我的方向盘上的所有其他功能都中断了。

Can anyone help with rotating the text using the KineticJS 5.0.1? 任何人都可以使用KineticJS 5.0.1来帮助旋转文本吗?

The more recent versions of KineticJS use objects to define properties so you need to declare the offset using an object instead of an array: KineticJS的最新版本使用对象来定义属性,因此您需要使用对象而不是数组来声明offset

var offset = { x: wedgeRadius - 10, y: 7 };

Here's an updated Demo: http://jsfiddle.net/m1erickson/8Px6C/ 这是更新的演示: http : //jsfiddle.net/m1erickson/8Px6C/

Good luck with your project! 祝您项目顺利!

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

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