移动自定义字体不起作用

编程入门 行业动态 更新时间:2024-10-10 21:23:50
本文介绍了移动自定义字体不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 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);

更多推荐

移动自定义字体不起作用

本文发布于:2023-11-02 06:02:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551564.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   不起作用   字体

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!