2014-05-23 2 views
-1

easeljs에서 닫힌 경로를 채울 방법이 있습니까? 나는 이상한 모양을 그리는 mt (x_t, y_t) .lt (x_ (t + 1), y_ (t + 1)) 문자열을 가지고있다. 모양이 닫히지 만 닫힌 영역을 실제로 채울 수있는 방법을 찾을 수 없습니다. 어떤 아이디어?easeljs에서 닫힌 경로 채우기

T는 연결될 좌표의 수이고 [round.X, round.Y]는 좌표 쌍의 Tx2 배열이며 ghf는 그래픽 개체입니다. xline.y는 가장 낮은 y 값입니다.

for(var i=0;i<T;i++){ 

     x0 = round.X[i]; 
     y0 = round.Y[i]; 

     // scale for drawing 
     px0 = Math.round(xscale * x0); 
     py0 = Math.round(yscale * y0) + xline.y; 

     if(x0>gp.xmin){ // if not first point ... 
      ghf.mt(prevx,prevy).lt(px0,py0); // draw line from prev point to this point 
     } 

     // set this point as prev point 
     prevx = px0; 
     prevy = py0; 
    } 
// fill out thing 
ghf.mt(prevx,prevy).lt(px0,xline.y); 
ghf.mt(px0,xline.y).lt(0,xline.y); 

x0 = round.X[0]; 
y0 = round.Y[0]; 
px0 = Math.round(xscale * x0); 
py0 = Math.round(yscale * y0) + xline.y; 
ghf.mt(0,xline.y).lt(px0,py0); 
ghf.f('red'); 

답변

0

코드가별로 도움이되지 않지만, 필요한 것은 beginFill 메서드입니다. link을 참조하십시오.

이처럼 사용할 수 있습니다

var ball = new createjs.Shape(); 
ball.graphics.setStrokeStyle(5, 'round', 'round'); 
ball.graphics.beginStroke(('#000000')); 
ball.graphics.beginFill("#FF0000").drawCircle(0,0,50); 
ball.graphics.endStroke(); 
ball.graphics.endFill(); 
ball.graphics.setStrokeStyle(1, 'round', 'round'); 
ball.graphics.beginStroke(('#000000')); 
ball.graphics.moveTo(0,0); 
ball.graphics.lineTo(0,50);