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


Java SweepGradient.setLocalMatrix方法代码示例

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


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

示例1: drawProgress

import android.graphics.SweepGradient; //导入方法依赖的package包/类
/**
 * 绘制进度
 *
 * @param canvas 画布
 */
protected void drawProgress(Canvas canvas) {
    if (mRadius == 0 || mProgressSize == 0 || mAnimatorProgress < 0)
        return;
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(mProgressSize);
    final float halfCircleSize = mProgressSize * 0.5f;
    mRectF.set(-mRadius + halfCircleSize, -mRadius + halfCircleSize,
            mRadius - halfCircleSize, mRadius - halfCircleSize);
    SweepGradient sweepGradient = new SweepGradient(0, 0, mGradientColors, mGradientPositions);
    mRotateMatrix.setRotate(mStartAngle, 0, 0);
    sweepGradient.setLocalMatrix(mRotateMatrix);
    mPaint.setShader(sweepGradient);
    canvas.save();
    canvas.drawArc(mRectF, mStartAngle, mAnimatorProgressAngle, false, mPaint);
    canvas.restore();
}
 
开发者ID:AlexMofer,项目名称:ProjectX,代码行数:24,代码来源:CircleProgressBar.java

示例2: drawLoading

import android.graphics.SweepGradient; //导入方法依赖的package包/类
/**
 * 绘制载入
 *
 * @param canvas 画布
 */
protected void drawLoading(Canvas canvas) {
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(mProgressSize);
    final float halfCircleSize = mProgressSize * 0.5f;
    SweepGradient sweepGradient = new SweepGradient(0, 0, mGradientColors, mGradientPositions);
    mRotateMatrix.setRotate(mStartAngle - mLoadingStartAngle -
            mLoadingSweepAngle * mLoadingOffset, 0, 0);
    sweepGradient.setLocalMatrix(mRotateMatrix);
    mPaint.setShader(sweepGradient);
    canvas.save();
    canvas.rotate(mLoadingStartAngle);
    canvas.rotate(mLoadingSweepAngle * mLoadingOffset);
    canvas.drawPoint(mRadius - halfCircleSize, 0, mPaint);
    canvas.restore();
}
 
开发者ID:AlexMofer,项目名称:ProjectX,代码行数:23,代码来源:CircleProgressBar.java

示例3: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    RectF oval = new RectF(8.0f, 8.0f, (float) (this.mSize - 8), (float) (this.mSize - 8));
    Paint bgPaint = new Paint();
    bgPaint.setAntiAlias(true);
    bgPaint.setStrokeWidth(2.0f);
    bgPaint.setStyle(Style.STROKE);
    bgPaint.setColor(this.CIRCLE_INDICATOR_COLOR);
    canvas.drawArc(oval, 0.0f, 360.0f, false, bgPaint);
    Paint circlePaint = new Paint();
    circlePaint.setAntiAlias(true);
    circlePaint.setStrokeWidth(8.0f);
    circlePaint.setStyle(Style.STROKE);
    circlePaint.setStrokeCap(Cap.ROUND);
    Matrix matrix = new Matrix();
    matrix.preRotate(-90.0f, (float) (this.mSize / 2), (float) (this.mSize / 2));
    SweepGradient gradient = new SweepGradient((float) (this.mSize / 2), (float) (this
            .mSize / 2), this.CIRCLE_STROKE_COLOR, this.CIRCLE_STROKE_COLOR_END);
    gradient.setLocalMatrix(matrix);
    circlePaint.setShader(gradient);
    canvas.drawArc(oval, -90.0f, (float) this.mProgress, false, circlePaint);
    Paint fullPaint = new Paint();
    fullPaint.setAntiAlias(true);
    fullPaint.setStyle(Style.FILL);
    fullPaint.setStrokeCap(Cap.ROUND);
    if (this.mProgress == 360) {
        fullPaint.setColor(this.CIRCLE_STROKE_COLOR_END);
    } else {
        fullPaint.setColor(this.CIRCLE_STROKE_COLOR);
    }
    canvas.drawCircle((float) (this.mSize / 2), 8.0f, aj.hA, fullPaint);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:ProgressIndicator.java

示例4: init

import android.graphics.SweepGradient; //导入方法依赖的package包/类
private void init() {

        setUpMark();

        float padding = mWideRingWidth / 2 + 2;

        mRectF = new RectF(padding, padding, mWidth - padding, mWidth - padding);

        mSweepGradient = new SweepGradient(mWidth / 2, mWidth / 2, mColors, mPositions);
        Matrix matrix = new Matrix();
        matrix.setRotate(120, mWidth / 2, mWidth / 2);
        mSweepGradient.setLocalMatrix(matrix);
        mPaintLevel.setShader(mSweepGradient);
    }
 
开发者ID:xuyunqiang,项目名称:RingView,代码行数:15,代码来源:RingView.java

示例5: updateSweep

import android.graphics.SweepGradient; //导入方法依赖的package包/类
private SweepGradient updateSweep() {
    int startColor = Color.argb(150, Color.red(speedometerColor), Color.green(speedometerColor), Color.blue(speedometerColor));
    int color2 = Color.argb(220, Color.red(speedometerColor), Color.green(speedometerColor), Color.blue(speedometerColor));
    int color3 = Color.argb(70, Color.red(speedometerColor), Color.green(speedometerColor), Color.blue(speedometerColor));
    int endColor = Color.argb(15, Color.red(speedometerColor), Color.green(speedometerColor), Color.blue(speedometerColor));
    float position = getOffsetSpeed() * (getEndDegree() - getStartDegree())/360f;
    SweepGradient sweepGradient = new SweepGradient(getSize() *.5f, getSize() *.5f
            , new int[]{startColor, color2, speedometerColor, color3, endColor, startColor}
            , new float[]{0f, position *.5f, position, position, .99f, 1f});
    Matrix matrix = new Matrix();
    matrix.postRotate(getStartDegree(), getSize() *.5f, getSize() *.5f);
    sweepGradient.setLocalMatrix(matrix);
    return sweepGradient;
}
 
开发者ID:anastr,项目名称:SpeedView,代码行数:15,代码来源:PointerSpeedometer.java

示例6: drawHorizon

import android.graphics.SweepGradient; //导入方法依赖的package包/类
private void drawHorizon() {
    if (mAmbientMode)
        return;

    int horizonSeparatorLength = 40;
    int[] colors = {Color.TRANSPARENT, Color.BLACK};

    // find out at what angle the gradient needs to start
    float startAngle = (mCurrentAngle - horizonSeparatorLength);

    // if we the start is negative, it means we'll have to "go around"
    if (startAngle < 0) startAngle += 360;

    // the gradient starts at the beginning of the sweep, but has to end at the defined horizon separator length
    float[] positions = {0, horizonSeparatorLength / 360f};
    SweepGradient horizonGradient = new SweepGradient(mWatchFaceCenter.x, mWatchFaceCenter.y, colors, positions);

    // the sweep gradient doesn't like drawing starting from a value before the 0 point (3 o clock) to after,
    // that's why we need a "local" matrix for the gradient, which we can first rotate to always have our start be 0
    Matrix gradientMatrix = new Matrix();

    // we'll rotate one degree back, because for some reason there is a weird striped border at the start,
    // which we do not want to see.
    float rotateAngle = startAngle - 1;
    if (rotateAngle < 0) rotateAngle += 360;

    // do the actual rotate and assign the matrix to the gradient
    gradientMatrix.preRotate(rotateAngle, mWatchFaceCenter.x, mWatchFaceCenter.y);
    horizonGradient.setLocalMatrix(gradientMatrix);

    // assign the gradient shader to the horizon
    mHorizonPaint.setShader(horizonGradient);

    // draw the horizon arc
    mCanvas.drawArc(new RectF(mWatchFaceBounds)
            , startAngle
            , horizonSeparatorLength
            , true
            , mHorizonPaint);
}
 
开发者ID:yannickgr,项目名称:PieWatchFace,代码行数:41,代码来源:PieWatchFace.java

示例7: ensureValidRect

import android.graphics.SweepGradient; //导入方法依赖的package包/类
/**
 * This checks mRectIsDirty, and if it is true, recomputes both our drawing
 * rectangle (mRect) and the gradient itself, since it depends on our
 * rectangle too.
 * @return true if the resulting rectangle is not empty, false otherwise
 */
private boolean ensureValidRect() {
    if (mRectIsDirty) {
        mRectIsDirty = false;

        Rect bounds = getBounds();
        float inset = 0;

        final CircularProgressBarState st = mCircularProgressBarState;

        mRect.set(bounds.left + inset, bounds.top + inset,
                bounds.right - inset, bounds.bottom - inset);

        final int[] colors = st.mColors;
        if (colors != null) {
            RectF r = mRect;
            float x0, y0;

            x0 = r.left + (r.right - r.left) * st.mCenterX;
            y0 = r.top + (r.bottom - r.top) * st.mCenterY;

            final SweepGradient sweepGradient = new SweepGradient(x0, y0, colors, null);
            Matrix flipMatrix = new Matrix();
            flipMatrix.setScale(1, -1);
            flipMatrix.postTranslate(0, (r.bottom - r.top));
            flipMatrix.postRotate(-startingAngle, x0, y0);
            sweepGradient.setLocalMatrix(flipMatrix);
            mFillPaint.setShader(sweepGradient);

            // If we don't have a solid color, the alpha channel must be
            // maxed out so that alpha modulation works correctly.
            if (!st.mHasSolidColor) {
                mFillPaint.setColor(Color.BLACK);
            }
        }
    }
    return !mRect.isEmpty();
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:44,代码来源:CircularProgressBarDrawable.java

示例8: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    final int store = canvas.save();
    //参数修正
    int w = getMeasuredWidth();
    int h = getMeasuredHeight();




    //圆心
    int x = w/2;
    int y = h/2;
    //半径
    int radius = (Math.min(w,h)-2*padding)/2-internalStrokeWidth/2;//半径
    //线冒的范围,默认在roate 为0的位置,之后通过旋转摆正
    recthead = new RectF(x+radius-internalStrokeWidth/2,y-internalStrokeWidth/2,
            x+radius+internalStrokeWidth/2,y+internalStrokeWidth/2);

    calculatePercentEndColor(pre);
    sweepGradient = new SweepGradient(x,y,colors,dur);
    //旋转sweepGradient的角度
    Matrix gradientMatrix = new Matrix();
    gradientMatrix.preRotate(roate, x, y);
    sweepGradient.setLocalMatrix(gradientMatrix);

    outpaint.setShader(sweepGradient);


    //绘制背景
    canvas.drawCircle(x,y,radius+internalStrokeWidth/2+padding,bgpaint);

    //绘制外部单元格
    canvas.drawCircle(x,y,radius,outpaint);

    //如果是非dash样式,线冒会被染色为终点颜色.例如红色,这里需要一个半圆盖着
    if(!dash){
        //为保证旋转不画布其他元素生效
        if(pre>0&&pre<1) {
            canvas.save();
            // 绘制开头的半圆,线冒
            canvas.rotate(roate, x, y);
            canvas.drawArc(recthead, 180, 180, true, startPaint);
            canvas.restore();
        }
        // 绘制结束的半圆,线冒
        if (pre>0&&pre <= 1) {
            //为保证旋转不画布其他元素生效
            canvas.save();
            endPaint.setColor(percentEndColor);
            //-1个角度,因为计算后有一定的精度损失
            canvas.rotate(roate+360*pre-1, x, y);
            canvas.drawArc(recthead, 0f, 180f, true, endPaint);
            canvas.restore();
        }


    }

    canvas.restoreToCount(store);

}
 
开发者ID:jiongjiongxia,项目名称:DashProgress,代码行数:64,代码来源:DashProgressCircle.java

示例9: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    // drawing color wheel

    canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY
            - colorWheelRadius, null);

    // drawing color view

    colorViewPaint.setColor(Color.HSVToColor(colorHSV));
    canvas.drawPath(colorViewPath, colorViewPaint);

    // drawing value slider

    float[] hsv = new float[]{colorHSV[0], colorHSV[1], 1f};

    SweepGradient sweepGradient = new SweepGradient(centerX, centerY,
            new int[]{Color.BLACK, Color.HSVToColor(hsv), Color.WHITE},
            null);
    sweepGradient.setLocalMatrix(gradientRotationMatrix);
    valueSliderPaint.setShader(sweepGradient);

    canvas.drawPath(valueSliderPath, valueSliderPaint);

    // drawing color wheel pointer

    float hueAngle = (float) Math.toRadians(colorHSV[0]);
    int colorPointX = (int) (-Math.cos(hueAngle) * colorHSV[1] * colorWheelRadius)
            + centerX;
    int colorPointY = (int) (-Math.sin(hueAngle) * colorHSV[1] * colorWheelRadius)
            + centerY;

    float pointerRadius = 0.075f * colorWheelRadius;
    int pointerX = (int) (colorPointX - pointerRadius / 2);
    int pointerY = (int) (colorPointY - pointerRadius / 2);

    colorPointerCoords.set(pointerX, pointerY, pointerX + pointerRadius,
            pointerY + pointerRadius);
    canvas.drawOval(colorPointerCoords, colorPointerPaint);

    // drawing value pointer

    valuePointerPaint.setColor(Color.HSVToColor(new float[]{0f, 0f,
            1f - colorHSV[2]}));

    double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
    float valueAngleX = (float) Math.cos(valueAngle);
    float valueAngleY = (float) Math.sin(valueAngle);

    canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY
                    * innerWheelRadius + centerY, valueAngleX * outerWheelRadius
                    + centerX, valueAngleY * outerWheelRadius + centerY,
            valuePointerPaint);

    // drawing pointer arrow

    if (arrowPointerSize > 0) {
        drawPointerArrow(canvas);
    }

}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:67,代码来源:ColorPicker.java

示例10: drawPie

import android.graphics.SweepGradient; //导入方法依赖的package包/类
protected void drawPie(Canvas canvas, RectF rectf, float f1, float f2, float f3, float f4, float f5)
{
    canvas.drawCircle(f1, f2, f3 - o.getStrokeWidth() / 2.0F - n, o);
    canvas.drawCircle(f1, f2, f3 - i.getStrokeWidth() / 2.0F - 2.0F * n, i);
    float f6 = f4 * f5;
    if (f6 > 1.0F)
    {
        f6 = 1.0F;
    }
    if (c)
    {
        int ai[] = {
            0xffffff, -1, 0xffffff
        };
        if (f6 == 0.0F)
        {
            f6 = 0.5F;
        }
        k = new SweepGradient(f1, f2, ai, new float[] {
            0.0F, f6, 1.0F
        });
        j.setRotate(-90F + mRotate, f1, f2);
        k.setLocalMatrix(j);
        h.setShader(k);
    } else
    {
        h.setShader(null);
        h.setColor(-1);
    }
    if (f6 < 1.0F)
    {
        canvas.drawArc(m, -90F + mRotate + l, f6 * (360F - 2.0F * l), false, h);
    } else
    {
        canvas.drawCircle(f1, f2, f3 - i.getStrokeWidth() / 2.0F - 2.0F * n, h);
    }
    switch (d)
    {
    case 0: // '\0'
    default:
        return;

    case 1: // '\001'
        ChartUtil.erase(canvas, p);
        ChartUtil.drawBitmapCenter(canvas, p.centerX(), p.centerY(), mDensityScale, e, null);
        return;

    case 2: // '\002'
        ChartUtil.erase(canvas, p);
        ChartUtil.drawBitmapCenter(canvas, p.centerX(), p.centerY(), mDensityScale, f, null);
        return;

    case 3: // '\003'
        ChartUtil.erase(canvas, p);
        break;
    }
    ChartUtil.drawBitmapCenter(canvas, p.centerX(), p.centerY(), mDensityScale, g, null);
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:59,代码来源:DynamicPieChartOld.java

示例11: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    // drawing color wheel

    canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

    // drawing color view

    colorViewPaint.setColor(Color.HSVToColor(colorHSV));
    canvas.drawPath(colorViewPath, colorViewPaint);

    // drawing value slider

    float[] hsv = new float[] { colorHSV[0], colorHSV[1], 1f };

    SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[] { Color.BLACK, Color.HSVToColor(hsv), Color.WHITE }, null);
    sweepGradient.setLocalMatrix(gradientRotationMatrix);
    valueSliderPaint.setShader(sweepGradient);

    canvas.drawPath(valueSliderPath, valueSliderPaint);

    // drawing color wheel pointer

    float hueAngle = (float) Math.toRadians(colorHSV[0]);
    int colorPointX = (int) (-Math.cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
    int colorPointY = (int) (-Math.sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;

    float pointerRadius = 0.075f * colorWheelRadius;
    int pointerX = (int) (colorPointX - pointerRadius / 2);
    int pointerY = (int) (colorPointY - pointerRadius / 2);

    colorPointerCoords.set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
    canvas.drawOval(colorPointerCoords, colorPointerPaint);

    // drawing value pointer

    valuePointerPaint.setColor(Color.HSVToColor(new float[] { 0f, 0f, 1f - colorHSV[2] }));

    double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
    float valueAngleX = (float) Math.cos(valueAngle);
    float valueAngleY = (float) Math.sin(valueAngle);

    canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
            valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

    // drawing pointer arrow

    if (arrowPointerSize > 0) {
        drawPointerArrow(canvas);
    }

}
 
开发者ID:MLNO,项目名称:airgram,代码行数:58,代码来源:ColorPicker.java

示例12: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    // drawing color wheel

    canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

    // drawing color view

    int[] segmentColors = getColors();
    float sweepAngleStep = 180f / paramColorCount;
    for (int i = 0; i < paramColorCount; i++) {

        colorViewPath.reset();
        colorViewPath.arcTo(outerWheelRect, 270 - i * sweepAngleStep, -sweepAngleStep);
        colorViewPath.arcTo(innerWheelRect, 90 + (paramColorCount - i - 1) * sweepAngleStep, sweepAngleStep);

        colorViewPaint.setColor(segmentColors[i]);

        canvas.drawPath(colorViewPath, colorViewPaint);

    }

    // drawing value slider

    float[] hsv = new float[] { colorHSV[0], colorHSV[1], 1f };

    SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[] { Color.BLACK, Color.HSVToColor(hsv), Color.WHITE }, null);
    sweepGradient.setLocalMatrix(gradientRotationMatrix);
    valueSliderPaint.setShader(sweepGradient);

    canvas.drawPath(valueSliderPath, valueSliderPaint);

    // drawing color wheel pointer

    for (int i = 0; i < paramColorCount; i++) {
        drawColorWheelPointer(canvas, (float) Math.toRadians(adjacentHue[i]));
    }

    // drawing value pointer

    valuePointerPaint.setColor(Color.HSVToColor(new float[] { 0f, 0f, 1f - colorHSV[2] }));

    double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
    float valueAngleX = (float) Math.cos(valueAngle);
    float valueAngleY = (float) Math.sin(valueAngle);

    canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
            valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

    // drawing pointer arrow

    if (arrowPointerSize > 0) {
        drawPointerArrow(canvas);
    }

}
 
开发者ID:MLNO,项目名称:airgram,代码行数:62,代码来源:MultiColorPicker.java

示例13: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    // drawing color wheel

    canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

    // drawing color view

    colorViewPaint.setColor(Color.HSVToColor(colorHSV));
    canvas.drawPath(colorViewPath, colorViewPaint);

    // drawing value slider

    float[] hsv = new float[]{colorHSV[0], colorHSV[1], 1f};

    SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[]{Color.BLACK, Color.HSVToColor(hsv), Color.WHITE}, null);
    sweepGradient.setLocalMatrix(gradientRotationMatrix);
    valueSliderPaint.setShader(sweepGradient);

    canvas.drawPath(valueSliderPath, valueSliderPaint);

    // drawing color wheel pointer

    float hueAngle = (float) Math.toRadians(colorHSV[0]);
    int colorPointX = (int) (-Math.cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
    int colorPointY = (int) (-Math.sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;

    float pointerRadius = 0.075f * colorWheelRadius;
    int pointerX = (int) (colorPointX - pointerRadius / 2);
    int pointerY = (int) (colorPointY - pointerRadius / 2);

    colorPointerCoords.set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
    canvas.drawOval(colorPointerCoords, colorPointerPaint);

    // drawing value pointer

    valuePointerPaint.setColor(Color.HSVToColor(new float[]{0f, 0f, 1f - colorHSV[2]}));

    double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
    float valueAngleX = (float) Math.cos(valueAngle);
    float valueAngleY = (float) Math.sin(valueAngle);

    canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
            valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

    // drawing pointer arrow

    if (arrowPointerSize > 0) {
        drawPointerArrow(canvas);
    }

}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:58,代码来源:ColorPicker.java

示例14: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@SuppressLint("DrawAllocation")
    @Override
    protected void onDraw(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        // drawing color wheel

        canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

        // drawing color view

//        colorViewPaint.setColor(Color.HSVToColor(colorHSV));
//        canvas.drawPath(colorViewPath, colorViewPaint);

        // drawing value slider

        float[] hsv = new float[]{colorHSV[0], colorHSV[1], 1f};

        SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[]{Color.BLACK, Color.HSVToColor(hsv), Color.WHITE}, null);
        sweepGradient.setLocalMatrix(gradientRotationMatrix);
        valueSliderPaint.setShader(sweepGradient);

        canvas.drawPath(valueSliderPath, valueSliderPaint);

        // drawing color wheel pointer

        float hueAngle = (float) Math.toRadians(colorHSV[0]);
        int colorPointX = (int) (-Math.cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
        int colorPointY = (int) (-Math.sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;

        float pointerRadius = 0.075f * colorWheelRadius;
        int pointerX = (int) (colorPointX - pointerRadius / 2);
        int pointerY = (int) (colorPointY - pointerRadius / 2);

        colorPointerCoords.set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
        canvas.drawOval(colorPointerCoords, colorPointerPaint);

        // drawing value pointer

        valuePointerPaint.setColor(Color.HSVToColor(new float[]{0f, 0f, 1f - colorHSV[2]}));

        double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
        float valueAngleX = (float) Math.cos(valueAngle);
        float valueAngleY = (float) Math.sin(valueAngle);

        canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
                valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

        // drawing pointer arrow

        if (arrowPointerSize > 0) {
            drawPointerArrow(canvas);
        }

    }
 
开发者ID:SwiftyWang,项目名称:FingerColoring-Android,代码行数:58,代码来源:ColorPicker.java

示例15: onDraw

import android.graphics.SweepGradient; //导入方法依赖的package包/类
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {

    int centerX = getWidth() / 2;
    int centerY = getHeight() / 2;

    // drawing color wheel

    canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

    // drawing color view

    colorViewPaint.setColor(Color.HSVToColor(colorHSV));
    canvas.drawPath(colorViewPath, colorViewPaint);

    // drawing value slider

    float[] hsv = new float[] { colorHSV[0], colorHSV[1], 1f };

    SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[] { Color.BLACK, Color.HSVToColor(hsv), Color.WHITE }, null);
    sweepGradient.setLocalMatrix(gradientRotationMatrix);
    valueSliderPaint.setShader(sweepGradient);

    canvas.drawPath(valueSliderPath, valueSliderPaint);

    // drawing color wheel pointer

    float hueAngle = (float) Math.toRadians(colorHSV[0]);
    int colorPointX = (int) (-Math.cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
    int colorPointY = (int) (-Math.sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;

    float pointerRadius = 0.075f * colorWheelRadius;
    int pointerX = (int) (colorPointX - pointerRadius / 2);
    int pointerY = (int) (colorPointY - pointerRadius / 2);

    colorPointerCoords.set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
    canvas.drawOval(colorPointerCoords, colorPointerPaint);

    // drawing value pointer

    valuePointerPaint.setColor(Color.HSVToColor(new float[]{0f, 0f, 1f - colorHSV[2]}));

    double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
    float valueAngleX = (float) Math.cos(valueAngle);
    float valueAngleY = (float) Math.sin(valueAngle);

    canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
            valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

    // drawing pointer arrow

    if (arrowPointerSize > 0) {
        drawPointerArrow(canvas);
    }

}
 
开发者ID:tmay,项目名称:BluetoothBacon,代码行数:58,代码来源:ColorPicker.java


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