Skip to content

Commit

Permalink
feat: Add Graphics.setLineDash, Fixed #129
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Oct 17, 2018
1 parent 408d494 commit 4fa1446
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/Graphics.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ <h1>Graphics</h1>
var svgPath = "M53 84 C53 84 51 84 51 84 C51 89 53 94 56 94 C64 94 71 89 71 84 C71 72 64 64 56 64 C42 64 31 72 31 84 C31 100 42 114 56 114 C75 114 91 100 91 84 C91 61 75 44 56 44 C31 44 11 61 11 84 C11 111 31 134 56 134 C86 134 111 111 111 84 C111 50 86 24 56 24";
var g6 = new Hilo.Graphics({width:120, height:150, x:170, y:250});
g6.lineStyle(4, "#02d1d1").drawSVGPath(svgPath).closePath().endFill().addTo(stage);

//rect with linear gradient
var g7 = new Hilo.Graphics({width:90, height:90, x:320, y:20});
g7.setLineDash([5, 4]).lineStyle(2, "#009898").drawRect(4, 4, 80, 80).endFill().beginPath().setLineDash([]).lineStyle(2, "#f96").drawRect(14, 14, 60, 60).endFill().addTo(stage);

}
</script>
</body>
Expand Down
9 changes: 9 additions & 0 deletions src/view/Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ return Class.create(/** @lends Graphics.prototype */{
return me;
},

/**
* 设置虚线样式
* @param {Number[]} segments 一组描述交替绘制线段和间距(坐标空间单位)长度的数字
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
*/
setLineDash: function(segments){
return this._addAction(['setLineDash', segments]);
},

/**
* @language=en
* Set how to fill shapes and the transparency.
Expand Down

0 comments on commit 4fa1446

Please sign in to comment.