Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

svg - 在行中添加文字(Add text to line)

I used svg.draw.js to allow the user to create a sketch of a terrace.

(我使用svg.draw.js允许用户创建露台的草图。)

I'd like to add a label above each line to show the length of the line.

(我想在每行上方添加一个标签,以显示行的长度。)

I've tried several things but none of them were good enough.

(我已经尝试了好几件事,但是没有一件事情足够好。)

Please have a look at this fiddle: https://jsfiddle.net/mdemuynck/pxy4f9o0/8/#&togetherjs=8oMIQFQmBg/

(请看一下这个小提琴: https : //jsfiddle.net/mdemuynck/pxy4f9o0/8/#&togetherjs=8oMIQFQmBg/)

var poly2 = new SVG('polygonGrid').size('100%', '300')
    .polygon().draw({snapToGrid:20});

poly2.on('drawstart', function(e){
    document.addEventListener('keydown', function(e){
        if(e.keyCode == 13){
            poly2.draw('done');
            poly2.off('drawstart');
        }
    });
});

poly2.on('drawstop', function(){
    // remove listener
});
  ask by Mr. Martini translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...