List of usage examples for android.graphics Canvas restoreToCount
public void restoreToCount(int saveCount)
From source file:net.yanzm.actionbarprogress.MaterialIndeterminateProgressDrawable.java
@Override public void draw(Canvas canvas) { final int level = getLevel(); final float input = level / 10000f; canvas.drawColor(trackColor);//from w ww . ja va 2 s. c om canvas.save(); canvas.translate(canvas.getWidth() / 2f, 0); canvas.scale(canvas.getWidth() / 360f, 1); paint.setColor(accentColor); { final int saveCount = canvas.save(); float translateX2 = translateInterpolator2.getInterpolation(input); canvas.translate(-197.60001f + translateX2 * 620.20002f, 0); float x = scaleInterpolator2.getInterpolation(input); float scaleX = 1.6199005127f * -Math.abs(x - 0.5f) + 0.909950256348f; rect2.set(-144f * scaleX, 0, 144f * scaleX, canvas.getHeight()); canvas.drawRect(rect2, paint); canvas.restoreToCount(saveCount); } { final int saveCount = canvas.save(); float translateX1 = translateInterpolator1.getInterpolation(input); canvas.translate(-522.59998f + translateX1 * 722.19999f, 0); float x = scaleInterpolator1.getInterpolation(input); float scaleX = 1.45369842529f * -Math.abs(x - 0.5f) + 0.826849212646f; rect1.set(-144f * scaleX, 0, 144f * scaleX, canvas.getHeight()); canvas.drawRect(rect1, paint); canvas.restoreToCount(saveCount); } canvas.restore(); }
From source file:io.plaidapp.core.ui.widget.CollapsingTitleLayout.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (lineCount == 1) { collapsingText.draw(canvas);/*w w w.ja v a 2 s .com*/ } else { int savePoint = canvas.save(); float x = titleInsetStart; float y = Math.max(textTop - scrollOffset, titleInsetTop); canvas.translate(x, y); canvas.clipRect(0, 0, getWidth() - titleInsetStart - titleInsetEnd, Math.max(getHeight() - scrollOffset, collapsedHeight) - y); layout.draw(canvas); canvas.restoreToCount(savePoint); } }
From source file:cn.spinsoft.wdq.widget.swipe.MaterialProgressDrawable.java
@Override public void draw(Canvas c) { final Rect bounds = getBounds(); final int saveCount = c.save(); c.rotate(mRotation, bounds.exactCenterX(), bounds.exactCenterY()); mRing.draw(c, bounds);// w w w. j av a2 s. c om c.restoreToCount(saveCount); }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.DraggingItemDecorator.java
private Bitmap createDraggingItemImage(View v, NinePatchDrawable shadow) { int width = v.getWidth() + mShadowPadding.left + mShadowPadding.right; int height = v.getHeight() + mShadowPadding.top + mShadowPadding.bottom; final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); if (shadow != null) { shadow.setBounds(0, 0, width, height); shadow.draw(canvas);//from w w w. j av a 2 s . c om } final int savedCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG); // NOTE: Explicitly set clipping rect. This is required on Gingerbread. canvas.clipRect(mShadowPadding.left, mShadowPadding.top, width - mShadowPadding.right, height - mShadowPadding.bottom); canvas.translate(mShadowPadding.left, mShadowPadding.top); v.draw(canvas); canvas.restoreToCount(savedCount); return bitmap; }
From source file:com.limxing.library.PullToRefresh.SwipeProgressBar.java
void draw(Canvas canvas) { // final int width = mBounds.width(); final int height = mBounds.height(); int restoreCount = canvas.save(); canvas.clipRect(mBounds);//from www . jav a 2 s . com if (mRunning || (mFinishTime > 0)) { if (!mRunning) { mFinishTime = 0; return; } this.tips = processingTips; drawBar(canvas, height); // Keep running until we finish out the last cycle. ViewCompat.postInvalidateOnAnimation(mParent); } else { if (height > 0) { drawBar(canvas, height); } } if (state != FINISHED) { canvas.restoreToCount(restoreCount); } }
From source file:com.zzti.fyg.widgets.SwipeProgressBar.java
void draw(Canvas canvas) { // final int width = mBounds.width(); final int height = mBounds.height(); int restoreCount = canvas.save(); canvas.clipRect(mBounds);//from w ww . j av a 2 s. com if (mRunning || (mFinishTime > 0)) { if (!mRunning) { mFinishTime = 0; return; } this.tips = processingTips; drawBar(canvas, height); // Keep running until we finish out the last cycle. ViewCompat.postInvalidateOnAnimation(mParent); } else { if (height > 0) { drawBar(canvas, height); } } if (state != FINISHED) { canvas.restoreToCount(restoreCount); } }
From source file:vc908.stickerfactory.ui.advancedrecyclerview.swipeable.RemovingItemDecorator.java
private void fillSwipingItemBackground(Canvas c, Drawable drawable, int height) { final Rect bounds = mSwipingItemBounds; final int translationX = mInitialTranslationX; final int translationY = mTranslationY; if (height < 0) { height = bounds.height();/* w w w . ja v a 2 s . com*/ } if ((height == 0) || (drawable == null)) { return; } final int savedCount = c.save(); c.clipRect(bounds.left + translationX, bounds.top + translationY, bounds.right + translationX, bounds.top + translationY + height); // c.drawColor(0xffff0000); // <-- debug c.translate(bounds.left + translationX, bounds.top + translationY - (bounds.height() - height) / 2); drawable.setBounds(0, 0, bounds.width(), bounds.height()); drawable.draw(c); c.restoreToCount(savedCount); }
From source file:com.ceabie.EffectiveLib.EffectImageView.java
@Override protected void onDraw(Canvas canvas) { if (mEffectDrawable == null || mEffectDrawable.getOpacity() == PixelFormat.TRANSPARENT // ? || getDrawable() == null) {//from w w w.j av a2 s . c o m super.onDraw(canvas); return; } if (mRectF == null) { mRectF = new RectF(); } mRectF.left = 0; mRectF.top = 0; mRectF.right = getMeasuredWidth(); mRectF.bottom = getMeasuredHeight(); int saveBottom = 0; // if (!mHardware) { saveBottom = canvas.saveLayer(mRectF, null, Canvas.CLIP_TO_LAYER_SAVE_FLAG | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG); } super.onDraw(canvas); mPaint.setXfermode(mXfermodeDstIn); int saveCount = canvas.saveLayer(mRectF, mPaint, Canvas.CLIP_TO_LAYER_SAVE_FLAG); mPaint.setXfermode(null); mEffectDrawable.draw(canvas); canvas.restoreToCount(saveCount); if (!mHardware) { canvas.restoreToCount(saveBottom); } }
From source file:android.support.v7.widget.AppCompatSeekBarHelper.java
/** * Draw the tick marks./*ww w . j a va2s . co m*/ */ void drawTickMarks(Canvas canvas) { if (mTickMark != null) { final int count = mView.getMax(); if (count > 1) { final int w = mTickMark.getIntrinsicWidth(); final int h = mTickMark.getIntrinsicHeight(); final int halfW = w >= 0 ? w / 2 : 1; final int halfH = h >= 0 ? h / 2 : 1; mTickMark.setBounds(-halfW, -halfH, halfW, halfH); final float spacing = (mView.getWidth() - mView.getPaddingLeft() - mView.getPaddingRight()) / (float) count; final int saveCount = canvas.save(); canvas.translate(mView.getPaddingLeft(), mView.getHeight() / 2); for (int i = 0; i <= count; i++) { mTickMark.draw(canvas); canvas.translate(spacing, 0); } canvas.restoreToCount(saveCount); } } }
From source file:com.github.shareme.gwsmaterialuikit.library.material.drawable.LineMorphingDrawable.java
@Override public void draw(Canvas canvas) { int restoreCount = canvas.save(); float degrees = (mClockwise ? 180 : -180) * ((mPrevState < mCurState ? 0f : 1f) + mAnimProgress); if (mIsRtl)// www.j ava 2s . co m canvas.scale(-1f, 1f, mDrawBound.centerX(), mDrawBound.centerY()); canvas.rotate(degrees, mDrawBound.centerX(), mDrawBound.centerY()); canvas.drawPath(mPath, mPaint); canvas.restoreToCount(restoreCount); }