當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。