[英]How to Place an SVG Image at the Beginning of Text on a TextPath
要将评论打包成答案,请按以下步骤操作:
let text = myTextNode //
let {x, y} = text.getStartPositionOfChar(0)
let rot = text.getRotationOfChar(0)
let image = document.createElementNS('http://www.w3.org/2000/svg', 'image')
image.setAttributeNS(null, 'x', x)
image.setAttributeNS(null, 'y', y)
image.setAttributeNS(null, 'transform', `rotate(${rot} ${x} ${y})`)
或在svg.js中
let text = mySVGJSText
let {x, y} = text.node.getStartPositionOfChar(0)
let rot = text.node.getRotationOfChar(0)
let image = new SVG.Image()
.load(src)
.size(width, height)
.move(x, y)
.transform({rotate: rot, cx: x, cy: y})
// or when you have your root element:
root.image(src, width, height).move....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.