Accepted answer

why do you use rectf to draw a circle? is it a 'true' circle, or is it really oval / ellipse?

if it's just a circle, why don't you use this.

canvas.drawcircle(x, y, radius, paint);

so you won't need to transform rectf's points if it's tilted :)


i believe this should work, i don't have an android workflow setup with me to really test it; sorry if it's a miss.

matrix m = new matrix(); //creates identity matrix
m.setrotate(tilt_angle); //rotate it by the tilt angle
m.maprect(ovalbounds); //transform the rect


// rectf face: face position and dimentions

// create bitmap where to draw an oval
bitmap ovalbmp = bitmap.createbitmap( face.width(), face.height(), config );
canvasbmp = new canvas(ovalbmp); // get a canvas to draw an oval on the bitmap
canvasbmp.drawoval( new rectf( 0, 0, face.width(), face.height ), paint );

// create transformation matrix
transformatrix = new matrix();
// rotate around center of oval
transformatrix.postrotate( tilt_angle, face.width() / 2, face.height() / 2 );
transformatrix.posttranslate( face.left, );
canvas.drawbitmap( ovalbmp, transformatrix, null );

ps: i assume by tilt angle you mean roll, where pitch is rotation around x axis, yaw is rotation around y axis and roll is rotation around z axis.

Related Query