gpt4 book ai didi

javascript - 如何在svg-edit中创建曲线文本的扩展名?

转载 作者:行者123 更新时间:2023-12-02 05:17:27 26 4
gpt4 key购买 nike

我想在项目中使用svg-edit插件。现在,我想为曲线文本创建扩展名,例如:

svgEditor.addExtension("Curve text!", function() {'use strict';
return {
name: "Curve text",
svgicons: svgEditor.curConfig.extPath + "text_curve-icon.xml",

buttons: [{
id: "text_curve",
type: "mode",
title: "Curve the text",
events: {
'click': function() {
svgCanvas.setMode("text_curve");

var textElement = $(svgCanvas.getSelectedElems()[0]);

var textPath = '<text>' +
' <textPath xlink:href="#relativeCurve">' +
$(svgCanvas.getSelectedElems()[0]).text() +
' </textPath>' +
'</text>';
$('#svgcontent').prepend('<defs><path d="m0,350c100,-100 200,-200 300,-200c100,0 200,200 300,200c100,0 200,-200 300,-200" id="relativeCurve"/></defs>');
$(textElement).replaceWith(textPath);
}
}
}],
mouseDown: function() {
if(svgCanvas.getMode() == "text_curve") {
return {started: true};
}
},

mouseUp: function(opts) {
if(svgCanvas.getMode() == "text_curve") {
}
}
};
});

但这不起作用,如何创建它?

最佳答案

我一直在考虑同一件事,但是我认为我要采取的方法是通过ID来选择路径的下拉列表。

然后按ID引用路径

这些天之一,我什至可以做。

关于javascript - 如何在svg-edit中创建曲线文本的扩展名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28989361/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com