- /**
- *
- * @param g
- * @param form
- * @param to
- * @param weight 线条粗细
- * @param color
- * @param step 线条的长度
- */
- public static function dashFormTo(g:Graphics, from:Point, to:Point, color:uint, weight:int = 1, step:int = 1):void {
- var xx:Number = (to.y - from.y) / (to.x - from.x);
- g.lineStyle(weight, color);
- g.moveTo(from.x, from.y);
- var x:int = from.x;
- var y:int = from.y;
- var i:int = 0;
- while (true) {
- x = x + step;
- y = y + step * xx;
- g.lineTo(x, y);
- x = x + step * 2 + weight;
- y = y + (step * 2 + weight) * xx;
- g.moveTo(x, y);
- i++;
- if (x > to.x - weight) {
- break;
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/190420132894.html
来源: http://www.codesnippet.cn/detail/190420132894.html