List of usage examples for android.graphics Canvas rotate
public final void rotate(float degrees, float px, float py)
From source file:com.ad.view.staggeredgridview.StaggeredGridView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mTopEdge != null) { boolean needsInvalidate = false; if (!mTopEdge.isFinished()) { mTopEdge.draw(canvas);//from ww w . j a v a 2 s. c o m needsInvalidate = true; } if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); canvas.translate(-width, getHeight()); canvas.rotate(180, width, 0); mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); needsInvalidate = true; } if (needsInvalidate) { invalidate(); } } // drawSelector(canvas); }
From source file:chan.android.app.bitwise.util.StaggeredGridView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mTopEdge != null) { boolean needsInvalidate = false; if (!mTopEdge.isFinished()) { mTopEdge.draw(canvas);/* ww w.j a v a 2s. c o m*/ needsInvalidate = true; } if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); canvas.translate(-width, getHeight()); canvas.rotate(180, width, 0); mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); needsInvalidate = true; } if (needsInvalidate) { invalidate(); } } // drawSelector(canvas); }
From source file:com.dishes.views.stageredggridview.StaggeredGridView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mTopEdge != null) { boolean needsInvalidate = false; if (!mTopEdge.isFinished()) { mTopEdge.draw(canvas);/* w w w . ja v a2s . c om*/ needsInvalidate = true; } if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); canvas.translate(-width, getHeight()); canvas.rotate(180, width, 0); mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); needsInvalidate = true; } if (needsInvalidate) { invalidate(); } } if (mFastScroller != null) { final int scrollY = this.getScrollY(); if (scrollY != 0) { // Pin to the top/bottom during overscroll int restoreCount = canvas.save(); canvas.translate(0, (float) scrollY); mFastScroller.draw(canvas); canvas.restoreToCount(restoreCount); } else { mFastScroller.draw(canvas); } } // drawSelector(canvas); }
From source file:com.dian.diabetes.widget.VerticalViewPager.java
@Override public void draw(Canvas canvas) { super.draw(canvas); boolean needsInvalidate = false; //jelle disabled edge effect final int overScrollMode = ViewCompat.getOverScrollMode(this); if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null && mAdapter.getCount() > 1)) { final int height = getHeight(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); if (!mTopEdge.isFinished()) { mTopEdge.setSize(width, height); needsInvalidate |= mTopEdge.draw(canvas); }/* ww w.jav a 2 s .c om*/ if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); canvas.translate(-width + getPaddingLeft(), getScrollY() + height); canvas.rotate(180, width, 0); mBottomEdge.setSize(width, height); needsInvalidate |= mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); } } else { mTopEdge.finish(); mBottomEdge.finish(); } if (needsInvalidate) { // Keep animating ViewCompat.postInvalidateOnAnimation(this); } }
From source file:ticwear.design.widget.CoordinatorLayout.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mEdgeGlowTop != null) { if (!mEdgeGlowTop.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); int edgeY = Math.min(0, getScrollY()); canvas.translate(0, edgeY);/* www .j a va2 s .c om*/ mEdgeGlowTop.setSize(width, getHeight()); if (mEdgeGlowTop.draw(canvas)) { invalidate(0, 0, getWidth(), mEdgeGlowTop.getMaxHeight() + getPaddingTop()); } canvas.restoreToCount(restoreCount); } if (!mEdgeGlowBottom.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight(); int edgeX = -width; int edgeY = Math.max(height, getScrollY() + height); canvas.translate(edgeX, edgeY); canvas.rotate(180, width, 0); mEdgeGlowBottom.setSize(width, height); if (mEdgeGlowBottom.draw(canvas)) { invalidate(0, getHeight() - getPaddingBottom() - mEdgeGlowBottom.getMaxHeight(), getWidth(), getHeight()); } canvas.restoreToCount(restoreCount); } } }
From source file:com.jjoe64.graphview.GridLabelRenderer.java
/** * draws the horizontal steps//from w ww. ja v a2 s. c om * vertical lines and horizontal labels * * @param canvas canvas */ protected void drawHorizontalSteps(Canvas canvas) { // draw horizontal steps (vertical lines and horizontal labels) mPaintLabel.setColor(getHorizontalLabelsColor()); int i = 0; for (Map.Entry<Integer, Double> e : mStepsHorizontal.entrySet()) { // draw line if (mStyles.highlightZeroLines) { if (e.getValue() == 0d) { mPaintLine.setStrokeWidth(5); } else { mPaintLine.setStrokeWidth(0); } } if (mStyles.gridStyle.drawVertical()) { canvas.drawLine(mGraphView.getGraphContentLeft() + e.getKey(), mGraphView.getGraphContentTop(), mGraphView.getGraphContentLeft() + e.getKey(), mGraphView.getGraphContentTop() + mGraphView.getGraphContentHeight(), mPaintLine); } // draw label if (isHorizontalLabelsVisible()) { if (mStyles.horizontalLabelsAngle > 0f && mStyles.horizontalLabelsAngle <= 180f) { if (mStyles.horizontalLabelsAngle < 90f) { mPaintLabel.setTextAlign((Paint.Align.RIGHT)); } else if (mStyles.horizontalLabelsAngle <= 180f) { mPaintLabel.setTextAlign((Paint.Align.LEFT)); } } else { mPaintLabel.setTextAlign(Paint.Align.CENTER); if (i == mStepsHorizontal.size() - 1) mPaintLabel.setTextAlign(Paint.Align.RIGHT); if (i == 0) mPaintLabel.setTextAlign(Paint.Align.LEFT); } // multiline labels String label = mLabelFormatter.formatLabel(e.getValue(), true); if (label == null) { label = ""; } String[] lines = label.split("\n"); // If labels are angled, calculate adjustment to line them up with the grid int labelWidthAdj = 0; if (mStyles.horizontalLabelsAngle > 0f && mStyles.horizontalLabelsAngle <= 180f) { Rect textBounds = new Rect(); mPaintLabel.getTextBounds(lines[0], 0, lines[0].length(), textBounds); labelWidthAdj = (int) Math .abs(textBounds.width() * Math.cos(Math.toRadians(mStyles.horizontalLabelsAngle))); } for (int li = 0; li < lines.length; li++) { // for the last line y = height float y = (canvas.getHeight() - mStyles.padding - getHorizontalAxisTitleHeight()) - (lines.length - li - 1) * getTextSize() * 1.1f + mStyles.labelsSpace; float x = mGraphView.getGraphContentLeft() + e.getKey(); if (mStyles.horizontalLabelsAngle > 0 && mStyles.horizontalLabelsAngle < 90f) { canvas.save(); canvas.rotate(mStyles.horizontalLabelsAngle, x + labelWidthAdj, y); canvas.drawText(lines[li], x + labelWidthAdj, y, mPaintLabel); canvas.restore(); } else if (mStyles.horizontalLabelsAngle > 0 && mStyles.horizontalLabelsAngle <= 180f) { canvas.save(); canvas.rotate(mStyles.horizontalLabelsAngle - 180f, x - labelWidthAdj, y); canvas.drawText(lines[li], x - labelWidthAdj, y, mPaintLabel); canvas.restore(); } else { canvas.drawText(lines[li], x, y, mPaintLabel); } } } i++; } }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mTopEdge != null) { boolean needsInvalidate = false; if (!mTopEdge.isFinished()) { final int restoreCount = canvas.save(); canvas.translate(0, 0);//from ww w. java2s . c om mTopEdge.draw(canvas); canvas.restoreToCount(restoreCount); needsInvalidate = true; } if (!mBottomEdge.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); canvas.translate(-width, getHeight()); canvas.rotate(180, width, 0); mBottomEdge.draw(canvas); canvas.restoreToCount(restoreCount); needsInvalidate = true; } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } } }
From source file:com.raibow.yamahaspk.filtershow.imageshow.ImageShow.java
public void drawImageAndAnimate(Canvas canvas, Bitmap image) { if (image == null) { return;/*from ww w .jav a 2s. c o m*/ } MasterImage master = MasterImage.getImage(); Matrix m = master.computeImageToScreen(image, 0, false); if (m == null) { return; } canvas.save(); RectF d = new RectF(0, 0, image.getWidth(), image.getHeight()); m.mapRect(d); d.roundOut(mImageBounds); boolean showAnimatedImage = master.onGoingNewLookAnimation(); if (!showAnimatedImage && mDidStartAnimation) { // animation ended, but do we have the correct image to show? if (master.getPreset().equals(master.getCurrentPreset())) { // we do, let's stop showing the animated image mDidStartAnimation = false; MasterImage.getImage().resetAnimBitmap(); } else { showAnimatedImage = true; } } else if (showAnimatedImage) { mDidStartAnimation = true; } if (showAnimatedImage) { canvas.save(); // Animation uses the image before the change Bitmap previousImage = master.getPreviousImage(); Matrix mp = master.computeImageToScreen(previousImage, 0, false); RectF dp = new RectF(0, 0, previousImage.getWidth(), previousImage.getHeight()); mp.mapRect(dp); Rect previousBounds = new Rect(); dp.roundOut(previousBounds); float centerX = dp.centerX(); float centerY = dp.centerY(); boolean needsToDrawImage = true; if (master.getCurrentLookAnimation() == MasterImage.CIRCLE_ANIMATION) { float maskScale = MasterImage.getImage().getMaskScale(); if (maskScale >= 0.0f) { float maskW = sMask.getWidth() / 2.0f; float maskH = sMask.getHeight() / 2.0f; Point point = mActivity.hintTouchPoint(this); float maxMaskScale = 2 * Math.max(getWidth(), getHeight()) / Math.min(maskW, maskH); maskScale = maskScale * maxMaskScale; float x = point.x - maskW * maskScale; float y = point.y - maskH * maskScale; // Prepare the shader mShaderMatrix.reset(); mShaderMatrix.setScale(1.0f / maskScale, 1.0f / maskScale); mShaderMatrix.preTranslate(-x + mImageBounds.left, -y + mImageBounds.top); float scaleImageX = mImageBounds.width() / (float) image.getWidth(); float scaleImageY = mImageBounds.height() / (float) image.getHeight(); mShaderMatrix.preScale(scaleImageX, scaleImageY); mMaskPaint.reset(); mMaskPaint.setShader(createShader(image)); mMaskPaint.getShader().setLocalMatrix(mShaderMatrix); drawShadow(canvas, mImageBounds); // as needed canvas.drawBitmap(previousImage, m, mPaint); canvas.clipRect(mImageBounds); canvas.translate(x, y); canvas.scale(maskScale, maskScale); canvas.drawBitmap(sMask, 0, 0, mMaskPaint); needsToDrawImage = false; } } else if (master.getCurrentLookAnimation() == MasterImage.ROTATE_ANIMATION) { Rect d1 = computeImageBounds(master.getPreviousImage().getHeight(), master.getPreviousImage().getWidth()); Rect d2 = computeImageBounds(master.getPreviousImage().getWidth(), master.getPreviousImage().getHeight()); float finalScale = d1.width() / (float) d2.height(); finalScale = (1.0f * (1.0f - master.getAnimFraction())) + (finalScale * master.getAnimFraction()); canvas.rotate(master.getAnimRotationValue(), centerX, centerY); canvas.scale(finalScale, finalScale, centerX, centerY); } else if (master.getCurrentLookAnimation() == MasterImage.MIRROR_ANIMATION) { if (master.getCurrentFilterRepresentation() instanceof FilterMirrorRepresentation) { FilterMirrorRepresentation rep = (FilterMirrorRepresentation) master .getCurrentFilterRepresentation(); ImagePreset preset = master.getPreset(); ArrayList<FilterRepresentation> geometry = (ArrayList<FilterRepresentation>) preset .getGeometryFilters(); GeometryMathUtils.GeometryHolder holder = null; holder = GeometryMathUtils.unpackGeometry(geometry); if (holder.rotation.value() == 90 || holder.rotation.value() == 270) { if (rep.isHorizontal() && !rep.isVertical()) { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } else if (rep.isVertical() && !rep.isHorizontal()) { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } else if (rep.isHorizontal() && rep.isVertical()) { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } else { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } } else { if (rep.isHorizontal() && !rep.isVertical()) { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } else if (rep.isVertical() && !rep.isHorizontal()) { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } else if (rep.isHorizontal() && rep.isVertical()) { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } else { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } } } } if (needsToDrawImage) { drawShadow(canvas, previousBounds); // as needed canvas.drawBitmap(previousImage, mp, mPaint); } canvas.restore(); } else { drawShadow(canvas, mImageBounds); // as needed canvas.drawBitmap(image, m, mPaint); } canvas.restore(); }
From source file:com.lt.adamlee.aagame.GameView.java
public void onDraw(Canvas c) { try {//from www. ja va2s . c o m if (mainpage == -1) { this.eg.exitdialog(c); } if (mainpage == 1) { if (bak2) { internalcounter2++; if (internalcounter2 % 10 == 0) { counter1234++; } if (counter1234 >= 2) { counter1234 = 0; internalcounter2 = 0; bak2 = false; } } if (bak4) { this.internalcounter4++; if (this.internalcounter4 % 10 == 0) { this.counter12346++; } if (this.counter12346 >= 2) { this.counter12346 = 0; this.internalcounter4 = 0; bak4 = false; } } c.drawBitmap(this.mainpageimage, 0.0f, 0.0f, null); c.drawBitmap(this.play, F.wf(110.0f), F.hf(175.0f), null); c.drawBitmap(this.moreapps, F.wf(45.0f), F.hf(340.0f), null); c.drawBitmap(this.help, F.wf(130.0f), F.hf(340.0f), null); c.drawBitmap(this.leaderboard, F.wf(215.0f), F.hf(340.0f), null); } if (mainpage == 5) { help(c); } if (mainpage == 6) { this.anim.levelanim(c); } if (mainpage == 7) { if (this.bakc) { this.internalcounterc++; if (this.internalcounterc % 10 == 0) { this.counterc++; } if (this.counterc >= 2) { this.counterc = 0; this.internalcounterc = 0; this.bakc = false; } } this.level.Level_Canvas(c); } if (mainpage == 3) { float[] fArr; if (baka) { this.internalcountera++; if (this.internalcountera % 10 == 0) { this.countera++; } if (this.countera >= 2) { this.countera = 0; this.internalcountera = 0; baka = false; } } view.drawRectangle(c); if (levelcounter % 3 == 0) { if (rotation[0] <= 0.0f && rotation[0] <= 0.0f) { changeangle = 2.0d; } if (rotation[0] > 0.0f && rotation[0] >= 360.0f) { changeangle = -2.0d; } } if (levelcounter % 3 == 1) { changeangle = 2.0d; } if (levelcounter % 3 == 2) { changeangle = -2.0d; } x = (int) F.wf(160.0f); y = (int) F.hf(159.0f); r = (int) F.wf(10.0f); int i = 0; while (i < blinedraw.length) { if (blinedraw[i]) { c.save(); c.rotate(rotation[i], (float) (screenW / 2), F.hf(272.0f)); c.drawLine((float) (screenW / 2), F.hf(272.0f), (float) (screenW / 2), F.hf(272.0f) - F.hf(105.0f), paint4); c.drawCircle((float) x, (float) y, (float) r, paint3); c.drawBitmap(this.cartoonbomb, new Rect(0, 0, this.cartoonbomb.getWidth(), this.cartoonbomb.getHeight()), new Rect(x - (this.cartoonbomb.getWidth() / 2), y - (this.cartoonbomb.getHeight() / 2), x + (this.cartoonbomb.getWidth() / 2), y + (this.cartoonbomb.getHeight() / 2)), null); if (i >= saveline) { c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)), this.innercircletext); } savex[i] = x; savey[i] = y; if (changeangle > 0.0d && rotation[i] >= 360.0f) { rotation[i] = 0.0f; } if (changeangle < 0.0d && rotation[i] <= -360.0f) { rotation[i] = 0.0f; } if (!(errorcircle || !GameActivity.isResume || circleblink)) { fArr = rotation; fArr[i] = (float) (((double) fArr[i]) + changeangle); } c.restore(); if (circleblink) { holdcounter++; if (holdcounter > 32000) { holdcounter = 0; } if (holdcounter % 5 == 0) { hcm++; } if (hcm > 32000) { hcm = 0; } if (hcm <= 9) { h = (int) F.wf(160.0f); j = (int) F.hf(159.0f); k = (int) F.wf(11.0f); paint7.setAlpha(a1); paint7.setColor(SupportMenu.CATEGORY_MASK); paint7.setAntiAlias(true); paint7.setFilterBitmap(true); paint7.setStrokeWidth(2.0f); c.drawCircle((float) h, (float) j, (float) k, paint7); c.drawCircle((float) x, (float) y, (float) r, paint3); if (i >= saveline) { c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)), this.innercircletext); } } if (hcm >= 11) { circleblink = false; mainpage = 6; // GameActivity.vimapad.isBottomAdVisible(true); // GameActivity.vimapad.isTopAdVisible(true); holdcounter = 0; hcm = 0; } } } i++; } i = 0; while (i < circledrawboolean.length) { if (circledrawboolean[i]) { c.save(); c.rotate(rotation[i], (float) (screenW / 2), F.hf(272.0f)); c.drawLine((float) (screenW / 2), F.hf(272.0f), (float) (screenW / 2), F.hf(272.0f) - F.hf(105.0f), paint4); c.drawCircle((float) x, (float) y, (float) r, paint3); if (i >= saveline) { c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)), this.innercircletext); } savex[i] = x; savey[i] = y; if (changeangle > 0.0d && rotation[i] >= 360.0f) { rotation[i] = 0.0f; } if (changeangle < 0.0d && rotation[i] <= -360.0f) { rotation[i] = 0.0f; } if (!(errorcircle || !GameActivity.isResume || circleblink)) { fArr = rotation; fArr[i] = (float) (((double) fArr[i]) + changeangle); } c.restore(); if (colcircle) { this.displaycount3++; textdisplayboolean = false; if (this.displaycount3 <= 70 || (this.displaycount3 >= 80 && this.displaycount3 <= 90)) { paint6.setAntiAlias(true); } paint6.setFilterBitmap(true); paint6.setColor(ViewCompat.MEASURED_STATE_MASK); c.drawCircle((float) (screenW / 2), F.hf(272.0f), F.wf(39.0f), paint6); paint6.setColor(SupportMenu.CATEGORY_MASK); paint6.setAntiAlias(true); paint6.setFilterBitmap(true); paint6.setTypeface(tf); paint6.setAlpha(Circle.a); paint6.setTextAlign(Paint.Align.CENTER); c.drawText(String.valueOf(levelcounter), F.wf(160.0f), F.hf(278.0f), paint6); paint6.setColor(getResources().getColor(R.color.common_signin_btn_default_background)); paint6.setAlpha(20); paint6.setAntiAlias(true); paint6.setFilterBitmap(true); c.drawRect(0.0f, 0.0f, (float) screenW, (float) screenH, paint6); if (this.displaycount3 <= 70 || this.displaycount3 >= 80) { } if (this.displaycount3 > 90) { int j; this.displaycount3 = 0; colcircle = false; circleblink = false; bak4 = true; reset(); levelcounter++; errorcircle = false; linecounter = NoOfInitialLines - 1; for (j = 0; j < NoOfInitialLines; j++) { blinedraw[j] = true; } for (j = 0; j < rotation.length; j++) { rotation[j] = 0.0f; } for (j = 0; j < NoOfInitialLines; j++) { rotation[j] = (float) ((j + 1) * (360 / NoOfInitialLines)); if (rotation[j] > 360.0f) { rotation[j] = rotation[j] - 360.0f; } } } } } i++; } this.paint21.setColor(-1); this.paint21.setTypeface(tf); this.paint21.setTextAlign(Paint.Align.CENTER); this.paint21.setAntiAlias(true); this.paint21.setFilterBitmap(true); if (textdisplayboolean) { c.drawText(String.valueOf(levelcounter), F.wf(160.0f), F.hf(278.0f), this.paint21); } } } catch (Exception e) { } }
From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java
public void drawImageAndAnimate(Canvas canvas, Bitmap image) { if (image == null) { return;//from ww w .j ava2 s .c o m } MasterImage master = MasterImage.getImage(); Matrix m = master.computeImageToScreen(image, 0, false); if (m == null) { return; } canvas.save(); RectF d = new RectF(0, 0, image.getWidth(), image.getHeight()); m.mapRect(d); d.roundOut(mImageBounds); boolean showAnimatedImage = master.onGoingNewLookAnimation(); if (!showAnimatedImage && mDidStartAnimation) { // animation ended, but do we have the correct image to show? if (master.getPreset().equals(master.getCurrentPreset())) { // we do, let's stop showing the animated image mDidStartAnimation = false; MasterImage.getImage().resetAnimBitmap(); } else { showAnimatedImage = true; } } else if (showAnimatedImage) { mDidStartAnimation = true; } if (showAnimatedImage) { canvas.save(); // Animation uses the image before the change Bitmap previousImage = master.getPreviousImage(); Matrix mp = master.computeImageToScreen(previousImage, 0, false); RectF dp = new RectF(0, 0, previousImage.getWidth(), previousImage.getHeight()); mp.mapRect(dp); Rect previousBounds = new Rect(); dp.roundOut(previousBounds); float centerX = dp.centerX(); float centerY = dp.centerY(); boolean needsToDrawImage = true; if (master.getCurrentLookAnimation() == MasterImage.CIRCLE_ANIMATION) { float maskScale = MasterImage.getImage().getMaskScale(); if (maskScale >= 0.0f) { float maskW = sMask.getWidth() / 2.0f; float maskH = sMask.getHeight() / 2.0f; Point point = mActivity.hintTouchPoint(this); float maxMaskScale = 2 * Math.max(getWidth(), getHeight()) / Math.min(maskW, maskH); maskScale = maskScale * maxMaskScale; float x = point.x - maskW * maskScale; float y = point.y - maskH * maskScale; // Prepare the shader mShaderMatrix.reset(); mShaderMatrix.setScale(1.0f / maskScale, 1.0f / maskScale); mShaderMatrix.preTranslate(-x + mImageBounds.left, -y + mImageBounds.top); float scaleImageX = mImageBounds.width() / (float) image.getWidth(); float scaleImageY = mImageBounds.height() / (float) image.getHeight(); mShaderMatrix.preScale(scaleImageX, scaleImageY); mMaskPaint.reset(); Shader maskShader = createShader(image); maskShader.setLocalMatrix(mShaderMatrix); mMaskPaint.setShader(maskShader); drawShadow(canvas, mImageBounds); // as needed canvas.drawBitmap(previousImage, m, mPaint); canvas.clipRect(mImageBounds); canvas.translate(x, y); canvas.scale(maskScale, maskScale); canvas.drawBitmap(sMask, 0, 0, mMaskPaint); needsToDrawImage = false; } } else if (master.getCurrentLookAnimation() == MasterImage.ROTATE_ANIMATION) { Rect d1 = computeImageBounds(master.getPreviousImage().getHeight(), master.getPreviousImage().getWidth()); Rect d2 = computeImageBounds(master.getPreviousImage().getWidth(), master.getPreviousImage().getHeight()); float finalScale = d1.width() / (float) d2.height(); finalScale = (1.0f * (1.0f - master.getAnimFraction())) + (finalScale * master.getAnimFraction()); canvas.rotate(master.getAnimRotationValue(), centerX, centerY); canvas.scale(finalScale, finalScale, centerX, centerY); } else if (master.getCurrentLookAnimation() == MasterImage.MIRROR_ANIMATION) { if (master.getCurrentFilterRepresentation() instanceof FilterMirrorRepresentation) { FilterMirrorRepresentation rep = (FilterMirrorRepresentation) master .getCurrentFilterRepresentation(); ImagePreset preset = master.getPreset(); ArrayList<FilterRepresentation> geometry = (ArrayList<FilterRepresentation>) preset .getGeometryFilters(); GeometryMathUtils.GeometryHolder holder = null; holder = GeometryMathUtils.unpackGeometry(geometry); if (holder.rotation.value() == 90 || holder.rotation.value() == 270) { if (rep.isHorizontal() && !rep.isVertical()) { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } else if (rep.isVertical() && !rep.isHorizontal()) { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } else if (rep.isHorizontal() && rep.isVertical()) { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } else { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } } else { if (rep.isHorizontal() && !rep.isVertical()) { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } else if (rep.isVertical() && !rep.isHorizontal()) { canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY); } else if (rep.isHorizontal() && rep.isVertical()) { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } else { canvas.scale(1, master.getAnimRotationValue(), centerX, centerY); } } } } if (needsToDrawImage) { drawShadow(canvas, previousBounds); // as needed canvas.drawBitmap(previousImage, mp, mPaint); } canvas.restore(); } else { drawShadow(canvas, mImageBounds); // as needed canvas.drawBitmap(image, m, mPaint); } canvas.restore(); }