當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.rotate方法代碼示例

本文整理匯總了Java中android.graphics.Canvas.rotate方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.rotate方法的具體用法?Java Canvas.rotate怎麽用?Java Canvas.rotate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.rotate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawShadow

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawShadow(Canvas canvas) {
    final float edgeShadowTop = -mCornerRadius - mShadowSize;
    final float insetVertical = mCornerRadius + mInsetShadow + mRawShadowSize / 2;
    final float insetHorizontal = -mInsetShadow;
    // LT top
    int saved = canvas.save();
    canvas.translate(mCardBounds.left + insetHorizontal, mCardBounds.top + insetVertical);
    canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
    canvas.drawRect(0, edgeShadowTop,    mCardBounds.width() - 2 * insetHorizontal, -mCornerRadius + mShadowSize,  mEdgeShadowPaint);
    canvas.restoreToCount(saved);

    // RT right
    saved = canvas.save();
    canvas.translate(mCardBounds.right - insetHorizontal, mCardBounds.top + insetVertical);
    canvas.rotate(90f);
    canvas.drawPath(mCornerShadowPath, mCornerShadowPaint);
    canvas.restoreToCount(saved);
}
 
開發者ID:MSay2,項目名稱:Mire,代碼行數:19,代碼來源:CustomShadow.java

示例2: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void draw(Canvas canvas) {
    int saveCount = canvas.save();

    mTempBounds.set(mBounds);
    mTempBounds.inset(mStrokeInset, mStrokeInset);

    canvas.rotate(mGroupRotation, mTempBounds.centerX(), mTempBounds.centerY());

    if (mSwipeDegrees != 0) {
        mPaint.setColor(mCurrentColor);
        canvas.drawArc(mTempBounds, mStartDegrees, mSwipeDegrees, false, mPaint);
    }

    canvas.restoreToCount(saveCount);
}
 
開發者ID:ZhuoKeTeam,項目名稱:JueDiQiuSheng,代碼行數:17,代碼來源:MaterialLoadingRenderer.java

示例3: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
public void draw(Canvas canvas)
    {
        super.draw(canvas);

        if (this.isShowPointName)
        {
            int i = 0;
            if (this.textWidth < this.mArrowWidth * 2)
                i = this.mArrowWidth - this.textWidth / 2;
            canvas.drawText(this.positionName, i, Math.abs(this.textPaint.getFontMetrics().top), this.textPaint);
        }
        if (this.isShowArrow)
        {
            canvas.save();
            canvas.rotate(-this.angle + this.matrixRotateAngle, this.moveX, this.moveY);
//            canvas.drawBitmap(this.mArrow, this.moveX, this.mainPosition.getTop(), new Paint());
            canvas.restore();
        }
    }
 
開發者ID:ZhouKanZ,項目名稱:SweepRobot,代碼行數:20,代碼來源:CoordinateView.java

示例4: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas){
    canvas.save();
    canvas.rotate(45, this.getWidth()/2 + 10, this.getHeight()/2);
    super.onDraw(canvas);
    canvas.restore();
}
 
開發者ID:zeevy,項目名稱:grblcontroller,代碼行數:8,代碼來源:AngledText45.java

示例5: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas, Paint paint) {
    float radius=getWidth()/10;
    for (int i = 0; i < 8; i++) {
        canvas.save();
        Point point=circleAt(getWidth(),getHeight(),getWidth()/2.5f-radius,i*(Math.PI/4));
        canvas.translate(point.x, point.y);
        canvas.scale(scaleFloats[i], scaleFloats[i]);
        canvas.rotate(i*45);
        paint.setAlpha(alphas[i]);
        RectF rectF=new RectF(-radius,-radius/1.5f,1.5f*radius,radius/1.5f);
        canvas.drawRoundRect(rectF,5,5,paint);
        canvas.restore();
    }
}
 
開發者ID:Mrqinlei,項目名稱:ImitateZHRB,代碼行數:16,代碼來源:LineSpinFadeLoaderIndicator.java

示例6: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected synchronized void onDraw(Canvas canvas) {
    //canvas.rotate(-90);
    //canvas.translate(-getHeight(), 0);

    canvas.rotate(90);
    canvas.translate(0, -getWidth());
    super.onDraw(canvas);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:VerticalSeekbar.java

示例7: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@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);
    c.restoreToCount(saveCount);
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:9,代碼來源:MaterialProgressDrawable.java

示例8: drawNextPageAreaAndShadow

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void drawNextPageAreaAndShadow(Canvas canvas) {
    mPath1.reset();
    mPath1.moveTo(mBezierStart1.x, mBezierStart1.y);
    mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
    mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y);
    mPath1.lineTo(mBezierStart2.x, mBezierStart2.y);
    mPath1.lineTo(mCornerX, mCornerY);
    mPath1.close();

    mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY));
    int leftx;
    int rightx;
    GradientDrawable mBackShadowDrawable;
    if (mIsRTandLB) {  //左下及右上
        leftx = (int) (mBezierStart1.x);
        rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4);
        mBackShadowDrawable = mBackShadowDrawableLR;
    } else {
        leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4);
        rightx = (int) mBezierStart1.x;
        mBackShadowDrawable = mBackShadowDrawableRL;
    }
    canvas.save();
    try {
        canvas.clipPath(mPath0);
        canvas.clipPath(mPath1, Region.Op.INTERSECT);
    } catch (Exception e) {
    }


    canvas.drawBitmap(mNextPageBitmap, 0, 0, null);
    canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
    mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y,
            rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐標值,構成一個矩形
    mBackShadowDrawable.draw(canvas);
    canvas.restore();
}
 
開發者ID:ynztlxdeai,項目名稱:TextReader,代碼行數:39,代碼來源:PageWidget.java

示例9: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas, Paint paint) {
    float circleSpacing=12;
    float x=getWidth()/2;
    float y=getHeight()/2;

    //draw fill circle
    canvas.save();
    canvas.translate(x, y);
    canvas.scale(scaleFloat1, scaleFloat1);
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(0, 0, x / 2.5f, paint);

    canvas.restore();

    canvas.translate(x, y);
    canvas.scale(scaleFloat2, scaleFloat2);
    canvas.rotate(degrees);

    paint.setStrokeWidth(3);
    paint.setStyle(Paint.Style.STROKE);

    //draw two arc
    float[] startAngles=new float[]{225,45};
    for (int i = 0; i < 2; i++) {
        RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing);
        canvas.drawArc(rectF, startAngles[i], 90, false, paint);
    }
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:30,代碼來源:BallClipRotatePulseIndicator.java

示例10: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
void draw(Canvas canvas) {
    canvas.save();
    canvas.rotate(-90, canvas.getWidth() / 2, canvas.getHeight() / 2);
    canvas.drawArc(boundingBox, 0, 360, false, paint);
    canvas.drawLines(marker, markerPaint);
    canvas.restore();
}
 
開發者ID:eltos,項目名稱:SimpleDialogFragments,代碼行數:8,代碼來源:ColorWheelView.java

示例11: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    if (mIsNeedBackground) {
        canvas.drawRoundRect(mRoundRectF, 8, 8, mBackGroundPaint);
    }

    if (isReverse) {
        mProgress -= mDel;
        mStartAngle += mDel;
        if (mStartAngle >= 270) {
            mStartAngle = -90;
            isReverse = false;
        }
        mRotateAngle += mDel;
        if (mRotateAngle >= 360) {
            mRotateAngle = 0;
        }
        canvas.save();
        canvas.rotate(mRotateAngle, mRotateCenter.x, mRotateCenter.y);
        canvas.drawPath(mPath, mTrianglePaint);
        canvas.restore();
    } else {
        mProgress += mDel;
        if (mProgress >= 360) {
            isReverse = true;
        }
        canvas.drawPath(mPath, mTrianglePaint);
    }

    canvas.drawArc(mRectF, mStartAngle, mProgress, false, mPaint);
    mHandler.sendEmptyMessageDelayed(REFRESH_VIEW, 80);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:33,代碼來源:LoadingView.java

示例12: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override public void draw(Canvas canvas) {
  for (int i = 0; i < numberOfCircle; i++) {
    canvas.save();
    canvas.rotate(rotates[i], center.x, center.y);
    circles[i].draw(canvas);
    canvas.restore();
  }
}
 
開發者ID:nntuyen,項目名稱:mkloader,代碼行數:9,代碼來源:FishSpinner.java

示例13: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
public void draw(Canvas c) {
    if (mShadow != null) {
        mShadow.getPaint().setColor(mRing.mBackgroundColor);
        mShadow.draw(c);
    }
    final Rect bounds = getBounds();
    final int saveCount = c.save();
    c.rotate(mRotation, bounds.exactCenterX(), bounds.exactCenterY());
    mRing.draw(c, bounds);
    c.restoreToCount(saveCount);
}
 
開發者ID:dkzwm,項目名稱:SmoothRefreshLayout,代碼行數:13,代碼來源:MaterialProgressDrawable.java

示例14: getMarkTextBitmap

import android.graphics.Canvas; //導入方法依賴的package包/類
public Bitmap getMarkTextBitmap(String gText, int width, int height, float textSize, float inter, int color, int alpha, int degress) {
        textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, textSize, MarkApplication.getInstance().getResources().getDisplayMetrics());
        inter = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, inter, MarkApplication.getInstance().getResources().getDisplayMetrics());

        int sideLength;
        if (width > height) {
            sideLength = (int) Math.sqrt(2 * (width * width));
        } else {
            sideLength = (int) Math.sqrt(2 * (height * height));
        }


        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        Rect rect = new Rect();
        paint.setTextSize(textSize);
        //獲取文字長度和寬度
        paint.getTextBounds(gText, 0, gText.length(), rect);

        int strwid = rect.width();
        int strhei = rect.height();

        Bitmap markBitmap = null;
        try {
            markBitmap = Bitmap.createBitmap(sideLength, sideLength, Bitmap.Config.ARGB_4444);
            Canvas canvas = new Canvas(markBitmap);
            //創建透明畫布
            canvas.drawColor(Color.TRANSPARENT);

            paint.setColor(color);
            paint.setAlpha(alpha);
//            paint.setAlpha((int) (0.1 * 255f));
            // 獲取跟清晰的圖像采樣
            paint.setDither(true);
            paint.setFilterBitmap(true);

            //先平移,再旋轉才不會有空白,使整個圖片充滿
            if (width > height) {
                if (degress < 90) {
                    canvas.translate(width - sideLength - inter, degress * (sideLength - width + inter) / 90);
                } else {
                    canvas.translate((degress - 180) * (width - sideLength - inter) / 180, (degress - 180) * (sideLength - width + inter) / 180);
                }
            } else {
                if (degress < 90) {
                    canvas.translate(height - sideLength - inter, (sideLength - height + inter) * degress / 90);
                } else {
                    canvas.translate(degress * (height - sideLength - inter) / 180, (degress - 180) * (sideLength - height + inter) / 180);
                }
            }

            //將該文字圖片逆時針方向傾斜45度
            if (degress < 90) {
                canvas.rotate(-degress, width / 2, height / 2);
            } else {
                canvas.rotate(180 - degress, width / 2, height / 2);
            }

            for (int i = 0; i <= sideLength; ) {
                int count = 0;
                for (int j = 0; j <= sideLength; count++) {
                    if (count % 2 == 0) {
                        canvas.drawText(gText, i, j, paint);
                    } else {
                        //偶數行進行錯開
                        canvas.drawText(gText, i + strwid / 2, j, paint);
                    }
                    j = (int) (j + inter + strhei);
                }
                i = (int) (i + strwid + inter);
            }
            canvas.save(Canvas.ALL_SAVE_FLAG);
//      ACache.get(gContext).put(gText, markBitmap);
        } catch (OutOfMemoryError e) {
            if (markBitmap != null && !markBitmap.isRecycled()) {
                markBitmap.recycle();
                markBitmap = null;
            }
        }
        return markBitmap;
    }
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:81,代碼來源:ImageUtil.java

示例15: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
protected void onDraw(Canvas canvas) {
	canvas.rotate(rotation, getWidth() / 2, getHeight() / 2);
	super.onDraw(canvas);
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:5,代碼來源:FollowListPage.java


注:本文中的android.graphics.Canvas.rotate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。