Javascript 拉斐尔JS中带下划线的文本
我想做一件简单的事。只是一个带有下划线的文本,就像html中的标记一样。如何在Raphael JS中实现这一点?以下是一个函数,它应该完成您所追求的功能:Javascript 拉斐尔JS中带下划线的文本,javascript,raphael,Javascript,Raphael,我想做一件简单的事。只是一个带有下划线的文本,就像html中的标记一样。如何在Raphael JS中实现这一点?以下是一个函数,它应该完成您所追求的功能: function underlineText(textElement) { var textBBox = textElement.getBBox(); var textUnderline = canvas.path("M"+textBBox.x+" "+(textBBox.y+textBBox.height)+"L"+(textBBo
function underlineText(textElement) {
var textBBox = textElement.getBBox();
var textUnderline = canvas.path("M"+textBBox.x+" "+(textBBox.y+textBBox.height)+"L"+(textBBox.x+textBBox.width)+" "+(textBBox.y+textBBox.height));
}
var textElement = canvas.text(100,100,"hello world");
underlineText(textElement);
我认为前面的答案已经不好了(因为对我来说它根本不起作用),但通过一些技巧,我让它成为了一种魅力 这是:
var underlineText = function () {
var textBBox = textElement.getBBox();
var textUnderline = paper.path("M"+textBBox.x+" "+(textBBox.y+textBBox.height)+"L"+(textBBox.x+textBBox.width)+" "+(textBBox.y+textBBox.height));};
underlineText(textElement);
干杯
www.stefanomoscardini.it适用于SVG画布,未使用VML进行测试(相关讨论在此仅做一个说明,如果您旋转文本,它将不会像预期的那样工作。不过,这是一个优雅的解决方案!这是唯一有效的答案!谢谢。这应该被接受
var text=paper.text(...);
if (text.node){
$(text.node).css('text-decoration','underline');
}