3
我使用Keith Wood的jQuery SVG插件沿着路徑繪製文本。我怎樣才能獲得一段JS的路徑?使用javascript的貝塞爾曲線長度
我使用Keith Wood的jQuery SVG插件沿着路徑繪製文本。我怎樣才能獲得一段JS的路徑?使用javascript的貝塞爾曲線長度
從SVG規範,使用path.getTotalLength()。
這裏有一個如何與jQuery的SVG庫使用這個小例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>jQuery SVG Basics</title>
<style type="text/css">
@import "jquery.svg.css";
#mydiv { width: 400px; height: 300px; border: 1px solid #484; }
</style>
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript" src="jquery.svg.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#mydiv").svg({
onLoad : function(svg){
var path = svg.createPath();
var pathNode = svg.path(path.move(100, 200).curveC([[200,
100, 300, 0, 400, 100], [500, 200, 600, 300, 700,
200], [800, 100, 900, 100, 900, 100]]));
console.log(pathNode.getTotalLength());
}
});
});
</script>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>
你能給我如何使它與基思·伍德的jQuery插件SVG工作的例子嗎? –
這就是答案。你應該接受它。否則作業。 –