I'm trying to use Camera (android.graphics.Camera, not a hardware camera) to rotate the canvas of views around a certain point, in this case, in the middle of the canvas.
In dispatchDraw (Canvas Canvas) - for brevity, I leave all the unimportant parts.
camera.save(); camera.rotateX(0); camera.rotateY(0); camera.rotateZ(angle); camera.getMatrix(cameraMatrix); camera.restore(); canvas.concat( cameraMatrix );
The canvas rotates, but always from the upper left corner.
NOTE. Since the canvas was designed to be larger than the display area, I also need to translate the final result so that it is centered on the display, I can do this with
canvas.translate(xOffset,yOffset) PRIOR to calling the camera methods
OR
cameraMatrix.preTranslate(xOffset,yOffset) AFTER the camera methods
Both correctly center the canvas on the display, but I can't get the pivot point to be the center for calling camera.rotateZ (angle) by trying to use methods in a 3D android sample, but so far they seem to work for the X / Y axis, it does not seem to affect Z axis
Any help would be appreciated; the document is not exactly detailed.
source share