flex 虛線 沿著虛線移動的箭頭 完

2021-08-30 18:24:47 字數 3510 閱讀 9519

1.虛線方向的箭頭

package view.line

public function draw():void

var centerx:number = p2.x - radius * math.cos(angle*(math.pi/180));

var centery:number = p2.y + radius * math.sin(angle*(math.pi/180));

var leftx:number = centerx + radius * math.cos((angle+120)*(math.pi/180));

var lefty:number = centery - radius * math.sin((angle+120)*(math.pi/180));

var rightx:number = centerx + radius * math.cos((angle+240)*(math.pi/180));

var righty:number = centery - radius * math.sin((angle+240)*(math.pi/180));

var p1:point = new point( leftx , lefty);

var p3:point= new point(rightx , righty);

var p4:point= new point(centerx , centery);

drawarrow(p1,p2,p3,p4);

}protected function drawarrow(p1:point,p2:point,p3:point,p4:point):void

//線填充色(箭頭)

private var _fillcolor:uint = 0x66ff66;//0x0000ff

public function set fillcolor(color:uint):void

[bindable]

public function get fillcolor():uint

//起點座標

public function set startpoint(p:point):void

public function get startpoint():point

//終點點座標

public function set endpoint(p:point):void

public function get endpoint():point

// 箭頭所放的位置,"center" ,"startpoint","endpoint"

public function get arrowalign():string

public function set arrowalign(str:string):void}}

2. 虛線,及沿著虛線移動的箭頭

package view.line

public function drawline():void

this.graphics.clear();

this.graphics.beginfill(fillcolor);

this.graphics.linestyle(1, fillcolor, 1);

this.graphics.moveto(_startpoint.x,_startpoint.y);

var xlen:number = -_startpoint.x + _endpoint.x;//起始點x座標差距

var ylen:number = -_startpoint.y + _endpoint.y;//起始點y座標差距

var linelen:number = math.sqrt(xlen * xlen + ylen * ylen);

// if(_duration == 0)

// _duration = math.round(linelen * 20);

xtemp =( _linesize * xlen )/linelen;//求出 x 座標 count的偏移x座標差

ytemp =( _linesize * ylen )/linelen;//求出 y 座標count 的偏移y座標差

var x0:number = _startpoint.x;

var y0:number = _startpoint.y;

while((linelen/_linesize) >= 1)

else

count++;

linelen = linelen - _linesize;

}// this.graphics.lineto(_endpoint.x , _endpoint.y);

this.graphics.endfill();

//畫箭頭

arrow.startpoint = this.startpoint;

arrow.endpoint = this.endpoint;

arrow.arrowalign = arrowui.startpoint;

arrow.fillcolor = this.fillcolor;

arrow.draw();

var num:number = this.numchildren;

if(_domove)

}//線填充色(箭頭)

private var _fillcolor:uint=0x00ff00;//0x808080

public function set fillcolor(color:uint):void

[bindable]

public function get fillcolor():uint

//起點座標

public function set startpoint(p:point):void

public function get startpoint():point

//終點點座標

public function set endpoint(p:point):void

public function get endpoint():point

//虛線 空白長度

public function set linesize(num:number):void

public function get linesize():number

//是否顯示箭頭

public function set arrowvisible(num:boolean):void

public function set arrowdomove(num:boolean):void

//是否移動箭頭

public function stopmove():void

}public function get isplaying():boolean

public function get arrowobj():arrowui}}

flex 畫虛線矩形演算法

選定矩形的乙個頂點為起點,開始畫 x0 頂點橫座標 y0 頂點縱座標 x1 水平線上另一頂點的橫座標 y1 水平線上另一丁點的縱座標 private function drawdottenrect g graphics,x0 number,y0 number,x1 number,y1 number ...

虛線的描繪

虛線的描繪,是線的描繪時使用的pen物件的dashstyle屬性的值變更實現的。下面的例子是,對dashstyle屬性的值進行各種變更所描繪的直線。using system.drawing using system.drawing.drawing2d 上面的1行 寫在所有 的最上面 graphics...

繪製虛線的UIView

繪製虛線的uiview cashapelayer配合貝塞爾曲線可以繪製曲線,筆者繼承了乙個uiview的子類,並將該子類的backedlayer替換為cashapelayer,以此來實現繪製虛線的效果.繪製出各種虛線的效果圖 實現的原始碼 linedashview.h 與 linedashview....