当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.clipPath方法代码示例

本文整理汇总了Java中android.graphics.Canvas.clipPath方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.clipPath方法的具体用法?Java Canvas.clipPath怎么用?Java Canvas.clipPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.clipPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawCurrentPageArea

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void drawCurrentPageArea(Canvas canvas) {
    mPath0.reset();
    mPath0.moveTo(mBezierStart1.x, mBezierStart1.y);
    mPath0.quadTo(mBezierControl1.x, mBezierControl1.y, mBezierEnd1.x, mBezierEnd1.y);
    mPath0.lineTo(mTouch.x, mTouch.y);
    mPath0.lineTo(mBezierEnd2.x, mBezierEnd2.y);
    mPath0.quadTo(mBezierControl2.x, mBezierControl2.y, mBezierStart2.x, mBezierStart2.y);
    mPath0.lineTo(mCornerX, mCornerY);
    mPath0.close();

    canvas.save();
    canvas.clipPath(mPath0, Region.Op.XOR);
    canvas.drawBitmap(mCurPageBitmap, 0, 0, null);
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
 
开发者ID:zwmlibs,项目名称:BookReader-master,代码行数:21,代码来源:PageWidget.java

示例2: dispatchDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);

    if (canvas == null) return;

    mPath.reset();

    mPath.addCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 550, Path.Direction.CW);
    mPath.setFillType(Path.FillType.INVERSE_EVEN_ODD);

    canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 550, mTransparentPaint);

    canvas.drawPath(mPath, mSemiBlackPaint);
    canvas.clipPath(mPath);
    canvas.drawColor(Color.parseColor("#A6000000"));
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:18,代码来源:CameraView.java

示例3: drawCurrentBackArea

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) {
    mPath2.reset();
    mPath2.moveTo(mBzVertex1.x, mBzVertex1.y);
    mPath2.lineTo(mBzVertex2.x, mBzVertex2.y);
    mPath2.lineTo(mBzEnd2.x, mBzEnd2.y);
    mPath2.lineTo(mTouch.x, mTouch.y);
    mPath2.lineTo(mBzEnd1.x, mBzEnd1.y);
    mPath2.close();

    Matrix matrix = getSymmetricalMatrix();

    canvas.save();
    canvas.clipPath(mPath1);
    canvas.clipPath(mPath2, Region.Op.INTERSECT);
    canvas.drawBitmap(bitmap, matrix, null);
    canvas.restore();
}
 
开发者ID:1014277960,项目名称:DailyReader,代码行数:18,代码来源:ReadView.java

示例4: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    float x = getPaddingLeft();
    float y = getPaddingTop();
    float w = getWidth() - getPaddingLeft() - getPaddingRight();
    float h = getHeight() - getPaddingTop() - getPaddingBottom();
    int vl = mValues.length;

    canvas.clipPath(mPath);
    for (int i = 0; i < vl; i++) {
        mPaint.setColor(mColors[i]);
        float ew = w * mValues[i] / mValuesTotal;
        canvas.drawRect((float) Math.floor(x), y, (float) Math.ceil(x + ew), y + h, mPaint);
        x += ew;
    }
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:18,代码来源:SimpleBarChart.java

示例5: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
    int w = getWidth();
    int h = getHeight();
    canvas.clipPath(innerRoundPath(w, h), Region.Op.DIFFERENCE);
    super.draw(canvas);

    degree += speed;
    degree %= 360;
    matrix.setRotate(degree, w / 2, h / 2);
    shader.setLocalMatrix(matrix);
    rectF.left = 0;
    rectF.top = 0;
    rectF.right = w;
    rectF.bottom = h;
    canvas.drawRoundRect(rectF, radius, radius, paint);
    invalidate();

}
 
开发者ID:android-notes,项目名称:sao,代码行数:20,代码来源:CoolView.java

示例6: drawCurrentPageArea

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawCurrentPageArea(Canvas canvas, Bitmap bitmap, Path path) {
    mPath0.reset();
    mPath0.moveTo(mBezierStart1.x, mBezierStart1.y);
    mPath0.quadTo(mBezierControl1.x, mBezierControl1.y, mBezierEnd1.x,
            mBezierEnd1.y);
    mPath0.lineTo(mTouchX, mTouchY);
    mPath0.lineTo(mBezierEnd2.x, mBezierEnd2.y);
    mPath0.quadTo(mBezierControl2.x, mBezierControl2.y, mBezierStart2.x,
            mBezierStart2.y);
    mPath0.lineTo(mCornerX, mCornerY);
    mPath0.close();

    canvas.save();
    canvas.clipPath(path, Region.Op.XOR);
    canvas.drawBitmap(bitmap, 0, 0, null);
    try {
        canvas.restore();
    } catch (Exception e) {

    }

}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:23,代码来源:SimulationPageAnim.java

示例7: drawMinutes

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawMinutes(Canvas canvas, Path selectorPath, float alphaMod) {
    final int minutesAlpha = (int) (255f * mHoursToMinutes * alphaMod + 0.5f);
    if (minutesAlpha > 0) {
        // Exclude the selector region, then draw minutes with no
        // activated states.
        canvas.save(Canvas.CLIP_SAVE_FLAG);
        canvas.clipPath(selectorPath, Region.Op.DIFFERENCE);
        drawMinutesClipped(canvas, minutesAlpha, false);
        canvas.restore();

        // Intersect the selector region, then draw minutes with only
        // activated states.
        canvas.save(Canvas.CLIP_SAVE_FLAG);
        canvas.clipPath(selectorPath, Region.Op.INTERSECT);
        drawMinutesClipped(canvas, minutesAlpha, true);
        canvas.restore();
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:19,代码来源:RadialTimePickerView.java

示例8: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
    Rect rect = getBounds();

    int count = canvas.saveLayer(new RectF(rect), null, Canvas.ALL_SAVE_FLAG);
    canvas.translate(rect.left, rect.top);
    mClipPath.reset();
    mClipPath.addCircle(rect.width() / 2, rect.height() / 2,
                        Math.min(rect.width(), rect.height()) / 2, Path.Direction.CCW);
    canvas.clipPath(mClipPath);

    if (mContentBitmap == null && !TextUtils.isEmpty(mContentText)) {
        mTextPaint.setColor(mBgColor);
        canvas.drawRect(rect, mTextPaint);
        int fontSize = this.mFontSize <= 0 ? (Math.min(rect.width(), rect.height()) / 2) : this.mFontSize;
        mTextPaint.setTextSize(fontSize);
        mTextPaint.setColor(mTextColor);
        canvas.drawText(mContentText, rect.width() / 2, rect.height() / 2 - ((mTextPaint.descent() + mTextPaint.ascent()) / 2), mTextPaint);
    } else {
        mMatrix.setScale(rect.width() * 1.0f / mContentBitmap.getWidth(),
                rect.height() * 1.0f / mContentBitmap.getHeight());
        Bitmap scaleContentBitmap = Bitmap.createBitmap(mContentBitmap, 0, 0,
                mContentBitmap.getWidth(), mContentBitmap.getHeight(),
                mMatrix, true);
        canvas.drawBitmap(scaleContentBitmap, rect, rect, null);
    }
    canvas.restoreToCount(count);
}
 
开发者ID:yanbober,项目名称:DreamDrawable,代码行数:29,代码来源:IconDrawable.java

示例9: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (mStatus == SmoothRefreshLayout.SR_STATUS_COMPLETE) {
        mOffsetX = 0;
        mOffsetY = (mTextRect.height() + mAmplitude * 2 + getPaddingTop());
    }
    mMovingPath.set(mWavePath);
    mMovingPath.offset(mOffsetX, mOffsetY);
    canvas.drawPath(mTextPath, mTextPaint);
    canvas.save();
    canvas.clipPath(mTextPath);
    canvas.drawPath(mMovingPath, mWavePaint);
    canvas.restore();
    mOffsetX -= mIncrementalX;
    if (mOffsetX <= -mWaveLength)
        mOffsetX = 0f;
    if (mStatus == SmoothRefreshLayout.SR_STATUS_REFRESHING
            || mStatus == SmoothRefreshLayout.SR_STATUS_LOADING_MORE) {
        mOffsetY -= mIncrementalY;
        if (mOffsetY <= getPaddingTop())
            mOffsetY = (mTextRect.height() + mAmplitude * 2 + getPaddingTop());
        mProgress = 1 - mOffsetY / (mTextRect.height() + mAmplitude * 2);
    }
    if (mStatus == SmoothRefreshLayout.SR_STATUS_COMPLETE)
        return;
    invalidate();
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:28,代码来源:WaveTextRefreshView.java

示例10: dispatchDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
    if (!mEnableClip || mClipPath.isEmpty()) {
        super.dispatchDraw(canvas);
        return;
    }
    canvas.save();
    canvas.clipPath(mClipPath);
    super.dispatchDraw(canvas);
    canvas.restore();
}
 
开发者ID:yangwencan2002,项目名称:CircularRevealCompat,代码行数:12,代码来源:CircularRevealCompatLayout.java

示例11: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
  rect.set(0, 0, this.getWidth(), this.getHeight());
  clipPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
  canvas.clipPath(clipPath);
  super.onDraw(canvas);
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:8,代码来源:RoundedImageView.java

示例12: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    // 需要剪切应显示视图的其余部分
    Path path = new Path();
    path.addRoundRect(
            new RectF(0, 0, canvas.getWidth(), canvas.getHeight()),
            _PST.dpToPx(cornerRadius),
            _PST.dpToPx(cornerRadius),
            Path.Direction.CW
    );
    canvas.clipPath(path, Region.Op.REPLACE);
}
 
开发者ID:LemonAppCN,项目名称:LemonHello4Android,代码行数:14,代码来源:LemonHelloPanel.java

示例13: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (canvas != null) {
        canvas.clipPath(path);
        super.onDraw(canvas);
    }
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:8,代码来源:ShapeImageView.java

示例14: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override protected void onDraw(Canvas canvas) {
    if (clipPath.isEmpty()) {
        super.onDraw(canvas);
        return;
    }

    int saveCount = canvas.save();
    canvas.clipPath(clipPath);
    super.onDraw(canvas);
    if (!borderPath.isEmpty()) {
        canvas.drawPath(borderPath, borderPaint);
    }
    canvas.restoreToCount(saveCount);
}
 
开发者ID:santalu,项目名称:diagonal-imageview,代码行数:15,代码来源:DiagonalImageView.java

示例15: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    //super.onDraw(canvas);
    canvas.save();
    canvas.translate(0,-Ui.cd.getHt(10));

    canvas.save();
    bass.draw(canvas);
    float radius = 10;
    final RectF oval = new RectF();
    oval.set(0, 0, bass.width, bass.height);
    Path ph = new Path();
    ph.setFillType(Path.FillType.WINDING);
    ph.moveTo(bass.width/2, bass.width/2);
    if(angle > 110 - 1){
        ph.addArc(oval,-(200) + 110,angle - 110);
    }else{
        ph.addArc(oval,-(90) - (110 - angle),(110 - angle));
    }
    ph.lineTo(bass.width/2,bass.width/2);

    canvas.clipPath(ph);
    basstop.draw(canvas);
    canvas.restore();

    canvas.save();
    canvas.rotate(-(90+20),XX,YY);
    canvas.rotate(angle,XX,YY);
    bassdot.draw(canvas);
    canvas.restore();

    int val = (angle - 110);
    val = (int) ((100f / 110) * val);
    levelText.setText(val+"",true);
    levelText.draw(canvas);
    canvas.restore();
    super.drawShape(canvas);
    //canvas.drawPath(ph,bass.img.maskPaint);
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:40,代码来源:WheelItem.java


注:本文中的android.graphics.Canvas.clipPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。