Pergunta

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!

Foi útil?

Solução

Path transform looks like exactly what you need.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top