2014-03-28 2 views
1

점선으로 원을 그리려합니다. 나는 이것을 시도했다 :다트의 StageXL로 점선 원을 그리는 방법

Shape shape = new Shape() 
..graphics.beginPath() 
      ..graphics.circle(50 , 50, 50) 
      ..graphics.closePath() 
      ..graphics.strokePattern(new GraphicsPattern.repeat(new BitmapData.fromImageElement(new HTML.ImageElement(src: "img/dash.png")))) 
      ..addTo(stage); 
    } 

그러나 원이 표시되지 않습니다. strokePattern 줄이 내 코드를 손상시키는 것 같습니다. 이 문제를 어떻게 해결할 수 있습니까?

답변

1

나는이 솔루션 :

void _addDottedCircle(double x, double y, int radius) { 
    List<double> xCoords = new List<double>(); 
    List<double> yCoords = new List<double>(); 

    for (int i = 0; i < radius; i++) { 
     xCoords.add(radius * cos(2 * PI * i/radius) + x); 
     yCoords.add(radius * sin(2 * PI * i/radius) + y); 
    } 

    for (int i = 0; i < radius; i++) { 
     new Shape() 
      ..graphics.beginPath() 
      ..graphics.circle(xCoords[i], yCoords[i], 1) 
      ..graphics.closePath() 
      ..graphics.fillColor(lightgreen) 
      ..addTo(stage); 
    } 
} 
함께했다
관련 문제