一個畫圖的例子

ngAfterViewInit() {    this.renderChar();    var stage = new createjs.Stage("analysisPath");    var circle1 = new createjs.Shape();    circle1.graphics.beginFill("#000").drawRect(0, 0, 200, 100);    circle1.x = 0;    circle1.y = 0;    stage.addChild(circle1);    var circle2 = new createjs.Shape();    circle2.graphics.beginFill("000").drawRect(0, 300, 200, 100);    circle2.x = 0;    circle2.y = 300;    stage.addChild(circle2);    var current = new createjs.Shape().set({x:100, y:circle1.y});    stage.addChild(current);    var w = circle2.x - circle1.x;    var h = circle2.y - circle1.y;    var l = Math.sqrt(w*w+h*h);    this.drawArrow(current, l);    current.rotation = Math.atan2(h,w) * 180/Math.PI;    stage.update();}drawArrow(arrow:any, length:number) {    arrow.graphics.clear().ss(3).s("#000").mt(0, 0);    var arrowSize = 15;    arrow.graphics.qt(0, 0, length, 0);    // Draw the arrow head at the end.    arrow.graphics.f("#000");    arrow.graphics.dp(length - arrowSize, 0, arrowSize, 3);}
相關文章
相關標籤/搜索