本文整理汇总了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);
}
示例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);
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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);
}
示例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();
}
}
示例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);
}
示例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;
}
示例15: onDraw
import android.graphics.Canvas; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
canvas.rotate(rotation, getWidth() / 2, getHeight() / 2);
super.onDraw(canvas);
}