How to rotate a path just like a bitmap

I find very little documentation on how to manipulate Path objects, in particular rotation.

I have a drawing application in which I am trying to enable the undo function. Each time the user's fingers touch the view until their finger is raised, their finger path will be saved as Path in the ArrayList. The cancellation method is as follows:

        public void undo() {
            //If nothing was drawn, do nothing
            int size = path_history.size();
            if (size == 0)
                return;

            //Draw the last saved bitmap
            setupView();

            //Loop through saved paths, don't paint last path - remove it
            for (int i=0; i<size-1; i++)
                canvas.drawPath(path_history.get(i), paint);
            path_history.remove(size-1);
            invalidate();
        }

, , , 90 ( , ). , , .

, :

Matrix m = new Matrix();
m.preRotate(90);
//I TRIED THIS TOO: m.preRotate(90, bitmap width / 2, bitmap height / 2);
for (int i=0; i<size-1; i++)
    path_history.get(i).transform(m);

, . , , , , . , ? , , , , .

!

.

+5

All Articles