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


Java Region類代碼示例

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


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

示例1: drawCurrentPageArea

import android.graphics.Region; //導入依賴的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(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(path, Region.Op.XOR);
    canvas.drawBitmap(bitmap, 0, 0, null);
    try {
        canvas.restore();
    } catch (Exception e) {

    }

}
 
開發者ID:guoxiaoxing,項目名稱:android-open-source-project-analysis,代碼行數:23,代碼來源:PageView.java

示例2: drawCurrentPageArea

import android.graphics.Region; //導入依賴的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:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:PageWidget.java

示例3: draw

import android.graphics.Region; //導入依賴的package包/類
public void draw(Canvas canvas, Paint paint, float opacity) {
  opacity *= mOpacity;
  if (opacity > MIN_OPACITY_FOR_DRAW) {
    saveAndSetupCanvas(canvas);

    if (mClipping != null) {
      canvas.clipRect(
        mClipping.left * mScale,
        mClipping.top * mScale,
        mClipping.right * mScale,
        mClipping.bottom * mScale,
        Region.Op.REPLACE);
    }

    for (int i = 0; i < getChildCount(); i++) {
      ARTVirtualNode child = (ARTVirtualNode) getChildAt(i);
      child.draw(canvas, paint, opacity);
      child.markUpdateSeen();
    }

    restoreCanvas(canvas);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:24,代碼來源:ARTGroupShadowNode.java

示例4: drawNextPageAreaAndShadow

import android.graphics.Region; //導入依賴的package包/類
@Override
protected void drawNextPageAreaAndShadow(Canvas canvas) {
    canvas.save();
    if (actiondownX > mScreenWidth >> 1) {
        canvas.clipPath(mPath0);
        canvas.drawBitmap(mNextPageBitmap, 0, 0, null);
    } else {
        canvas.clipPath(mPath0, Region.Op.XOR);
        canvas.drawBitmap(mNextPageBitmap, 0, 0, null);
    }
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:OverlappedWidget.java

示例5: CardItemView

import android.graphics.Region; //導入依賴的package包/類
public CardItemView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Card, defStyleAttr, 0);
    mSize = ta.getDimensionPixelSize(R.styleable.Card_size, 10);
    mPaint.setColor(ta.getColor(R.styleable.Card_bgColor, 0));
    ta.recycle();

    mRegion = new Region();
    mDrawPath = new Path();

    mDrawPath.moveTo(0, mSize / 2);
    mDrawPath.lineTo(mSize / 2, 0);
    mDrawPath.lineTo(mSize, mSize / 2);
    mDrawPath.lineTo(mSize / 2, mSize);
    mDrawPath.close();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:CardItemView.java

示例6: dispatchDraw

import android.graphics.Region; //導入依賴的package包/類
@Override
protected void dispatchDraw(Canvas canvas) {
    // Draw the background below children.
    if (mBackgroundAlpha > 0.0f) {
        // Update the scroll position first to ensure scrim cutout is in the right place.
        mLauncher.getWorkspace().computeScrollWithoutInvalidation();

        int alpha = (int) (mBackgroundAlpha * 255);
        CellLayout currCellLayout = mLauncher.getWorkspace().getCurrentDragOverlappingLayout();
        canvas.save();
        if (currCellLayout != null && currCellLayout != mLauncher.getHotseat().getLayout()) {
            // Cut a hole in the darkening scrim on the page that should be highlighted, if any.
            getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect);
            canvas.clipRect(mHighlightRect, Region.Op.DIFFERENCE);
        }
        canvas.drawColor((alpha << 24) | SCRIM_COLOR);
        canvas.restore();
    }

    mFocusIndicatorHelper.draw(canvas);
    super.dispatchDraw(canvas);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:23,代碼來源:DragLayer.java

示例7: drawCurrentPageArea

import android.graphics.Region; //導入依賴的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

示例8: drawProgressRectWithClip

import android.graphics.Region; //導入依賴的package包/類
private void drawProgressRectWithClip(Canvas canvas) {
    mPaint.setColor(mProgressBarColor);
    mPaint.setStyle(Paint.Style.FILL);
    //根據進度比率計算出當前的進度值對應的寬度
    int progress = (int) (mValidWidth * (getProgress() * 1.0f / getMax()));
    canvas.save();
    canvas.translate(getPaddingLeft(), getPaddingTop());
    //裁剪圓角矩形路徑
    drawRoundRectPath();
    canvas.clipPath(mRoundRectPath);//裁剪之後此時畫布就變成了裁剪之後的圓角矩形
    //裁剪進度路徑
    drawProgressPath(progress);
    canvas.clipPath(mProgressPath, Region.Op.INTERSECT);
    canvas.drawColor(mProgressBarColor);
    canvas.restore();
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:17,代碼來源:DownloadProgressButton.java

示例9: initData

import android.graphics.Region; //導入依賴的package包/類
private void initData() {
    //關閉硬件加速,為了可以設置陰影
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    mOuterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mOuterPaint.setStyle(Paint.Style.STROKE);
    mOuterPaint.setStrokeWidth(mOuterWidth);
    mOuterPaint.setColor(mOuterColor);


    mInnerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mInnerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mInnerPaint.setColor(mInnerColor);


    mRegion = new Region();
    mViewPath = new Path();
}
 
開發者ID:Vander-liu,項目名稱:HexagonRecyclerView,代碼行數:19,代碼來源:PolygonItemView.java

示例10: drawPathAHorizontalShadow

import android.graphics.Region; //導入依賴的package包/類
/**
 * 繪製A區域水平翻頁陰影
 * @param canvas
 */
private void drawPathAHorizontalShadow(Canvas canvas, Path pathA){
    canvas.restore();
    canvas.save();
    canvas.clipPath(pathA, Region.Op.INTERSECT);

    int maxShadowWidth = 30;//陰影矩形最大的寬度
    int left = (int) (a.x - Math.min(maxShadowWidth,(rPathAShadowDis/2)));
    int right = (int) (a.x);
    int top = 0;
    int bottom = viewHeight;
    GradientDrawable gradientDrawable = drawableHorizontalLowerRight;
    gradientDrawable.setBounds(left,top,right,bottom);

    float mDegrees = (float) Math.toDegrees(Math.atan2(f.x-a.x,f.y-h.y));
    canvas.rotate(mDegrees, a.x, a.y);
    gradientDrawable.draw(canvas);
}
 
開發者ID:AnliaLee,項目名稱:BookPage,代碼行數:22,代碼來源:BookPageView.java

示例11: drawPathCContent

import android.graphics.Region; //導入依賴的package包/類
/**
     * 繪製C區域內容
     * @param canvas
     * @param pathA
     */
    private void drawPathCContent(Canvas canvas, Path pathA){
        canvas.save();
        canvas.clipPath(pathA);
        canvas.clipPath(getPathC(), Region.Op.REVERSE_DIFFERENCE);//裁剪出C區域不同於A區域的部分
//        canvas.drawPath(getPathC(),pathCPaint);

        float eh = (float) Math.hypot(f.x - e.x,h.y - f.y);
        float sin0 = (f.x - e.x) / eh;
        float cos0 = (h.y - f.y) / eh;
        //設置翻轉和旋轉矩陣
        mMatrixArray[0] = -(1-2 * sin0 * sin0);
        mMatrixArray[1] = 2 * sin0 * cos0;
        mMatrixArray[3] = 2 * sin0 * cos0;
        mMatrixArray[4] = 1 - 2 * sin0 * sin0;

        mMatrix.reset();
        mMatrix.setValues(mMatrixArray);//翻轉和旋轉
        mMatrix.preTranslate(-e.x, -e.y);//沿當前XY軸負方向位移得到 矩形A₃B₃C₃D₃
        mMatrix.postTranslate(e.x, e.y);//沿原XY軸方向位移得到 矩形A4 B4 C4 D4
        canvas.drawBitmap(pathCContentBitmap, mMatrix, null);

        drawPathCShadow(canvas);
        canvas.restore();
    }
 
開發者ID:AnliaLee,項目名稱:BookPage,代碼行數:30,代碼來源:BookPageView.java

示例12: dispatchDraw

import android.graphics.Region; //導入依賴的package包/類
@Override
protected void dispatchDraw(Canvas canvas) {

    width = getWidth();
    height = getHeight();
    mClipPath.reset();
    if (position == ElasticDrawer.Position.LEFT) {
        drawLeftMenu();
    } else {
        drawRightMenu();
    }
    canvas.save();
    canvas.drawPath(mClipPath, mPaint);
    canvas.clipPath(mClipPath, Region.Op.REPLACE);
    super.dispatchDraw(canvas);
    canvas.restore();
}
 
開發者ID:Break369,項目名稱:MyLife,代碼行數:18,代碼來源:FlowingMenuLayout.java

示例13: draw

import android.graphics.Region; //導入依賴的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

示例14: drawMinutes

import android.graphics.Region; //導入依賴的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

示例15: onSizeChanged

import android.graphics.Region; //導入依賴的package包/類
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mLayer = new RectF(0, 0, w, h);
    RectF areas = new RectF();
    areas.left = getPaddingLeft();
    areas.top = getPaddingTop();
    areas.right = w - getPaddingRight();
    areas.bottom = h - getPaddingBottom();
    mClipPath.reset();
    if (mRoundAsCircle) {
        float d = areas.width() >= areas.height() ? areas.height() : areas.width();
        float r = d / 2;
        PointF center = new PointF(w / 2, h / 2);
        mClipPath.addCircle(center.x, center.y, r, Path.Direction.CW);
        mClipPath.moveTo(-mEdgeFix, -mEdgeFix);  // 通過空操作讓Path區域占滿畫布
        mClipPath.moveTo(w + mEdgeFix, h + mEdgeFix);
    } else {
        mClipPath.addRoundRect(areas, radii, Path.Direction.CW);
    }
    Region clip = new Region((int) areas.left, (int) areas.top,
                             (int) areas.right, (int) areas.bottom);
    mAreaRegion.setPath(mClipPath, clip);
}
 
開發者ID:GcsSloop,項目名稱:rclayout,代碼行數:24,代碼來源:RCRelativeLayout.java


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