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


Java GradientDrawable.draw方法代码示例

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


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

示例1: drawCurrentPageShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
protected void drawCurrentPageShadow(Canvas canvas) {
    canvas.save();
    GradientDrawable shadow;
    if (actiondownX > mScreenWidth >> 1) {
        shadow = mBackShadowDrawableLR;
        shadow.setBounds((int) (mScreenWidth + touch_down - 5), 0, (int) (mScreenWidth + touch_down + 5), mScreenHeight);

    } else {
        shadow = mBackShadowDrawableRL;
        shadow.setBounds((int) (touch_down - 5), 0, (int) (touch_down + 5), mScreenHeight);
    }
    shadow.draw(canvas);
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:OverlappedWidget.java

示例2: addPulseRing

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void addPulseRing(LatLng latLng) {
    GradientDrawable d = new GradientDrawable();
    d.setShape(GradientDrawable.OVAL);
    d.setSize(500, 500);
    d.setColor(ContextCompat.getColor(this, R.color.pulse_color));

    Bitmap bitmap = Bitmap.createBitmap(d.getIntrinsicWidth()
            , d.getIntrinsicHeight()
            , Bitmap.Config.ARGB_8888);

    // Convert the drawable to bitmap
    Canvas canvas = new Canvas(bitmap);
    d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    d.draw(canvas);

    // Radius of the circle
    final int radius = 100;

    // Add the circle to the map
    circle = mMap.addGroundOverlay(new GroundOverlayOptions()
            .position(latLng, 2 * radius).image(BitmapDescriptorFactory.fromBitmap(bitmap)));
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:23,代码来源:Home.java

示例3: drawPathAHorizontalShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的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

示例4: drawNextPageAreaAndShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的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:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:PageWidget.java

示例5: drawNextPageAreaAndShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) {
    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(bitmap, 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:z-chu,项目名称:FriendBook,代码行数:39,代码来源:SimulationPageAnim.java

示例6: drawPathALeftShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 绘制A区域左阴影
 * @param canvas
 */
private void drawPathALeftShadow(Canvas canvas, Path pathA){
    canvas.restore();
    canvas.save();

    int left;
    int right;
    int top = (int) e.y;
    int bottom = (int) (e.y+viewHeight);

    GradientDrawable gradientDrawable;
    if (style.equals(STYLE_TOP_RIGHT)) {
        gradientDrawable = drawableLeftTopRight;
        left = (int) (e.x - lPathAShadowDis /2);
        right = (int) (e.x);
    } else {
        gradientDrawable = drawableLeftLowerRight;
        left = (int) (e.x);
        right = (int) (e.x + lPathAShadowDis /2);
    }

    Path mPath = new Path();
    mPath.moveTo(a.x- Math.max(rPathAShadowDis, lPathAShadowDis) /2,a.y);
    mPath.lineTo(d.x,d.y);
    mPath.lineTo(e.x,e.y);
    mPath.lineTo(a.x,a.y);
    mPath.close();
    canvas.clipPath(pathA);
    canvas.clipPath(mPath, Region.Op.INTERSECT);

    float mDegrees = (float) Math.toDegrees(Math.atan2(e.x-a.x, a.y-e.y));
    canvas.rotate(mDegrees, e.x, e.y);

    gradientDrawable.setBounds(left,top,right,bottom);
    gradientDrawable.draw(canvas);
}
 
开发者ID:AnliaLee,项目名称:BookPage,代码行数:40,代码来源:BookPageView.java

示例7: drawPathARightShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
     * 绘制A区域右阴影
     * @param canvas
     */
    private void drawPathARightShadow(Canvas canvas, Path pathA){
        canvas.restore();
        canvas.save();

        float viewDiagonalLength = (float) Math.hypot(viewWidth, viewHeight);//view对角线长度
        int left = (int) h.x;
        int right = (int) (h.x + viewDiagonalLength*10);//需要足够长的长度
        int top;
        int bottom;

        GradientDrawable gradientDrawable;
        if (style.equals(STYLE_TOP_RIGHT)) {
            gradientDrawable = drawableRightTopRight;
            top = (int) (h.y- rPathAShadowDis /2);
            bottom = (int) h.y;
        } else {
            gradientDrawable = drawableRightLowerRight;
            top = (int) h.y;
            bottom = (int) (h.y+ rPathAShadowDis /2);
        }
        gradientDrawable.setBounds(left,top,right,bottom);

        Path mPath = new Path();
        mPath.moveTo(a.x- Math.max(rPathAShadowDis, lPathAShadowDis) /2,a.y);
//        mPath.lineTo(i.x,i.y);
        mPath.lineTo(h.x,h.y);
        mPath.lineTo(a.x,a.y);
        mPath.close();
        canvas.clipPath(pathA);
        canvas.clipPath(mPath, Region.Op.INTERSECT);

        float mDegrees = (float) Math.toDegrees(Math.atan2(a.y-h.y, a.x-h.x));
        canvas.rotate(mDegrees, h.x, h.y);
        gradientDrawable.draw(canvas);
    }
 
开发者ID:AnliaLee,项目名称:BookPage,代码行数:40,代码来源:BookPageView.java

示例8: drawPathCShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 绘制C区域阴影,阴影左浅右深
 * @param canvas
 */
private void drawPathCShadow(Canvas canvas){
    int deepOffset = 1;//深色端的偏移值
    int lightOffset = -30;//浅色端的偏移值
    float viewDiagonalLength = (float) Math.hypot(viewWidth, viewHeight);//view对角线长度
    int midpoint_ce = (int) (c.x + e.x) / 2;//ce中点
    int midpoint_jh = (int) (j.y + h.y) / 2;//jh中点
    float minDisToControlPoint = Math.min(Math.abs(midpoint_ce - e.x), Math.abs(midpoint_jh - h.y));//中点到控制点的最小值

    int left;
    int right;
    int top = (int) c.y;
    int bottom = (int) (viewDiagonalLength + c.y);
    GradientDrawable gradientDrawable;
    if (style.equals(STYLE_TOP_RIGHT)) {
        gradientDrawable = drawableCTopRight;
        left = (int) (c.x - lightOffset);
        right = (int) (c.x + minDisToControlPoint + deepOffset);
    } else {
        gradientDrawable = drawableCLowerRight;
        left = (int) (c.x - minDisToControlPoint - deepOffset);
        right = (int) (c.x + lightOffset);
    }
    gradientDrawable.setBounds(left,top,right,bottom);

    float mDegrees = (float) Math.toDegrees(Math.atan2(e.x- f.x, h.y - f.y));
    canvas.rotate(mDegrees, c.x, c.y);
    gradientDrawable.draw(canvas);
}
 
开发者ID:AnliaLee,项目名称:BookPage,代码行数:33,代码来源:BookPageView.java

示例9: drawNextPageAreaAndShadow

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) {
    mPath2.reset();
    mPath2.moveTo(mBzStart1.x, mBzStart1.y);
    mPath2.lineTo(mBzVertex1.x, mBzVertex1.y);
    mPath2.lineTo(mBzVertex2.x, mBzVertex2.y);
    mPath2.lineTo(mBzStart2.x, mBzStart2.y);
    mPath2.lineTo(mCornerX, mCornerY);
    mPath2.close();

    mDegress = (float) Math.toDegrees(Math.atan2(mBzControl1.x
            - mCornerX, mBzControl2.y - mCornerY));
    int leftx;
    int rightx;
    GradientDrawable mBackShadowDrawable;
    if (mIsRtOrLb) {
        leftx = (int) (mBzStart1.x);
        rightx = (int) (mBzStart1.x + mTouchCornerDis / 4);
        mBackShadowDrawable = mBackDrawableLR;
    } else {
        leftx = (int) (mBzStart1.x - mTouchCornerDis / 4);
        rightx = (int) mBzStart1.x;
        mBackShadowDrawable = mBackDrawableRL;
    }
    canvas.save();
    canvas.clipPath(mPath1);
    canvas.clipPath(mPath2, Region.Op.INTERSECT);
    canvas.drawBitmap(bitmap, 0, 0, null);
    canvas.rotate(mDegress, mBzStart1.x, mBzStart1.y);
    // rotate就是旋转坐标,顺时针,默认原点旋转,可以指定旋转点,然后按照专选后的的坐标绘制,不会对之前的绘制有影响
    // 其实可以这样看,我们先按原来坐标绘制出来东西,在把这个东西按照点来旋转角度,效果是一样的,我们的阴影绘制在(start.x - touchCornerDic / 4, mHeight, start.x, maxLen)矩形中
    // 最后按照start点来旋转就可以变成原来当前页和下一页的交汇线下面的阴影 touchCornerDic / 4就是阴影的宽度
    mBackShadowDrawable.setBounds(leftx, (int) mBzStart1.y, rightx,
            (int) (mMaxLength + mBzStart1.y));
    mBackShadowDrawable.draw(canvas);
    canvas.restore();
}
 
开发者ID:1014277960,项目名称:DailyReader,代码行数:37,代码来源:ReadView.java

示例10: drawCurrentBackArea

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
protected void drawCurrentBackArea(Canvas canvas) {
    int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2;
    float f1 = Math.abs(i - mBezierControl1.x);
    int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2;
    float f2 = Math.abs(i1 - mBezierControl2.y);
    float f3 = Math.min(f1, f2);
    mPath1.reset();
    mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y);
    mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
    mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y);
    mPath1.lineTo(mTouch.x, mTouch.y);
    mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y);
    mPath1.close();
    GradientDrawable mFolderShadowDrawable;
    int left;
    int right;
    if (mIsRTandLB) {
        left = (int) (mBezierStart1.x - 1);
        right = (int) (mBezierStart1.x + f3 + 1);
        mFolderShadowDrawable = mFolderShadowDrawableLR;
    } else {
        left = (int) (mBezierStart1.x - f3 - 1);
        right = (int) (mBezierStart1.x + 1);
        mFolderShadowDrawable = mFolderShadowDrawableRL;
    }
    canvas.save();
    try {
        canvas.clipPath(mPath0);
        canvas.clipPath(mPath1, Region.Op.INTERSECT);
    } catch (Exception e) {
    }

    mPaint.setColorFilter(mColorMatrixFilter);

    float dis = (float) Math.hypot(mCornerX - mBezierControl1.x,
            mBezierControl2.y - mCornerY);
    float f8 = (mCornerX - mBezierControl1.x) / dis;
    float f9 = (mBezierControl2.y - mCornerY) / dis;
    mMatrixArray[0] = 1 - 2 * f9 * f9;
    mMatrixArray[1] = 2 * f8 * f9;
    mMatrixArray[3] = mMatrixArray[1];
    mMatrixArray[4] = 1 - 2 * f8 * f8;
    mMatrix.reset();
    mMatrix.setValues(mMatrixArray);
    mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y);
    mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y);
    canvas.drawBitmap(mCurPageBitmap, mMatrix, mPaint);
    // canvas.drawBitmap(bitmap, mMatrix, null);
    mPaint.setColorFilter(null);
    canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
    mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right,
            (int) (mBezierStart1.y + mMaxLength));
    mFolderShadowDrawable.draw(canvas);
    canvas.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:57,代码来源:PageWidget.java

示例11: drawCurrentBackArea

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 绘制翻起页背面
 *
 * @param canvas
 * @param bitmap
 */
private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) {
    int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2;
    float f1 = Math.abs(i - mBezierControl1.x);
    int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2;
    float f2 = Math.abs(i1 - mBezierControl2.y);
    float f3 = Math.min(f1, f2);
    mPath1.reset();
    mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y);
    mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
    mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y);
    mPath1.lineTo(mTouchX, mTouchY);
    mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y);
    mPath1.close();
    GradientDrawable mFolderShadowDrawable;
    int left;
    int right;
    if (mIsRTandLB) {
        left = (int) (mBezierStart1.x - 1);
        right = (int) (mBezierStart1.x + f3 + 1);
        mFolderShadowDrawable = mFolderShadowDrawableLR;
    } else {
        left = (int) (mBezierStart1.x - f3 - 1);
        right = (int) (mBezierStart1.x + 1);
        mFolderShadowDrawable = mFolderShadowDrawableRL;
    }
    canvas.save();
    try {
        canvas.clipPath(mPath0);
        canvas.clipPath(mPath1, Region.Op.INTERSECT);
    } catch (Exception e) {
    }


    mPaint.setColorFilter(mColorMatrixFilter);

    float dis = (float) Math.hypot(mCornerX - mBezierControl1.x,
            mBezierControl2.y - mCornerY);
    float f8 = (mCornerX - mBezierControl1.x) / dis;
    float f9 = (mBezierControl2.y - mCornerY) / dis;
    mMatrixArray[0] = 1 - 2 * f9 * f9;
    mMatrixArray[1] = 2 * f8 * f9;
    mMatrixArray[3] = mMatrixArray[1];
    mMatrixArray[4] = 1 - 2 * f8 * f8;
    mMatrix.reset();
    mMatrix.setValues(mMatrixArray);
    mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y);
    mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y);
    canvas.drawBitmap(bitmap, mMatrix, mPaint);
    // canvas.drawBitmap(bitmap, mMatrix, null);
    mPaint.setColorFilter(null);

    canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
    mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right,
            (int) (mBezierStart1.y + mMaxLength));
    mFolderShadowDrawable.draw(canvas);
    canvas.restore();
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:64,代码来源:SimulationPageAnim.java

示例12: drawCurrentBackArea

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 绘制翻起页背面
 *
 * @param canvas
 * @param bitmap
 */
private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) {
    int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2;
    float f1 = Math.abs(i - mBezierControl1.x);
    int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2;
    float f2 = Math.abs(i1 - mBezierControl2.y);
    float f3 = Math.min(f1, f2);
    mPath1.reset();
    mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y);
    mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
    mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y);
    mPath1.lineTo(mTouch.x, mTouch.y);
    mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y);
    mPath1.close();
    GradientDrawable mFolderShadowDrawable;
    int left;
    int right;
    if (mIsRTandLB) {
        left = (int) (mBezierStart1.x - 1);
        right = (int) (mBezierStart1.x + f3 + 1);
        mFolderShadowDrawable = mFolderShadowDrawableLR;
    } else {
        left = (int) (mBezierStart1.x - f3 - 1);
        right = (int) (mBezierStart1.x + 1);
        mFolderShadowDrawable = mFolderShadowDrawableRL;
    }
    canvas.save();
    try {
        canvas.clipPath(mPath0);
        canvas.clipPath(mPath1, Region.Op.INTERSECT);
    } catch (Exception e) {
    }


    mPaint.setColorFilter(mColorMatrixFilter);

    float dis = (float) Math.hypot(mCornerX - mBezierControl1.x,
            mBezierControl2.y - mCornerY);
    float f8 = (mCornerX - mBezierControl1.x) / dis;
    float f9 = (mBezierControl2.y - mCornerY) / dis;
    mMatrixArray[0] = 1 - 2 * f9 * f9;
    mMatrixArray[1] = 2 * f8 * f9;
    mMatrixArray[3] = mMatrixArray[1];
    mMatrixArray[4] = 1 - 2 * f8 * f8;
    mMatrix.reset();
    mMatrix.setValues(mMatrixArray);
    mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y);
    mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y);
    canvas.drawBitmap(bitmap, mMatrix, mPaint);
    // canvas.drawBitmap(bitmap, mMatrix, null);
    mPaint.setColorFilter(null);

    canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
    mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right,
            (int) (mBezierStart1.y + mMaxLength));
    mFolderShadowDrawable.draw(canvas);
    canvas.restore();
}
 
开发者ID:guoxiaoxing,项目名称:android-open-source-project-analysis,代码行数:64,代码来源:PageView.java

示例13: drawCurrentBackArea

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 绘制翻起页背面
 *
 * @param canvas
 * @param bitmap
 */
private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) {
    int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2;
    float f1 = Math.abs(i - mBezierControl1.x);
    int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2;
    float f2 = Math.abs(i1 - mBezierControl2.y);
    float f3 = Math.min(f1, f2);
    mPath1.reset();
    mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y);
    mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
    mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y);
    mPath1.lineTo(mTouchX, mTouchY);
    mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y);
    mPath1.close();
    GradientDrawable mFolderShadowDrawable;
    int left;
    int right;
    if (mIsRTandLB) {
        left = (int) (mBezierStart1.x - 1);
        right = (int) (mBezierStart1.x + f3 + 1);
        mFolderShadowDrawable = mFolderShadowDrawableLR;
    } else {
        left = (int) (mBezierStart1.x - f3 - 1);
        right = (int) (mBezierStart1.x + 1);
        mFolderShadowDrawable = mFolderShadowDrawableRL;
    }
    canvas.save();
    try {
        canvas.clipPath(mPath0);
        canvas.clipPath(mPath1, Region.Op.INTERSECT);
    } catch (Exception e) {
    }

    mPaint.setColorFilter(mColorMatrixFilter);
    //对Bitmap进行取色
    int color = bitmap.getPixel(1, 1);
    //获取对应的三色
    int red = (color & 0xff0000) >> 16;
    int green = (color & 0x00ff00) >> 8;
    int blue = (color & 0x0000ff);
    //转换成含有透明度的颜色
    int tempColor = Color.argb(200, red, green, blue);


    float dis = (float) Math.hypot(mCornerX - mBezierControl1.x,
            mBezierControl2.y - mCornerY);
    float f8 = (mCornerX - mBezierControl1.x) / dis;
    float f9 = (mBezierControl2.y - mCornerY) / dis;
    mMatrixArray[0] = 1 - 2 * f9 * f9;
    mMatrixArray[1] = 2 * f8 * f9;
    mMatrixArray[3] = mMatrixArray[1];
    mMatrixArray[4] = 1 - 2 * f8 * f8;
    mMatrix.reset();
    mMatrix.setValues(mMatrixArray);
    mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y);
    mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y);
    canvas.drawBitmap(bitmap, mMatrix, mPaint);
    //背景叠加
    canvas.drawColor(tempColor);

    mPaint.setColorFilter(null);

    canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
    mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right,
            (int) (mBezierStart1.y + mMaxLength));
    mFolderShadowDrawable.draw(canvas);
    canvas.restore();
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:74,代码来源:SimulationPageAnim.java


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