私の現在の目標は、移動もできる非長方形のビットマップを作成することです。canvas の clipPath メソッドと同様に使用できるパスを作成しました。そのclipPathを移動することは可能ですか?
また、私はこれを最善の方法で行っていますか、それともこれを達成するためのより良い方法はありますか?
ここに私の描画機能があります:
public void draw(Canvas c){
// Paint object, for outline of clip Path.
Paint p = new Paint();
p.setStyle(Style.STROKE);
p.setColor(Color.RED);
// A currently defined path to clip the bitmap with
Path clipPath = new Path();
clipPath.moveTo(top_left.getX() + nodes.getNodeVals('L').getX(), top_left.getY() + nodes.getNodeVals('T').getY());
clipPath.addPath(outline);
c.save(); // Save the canvas (rotations, transformations, etc)
c.clipPath(clipPath); // Create a clip region
c.drawPath(clipPath, p); // Draw that clip region in red
c.drawBitmap(img, top_left.getX(), top_left.getY(), null); // Draw the bitmap in the clip
c.restore(); // Restore the canvas (rotations, transformations, etc)
}
このclipPath.moveTo
行は、私が問題を抱えている場所だと思います。基本的には、moveTo の x 値と y 値で定義された場所にある新しいパスを作成する必要があります (他の場所で正しく設定されていると思います)。パスは事前に作成され、 に格納され outline
、addPath
パーツは にアウトラインを追加する必要がありますclipPath
。
前もって感謝します!