List of usage examples for android.graphics Canvas rotate
public final void rotate(float degrees, float px, float py)
From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java
private void rotateArrow() { final Drawable drawable = mHeaderArrow.getDrawable(); final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888);// w w w . j a v a 2 s . c o m final Canvas canvas = new Canvas(bitmap); canvas.save(); canvas.rotate(180.0f, canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); canvas.restore(); mHeaderArrow.setImageBitmap(bitmap); }
From source file:com.byagowi.persiancalendar.view.QiblaCompassView.java
public void drawQibla(Canvas canvas) { canvas.rotate((float) qiblaInfo.getHeading() - 360, px, py); qiblaPaint.reset();/* www .j a va 2 s.c om*/ qiblaPaint.setColor(Color.GREEN); qiblaPaint.setStyle(Paint.Style.FILL_AND_STROKE); qiblaPaint.setPathEffect(dashPath); qiblaPaint.setStrokeWidth(5.5f); canvas.drawLine(px, py - Radius, px, py + Radius, qiblaPaint); qiblaPaint.setPathEffect(null); canvas.drawBitmap(kaaba, px - kaaba.getWidth() / 2, py - Radius - kaaba.getHeight() / 2, qiblaPaint); canvas.restore(); }
From source file:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java
@Override public void draw(Canvas canvas) { canvas.save();// w w w . j av a2s . c o m canvas.rotate(mGlobalAngle, mBounds.centerX(), mBounds.centerY()); for (int i = 0; i < mSpinnerCount; i++) { canvas.drawPath(mSpinners[i].path, mSpinners[i].paint); } canvas.restore(); }
From source file:com.hippo.widget.ProgressView.java
@Override protected void onDraw(Canvas canvas) { int saved = canvas.save(); canvas.rotate(mTrimRotation, mRectF.centerX(), mRectF.centerY()); float startAngle = (mTrimStart + mTrimOffset) * 360.0f - 90; float sweepAngle = (mTrimEnd - mTrimStart) * 360.0f; canvas.drawArc(mRectF, startAngle, sweepAngle, false, mPaint); canvas.restoreToCount(saved);/*from w w w . j a v a 2 s .co m*/ if (mShouldStartAnimationDrawable) { mShouldStartAnimationDrawable = false; startAnimationActually(); } }
From source file:com.yanzhenjie.album.widget.loading.LevelLoadingRenderer.java
@Override protected void draw(Canvas canvas) { int saveCount = canvas.save(); mTempBounds.set(mBounds);// w ww.j a v a 2 s . c om mTempBounds.inset(mStrokeInset, mStrokeInset); canvas.rotate(mGroupRotation, mTempBounds.centerX(), mTempBounds.centerY()); for (int i = 0; i < 3; i++) { if (mLevelSwipeDegrees[i] != 0) { mPaint.setColor(mLevelColors[i]); canvas.drawArc(mTempBounds, mEndDegrees, mLevelSwipeDegrees[i], false, mPaint); } } canvas.restoreToCount(saveCount); }
From source file:android.support.design.widget.ShadowDrawableWrapper.java
private void drawShadow(Canvas canvas) { final int rotateSaved = canvas.save(); canvas.rotate(mRotation, mContentBounds.centerX(), mContentBounds.centerY()); final float edgeShadowTop = -mCornerRadius - mShadowSize; final float shadowOffset = mCornerRadius; final boolean drawHorizontalEdges = mContentBounds.width() - 2 * shadowOffset > 0; final boolean drawVerticalEdges = mContentBounds.height() - 2 * shadowOffset > 0; final float shadowOffsetTop = mRawShadowSize - (mRawShadowSize * SHADOW_TOP_SCALE); final float shadowOffsetHorizontal = mRawShadowSize - (mRawShadowSize * SHADOW_HORIZ_SCALE); final float shadowOffsetBottom = mRawShadowSize - (mRawShadowSize * SHADOW_BOTTOM_SCALE); final float shadowScaleHorizontal = shadowOffset / (shadowOffset + shadowOffsetHorizontal); final float shadowScaleTop = shadowOffset / (shadowOffset + shadowOffsetTop); final float shadowScaleBottom = shadowOffset / (shadowOffset + shadowOffsetBottom); // LT// w w w.j a v a2s. c om int saved = canvas.save(); canvas.translate(mContentBounds.left + shadowOffset, mContentBounds.top + shadowOffset); canvas.scale(shadowScaleHorizontal, shadowScaleTop); canvas.drawPath(mCornerShadowPath, mCornerShadowPaint); if (drawHorizontalEdges) { // TE canvas.scale(1f / shadowScaleHorizontal, 1f); canvas.drawRect(0, edgeShadowTop, mContentBounds.width() - 2 * shadowOffset, -mCornerRadius, mEdgeShadowPaint); } canvas.restoreToCount(saved); // RB saved = canvas.save(); canvas.translate(mContentBounds.right - shadowOffset, mContentBounds.bottom - shadowOffset); canvas.scale(shadowScaleHorizontal, shadowScaleBottom); canvas.rotate(180f); canvas.drawPath(mCornerShadowPath, mCornerShadowPaint); if (drawHorizontalEdges) { // BE canvas.scale(1f / shadowScaleHorizontal, 1f); canvas.drawRect(0, edgeShadowTop, mContentBounds.width() - 2 * shadowOffset, -mCornerRadius + mShadowSize, mEdgeShadowPaint); } canvas.restoreToCount(saved); // LB saved = canvas.save(); canvas.translate(mContentBounds.left + shadowOffset, mContentBounds.bottom - shadowOffset); canvas.scale(shadowScaleHorizontal, shadowScaleBottom); canvas.rotate(270f); canvas.drawPath(mCornerShadowPath, mCornerShadowPaint); if (drawVerticalEdges) { // LE canvas.scale(1f / shadowScaleBottom, 1f); canvas.drawRect(0, edgeShadowTop, mContentBounds.height() - 2 * shadowOffset, -mCornerRadius, mEdgeShadowPaint); } canvas.restoreToCount(saved); // RT saved = canvas.save(); canvas.translate(mContentBounds.right - shadowOffset, mContentBounds.top + shadowOffset); canvas.scale(shadowScaleHorizontal, shadowScaleTop); canvas.rotate(90f); canvas.drawPath(mCornerShadowPath, mCornerShadowPaint); if (drawVerticalEdges) { // RE canvas.scale(1f / shadowScaleTop, 1f); canvas.drawRect(0, edgeShadowTop, mContentBounds.height() - 2 * shadowOffset, -mCornerRadius, mEdgeShadowPaint); } canvas.restoreToCount(saved); canvas.restoreToCount(rotateSaved); }
From source file:com.byagowi.persiancalendar.view.QiblaCompassView.java
public void drawSun(Canvas canvas) { sunPaint.reset();//w w w .j a v a 2s . co m sunPaint.setColor(Color.YELLOW); sunPaint.setStyle(Paint.Style.FILL_AND_STROKE); // Horizontal sunPosition = new Horizontal(225, 45); if (sunPosition.getElevation() > -10) { canvas.rotate((float) sunPosition.getAzimuth() - 360, px, py); sunPaint.setPathEffect(dashPath); int ry = (int) (((90 - sunPosition.getElevation()) / 90) * Radius); canvas.drawCircle(px, py - ry, r, sunPaint); dashedPaint.setColor(Color.YELLOW); canvas.drawLine(px, py - Radius, px, py + Radius, dashedPaint); sunPaint.setPathEffect(null); canvas.restore(); } }
From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java
private void drawGaugeNeedle(Canvas canvas, int count, int Scale) { canvas.save(Canvas.MATRIX_SAVE_FLAG); float divisor = 360.0f / Scale; canvas.rotate((float) (divisor * count), 100, 100); //Inside/*w w w .jav a 2 s. c o m*/ Paint needleInsidePaint = new Paint(); needleInsidePaint.setStyle(Paint.Style.FILL_AND_STROKE); needleInsidePaint.setColor(Color.WHITE); needleInsidePaint.setStrokeWidth(4); needleInsidePaint.setAntiAlias(true); Paint needleEdgePaint = new Paint(); needleEdgePaint.setStyle(Paint.Style.STROKE); needleEdgePaint.setColor(Color.DKGRAY); needleEdgePaint.setStrokeWidth(0.5f); needleEdgePaint.setAntiAlias(true); canvas.drawOval(new RectF(95, 95, 105, 105), needleInsidePaint); canvas.drawOval(new RectF(95, 96, 105, 105), needleEdgePaint); Path needleInside = new Path(); needleInside.moveTo(98, 98); needleInside.lineTo(100, 20); needleInside.lineTo(102, 102); canvas.drawPath(needleInside, needleInsidePaint); Path needleEdge = new Path(); needleInside.moveTo(99, 99); needleInside.lineTo(99, 19); needleInside.lineTo(103, 103); canvas.drawPath(needleEdge, needleEdgePaint); canvas.restore(); }
From source file:com.example.waitou.rxjava.LoadingView.java
@Override protected void onDraw(Canvas canvas) { if (!mIsAnimatorCancel) { final Rect bounds = getBounds(); final int saveCount = canvas.save(); canvas.rotate(mRotation * 360, bounds.exactCenterX(), bounds.exactCenterY()); drawRing(canvas, bounds);/*from w w w.ja v a 2 s . c o m*/ canvas.restoreToCount(saveCount); } else { canvas.restore(); } }
From source file:com.byagowi.persiancalendar.view.QiblaCompassView.java
@Override protected void onDraw(Canvas canvas) { this.Radius = Math.min(px, py); this.r = Radius / 10; // Sun Moon radius; // over here//w w w . j av a 2s . c o m qiblaInfo = sunMoonPosition.getDestinationHeading(); textPaint.setTextAlign(Paint.Align.LEFT); textPaint.setColor(ContextCompat.getColor(getContext(), (R.color.qibla_color))); canvas.rotate(-bearing, px, py);// Attach and Detach capability lies canvas.save(); drawDial(canvas); if (isLongLatAvailable()) { canvas.save(); drawQibla(canvas); } canvas.save(); drawTrueNorthArrow(canvas, bearing); if (isLongLatAvailable()) { canvas.save(); drawMoon(canvas); canvas.save(); drawSun(canvas); } canvas.save(); }