I know this a stupid question to ask, but I was going through a tutorial
and I just dont seem to understand the below lines of code...Have pulled my
hair understanding the geometrical algorithm behind this, but.....Oh!!!
This is very simple but I just dont seem to get it. Please help....I am a
beginner...




      private void drawPict(Canvas canvas, int x, int y, int w, int h,
                                  float sx, float sy) {
                canvas.save();
                canvas.translate(x, y);
                canvas.clipRect(0, 0, w, h);
                canvas.scale(0.5f, 0.5f);
                canvas.scale(sx, sy, w, h);
                canvas.drawPicture(mPicture);
                canvas.restore();
            }
            @SuppressWarnings("unused")
                @Override
            protected void dispatchDraw(Canvas canvas) {
                super.dispatchDraw(mPicture.beginRecording(getWidth(),
getHeight()));
                mPicture.endRecording();
                int x = getWidth()/2;
                int y = getHeight()/2;
                if (false) {
                    canvas.drawPicture(mPicture);
                } else {
                    drawPict(canvas, 0, 0, x, y,  1,  1);
                    drawPict(canvas, x, 0, x, y, -1,  1);
                    drawPict(canvas, 0, y, x, y,  1, -1);
                    drawPict(canvas, x, y, x, y, -1, -1);
                }
            }

  I have looked into this again...and understand that canvas.scale has 4
parameters, being the co-ordinates of the points I assume...but I cannot
still understand the float sx, float sy...

sx=-1 and sy=1...it will scale, agreed...but is not there a better way?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to