3

I want to know about internals of canvas.getClipBound method. please guide me building my understanding.

for example: While drawing on canvas and zoomed , using clipBounds we can get the scrolled x and y positions by asking

int l = canvas.getClipBound().left;
int t = canvas.getClipBound().top;

I want to know how exactly it works internally.

mohit
  • 1,011
  • 2
  • 16
  • 26
  • see the link, this may be useful [see link](http://stackoverflow.com/questions/10941416/understanding-android-canvas-clipping) – AndroUser Aug 16 '13 at 06:59

1 Answers1

3

Suppose your Canvas has width and height as 480x800 and you have drawn something on it. Once you zoom it, the android system will calculate how much area of the current canvas can be shown to user for that particular zoom level, and that much area would be clipped. For example, the actual displayable area of canvas once it is zoomed could be 300x500, then the clip area would be the same 300x500, means, this 300x500 is zoomed and shown in the 480x800 display. In this example, the rest of the area ( width & height) of original canvas which is not currently displaying can be calculated as

xScroll = 480-300;

and

yScroll = 800-500;

canvas.getClipBound().left; gives how much the zoomed screen scrolled horizontally and canvas.getClipBound().top; shows how much it is scrolled vertically.

Hope this will help you.

Suji
  • 6,044
  • 2
  • 19
  • 17
  • Actually I want to ask, if I did zoom with [1f < scalefactor < 5f], then how it calculates offset – mohit Aug 17 '13 at 06:59