Note that there are some explanatory texts on larger screens.

plurals
  1. POShould I rely on Android to discard off-screen draws?
    primarykey
    data
    text
    <p>I have a function that takes a seamless bitmap and scrolls it on the screen in any direction using world coordinates. There are 4 draws (play area is smaller than the full bitmap size.. So at the most, you'll see 4 copies of the bitmap, just different sections drawn to retain the seamless effect). What I want to know is, should I apply modifications to the rect bounds so that it's only blitting the parts that it should onto the screen? Or should I let Android handle that? And if I do it myself, how should I handle that? The world coordinates and translate really confuse me, as far as the math goes. :/</p> <p>Here's the code. </p> <pre><code>public void draw(Canvas canvas){ oCoords.x=(int) fX; oCoords.y=(int) fY; oTopLeft = gridContainingPoint(oCoords); oTopRight.x = gridContainingPoint(oCoords).x + iWidth; oTopRight.y = gridContainingPoint(oCoords).y; oBottomLeft.x = gridContainingPoint(oCoords).x; oBottomLeft.y = gridContainingPoint(oCoords).y + iHeight; oBottomRight.x = gridContainingPoint(oCoords).x + iWidth; oBottomRight.y = gridContainingPoint(oCoords).y + iHeight; canvas.save(); canvas.translate(-fX, -fY); oCloud.setBounds(oTopLeft.x, oTopLeft.y, oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight); oCloud.draw(canvas); oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y, oTopLeft.x + (this.iImageWidth * 2), oTopLeft.y + this.iImageHeight); oCloud.draw(canvas); oCloud.setBounds(oTopLeft.x, oTopLeft.y + this.iImageHeight, oTopLeft.x + this.iImageWidth, oTopLeft.y + (this.iImageHeight * 2)); oCloud.draw(canvas); oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight, oTopLeft.x + (this.iImageWidth * 2),oTopLeft.y + (this.iImageHeight * 2)); oCloud.draw(canvas); canvas.restore(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload