2010-12-19 2 views
0

java2d로 애니메이션 된 선택 도구를 만들기위한 솔루션이 필요합니다. java2d 대시 패턴

은 내가 BasicStroke에와 Rectagnle2D API를 알고하지만 난 흑백 대시

및 this.anybody이 작품에 대한 아이디어를 가지고 애니메이션을 만들기위한 생각을하지?

alt text

감사

답변

0
void paint(Graphics2D g) { 

    //define these constants yourself 
    float dashWidth; 
    float offset; 

    //draw solid, i.e. background 
    g.setColor(Color.WHITE); 
    g.setStroke(new BasicStroke(width, cap, join, miter, null)); 
    g.drawLine(x1, y1, x2, y2); 

    //draw the pattern on top 
    float[] pattern = new float[] {dashWidth, dashWidth*2} 
    g.setColor(Color.BLACK); 
    g.setStroke(new BasicStroke(width, cap, join, miter, pattern, offset)); 
    g.drawLine(x1, y1, x2, y2); 
} 

이 어떤 모양으로 작동합니다, 그래서 당신이 필요로하는 무엇을 경우의 drawRect으로 drawLine을 교체합니다. 애니메이션을 적용하려면 색상을 전환하고 다시 칠하십시오.

관련 문제