2012-09-05 2 views
0

캔버스 드로잉에서 패스로 생성 한 ShapeDrawble 객체를 어떻게 이동 시키면 좋을까요?캔버스 드로잉에서 패스로 생성 한 ShapeDrawble 객체를 어떻게 움직입니까?

아래 코드는 겉으로보기에는 이동하기 위해 새로운 경로를 사용하므로 매번 ShapeDrawable 객체를 다시 만들 수 있습니다. 이것은 매우 낭비되는 자원이며 해결할 방법이 있습니까?

private void drawBitmapShape(Canvas canvas, Paint paint) 
    { 
     /*Draw a hollow triangle*/ 
     Path path=new Path(); 
     path.moveTo(10, 330); 
     path.lineTo(70,330); 
     path.lineTo(40,270); 
     path.close(); 
     //canvas.drawPath(path, paint); 

     /* create ShapeDrawable object and define the shape is elliptic */ 
     mShape = new ShapeDrawable(new PathShape(path, BitQQheight, BitQQheight)); 

     /* set up the ellipse things to draw for ShapeDrawable pictures */ 
     mShape.getPaint().setShader(mBitmapShader); 
     /*set display area*/ 
     //BitQQheight=BitQQheight*2; 
     mShape.setBounds(0,0, BitQQwidth, BitQQheight); 

     /* draw ShapeDrawableQQ */ 
     mShape.draw(canvas); 
    } 

답변

0

는 내가 그것을

private void drawBitmapShape(Canvas canvas, Paint paint) 
    { 
     canvas.save(); 
     canvas.translate(5, 5); 
     // rotate 
     //canvas.rotate(90, 60, 310); 
     /*Draw a hollow triangle*/ 
     Path path=new Path(); 
     path.moveTo(10, 330); 
     path.lineTo(70,330); 
     path.lineTo(40,270); 
     path.close(); 
     //canvas.drawPath(path, paint); 

     /* create ShapeDrawable object and define the shape is elliptic */ 
     mShape = new ShapeDrawable(new PathShape(path, BitQQheight, BitQQheight)); 

     /* set up the ellipse things to draw for ShapeDrawable pictures */ 
     mShape.getPaint().setShader(mBitmapShader); 
     /* set display area */ 
     //BitQQheight=BitQQheight*2; 
     mShape.setBounds(0,0, BitQQwidth, BitQQheight); 

     /* draw ShapeDrawableQQ */ 
     mShape.draw(canvas); 
     canvas.restore(); 
    } 
를 해결했다고 생각
관련 문제