移动自定义字体不起作用

发布于 2024-11-26 01:40:59 字数 269 浏览 5 评论 0原文

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

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);

有人知道我可能会错过什么吗?

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?

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

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

发布评论

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

评论(1

小情绪 2024-12-03 01:40:59

我认为如果您想稍后对其进行动画处理,您应该使用 text 函数而不是 print 函数。我不知道为什么,但它有效...

这是一个包含两种方法的示例:

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"});

在第二种方法中,您可以这样做:

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

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