移动自定义字体不起作用 [英] moving custom font doesn't work

查看:47
本文介绍了移动自定义字体不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 raphael 的 print() 通过动画移动文本,但它不起作用:

I'm trying to move a text via animation using raphael's print(), but it doesn't work:

var paper = Raphael(document.getElementById("stage"), 640, 480);
var text = paper.print(300, 200, "Test Text", paper.getFont("Yanone"), 50);
text.animate({
    y: 400
}, 1000);

有人知道我可能遗漏了什么吗?

Anyone have ideas what I may be missing?

推荐答案

我认为如果你想动画它应该使用 text 函数而不是 print 函数之后.我不知道为什么,但它有效......

I think you should use the text function instead of the print function if you want to animate it later. I'm not sure why but it works ...

以下是两种方法的示例:

Here is an example with both ways of doing it:

var paper = Raphael("canvas", 640, 480);
var fonts = [0, paper.getFont("DIN")];

//using print
var p = paper.print(70, 150, "Custom fonts", fonts[1], 20).attr({fill: "#f00"});

//using text (font-family is the same as in getFont)
var t = paper.text(100, 150, "Custom fonts")
t.attr({"font-family": "DIN", "font-size":50, "opacity": 0.5});
t.attr({"fill": "#000"});

在第二个你可以这样做,例如:

And on the second one you can do this for example :

t.animate({"font-size":40,"fill":"#0f0"},2000);
t.animate({"x":150},5000);

这篇关于移动自定义字体不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆