다음 코드를 수정하여 그려진 선을 파선으로 표시하면 jfiddle에서 동작하는 것을 볼 수 있습니다.점진적으로 점선으로 그려진 애니메이션 애니메이션 HTML5 Canvas & Jquery
<html>
<style>
#canvas
{
border-style:solid;
border-width:1px;
}
</style>
<div id="canvas">
<p>Hover over me</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</html>
$(function() {
animateLine = function(canvas, hoverDivName, colorNumber, pathString) {
$('#' + hoverDivName).hover(
function() {
var line = canvas.path(pathString).attr({
stroke: colorNumber
});
var length = line.getTotalLength();
$('path[fill*="none"]').animate({
'to': 1
}, {
duration: 5000,
step: function(pos, fx) {
var offset = length * fx.pos;
var subpath = line.getSubpath(0, offset);
canvas.clear();
canvas.path(subpath).attr({
stroke: colorNumber
});
},
});
}, function() {
$('path[fill*="none"]').stop(true, false).fadeOut();
});
};
var canvas = Raphael('canvas', 200, 200);
var pathString = "M10 10L10 200L100 200Z";
animateLine(canvas, "canvas", "#000", pathString);
});
[캔버스의 whatwg 사양] (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#line-styles)에는 setLineDash 메소드가 있습니다 그렇게하기 위해 노력했지만 브라우저는 지원하지 않았습니다. – Philipp
[this] (http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas) 캔버스에서 파선이나 점선을 만드는 방법에 대한 답변. – Zemljoradnik