0

I have CustomClass with image at the center.

I use compass and rotate canvas.

When data from compass is changed the canvas is invalidate and redraw.

Have you any idea, to draw Canvas and rotate it without redraw?

My code is below:

@Override 
protected void onDraw(Canvas canvas) {
    Paint paint = mPaint;

    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);

    canvas.translate(getWidth()/2, getHeight()/2);

    if (mValues != null) { 
       rotate=-mValues[0];
    }

    canvas.rotate(rotate); 
    canvas.drawBitmap(imgtable,  - imgtable.getWidth()/2, - imgtable.getHeight()/2, null);   
}
4

1 回答 1

0

请检查以下链接以解决您的问题:

https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/HTML-canvas-guide/Translation,Rotation,andScaling/Translation,Rotation,andScaling.html

(或者)

下面的链接已经在下面的 Stack Overflow 链接中建议检查它:

调用 clearRect 后,HTML5 画布未在 Chrome 中重绘

于 2013-09-05T10:46:36.387 回答