My goal right now is create a bitmap that is a non-rectangular shape, that I can also move. I have created a path that I can use as with canvas's clipPath method. Is it possible to move that clipPath around?
Also, am I doing this the best way, or is there a better way to accomplish this?
Here's my draw function:
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)
}
The clipPath.moveTo
line is where I'm having my problem, I believe. Basically, it should be creating a new path that is at the location defined with the x and y values of moveTo (I believe I have those set correctly elsewhere). The path is created beforehand, and stored into outline
, and the addPath
part should be adding the outline to clipPath
.
Thanks in advance!