2

I've been browsing for some days now, but I can't seem to find a way to do this. I hope that maybe some of you are more experienced then I am with the Android SDK and its abilities :)

Say you draw the path on the canvas with the upper- and left-most control point x=300 and y=500 (the scribble in the image below). I want to be able to set the position of its "rectangle" to the canvas coordinates e.g. x=10 and y=10

enter image description here So basically, it is the rectangle with the path that I am interested in. The idea is "cutting" this area out and moving it to a given position (but I don't want to include the underlying draws that are already on the canvas).

What I have tried:

Converting the Path into a PathShape and then a ShapeDrawable. I am able to skew the position of the Drawable, but it is too inexact to be used to position it.

ShapeDrawable sd = new ShapeDrawable(new PathShape(path, getWidth(), getHeight());
sd.getPaint().set(p);           
sd.setBounds(0, 0, getWidth(), getHeight());

getWidth() and getHeight() are respectively getting the width and height of the canvas.

Can you please help me think of a way to do this by a new idea or by correcting my ShapeDrawable idea? Thank you very much for any help in advance!

animuson
  • 53,861
  • 28
  • 137
  • 147
kamillan
  • 115
  • 1
  • 8

1 Answers1

2

Path transform looks like exactly what you need.

aragaer
  • 17,238
  • 6
  • 47
  • 49
  • +1, thank you for a quick answer :) I guess I was a bit lost at the Drawable, but this really helped. I found many guides where people use the Matrix for scaling and moving images in Android (which I can use for the Path). – kamillan Dec 13 '12 at 20:08