Java 类android.graphics.SweepGradient 实例源码

项目:airgram    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:airgram    文件:MultiColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:labtablet    文件:ColorPickerDialog.java   
ColorPickerView(Context c, OnColorChangedListener l, int color) {
    super(c);
    mListener = l;
    mColors = new int[]{
            0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
            0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(32);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setColor(color);
    mCenterPaint.setStrokeWidth(5);
}
项目:planetcon    文件:ColorPicker.java   
private Bitmap createColorDiscBitmap(int radius) {
    int centerColor, edgeColor;
    Bitmap bitmap = Bitmap.createBitmap(2 * radius, 2 * radius, Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    mHSV[0] = 0; mHSV[1] = 1; mHSV[2] = 1;   //red
    SweepGradient sweepGradient = new SweepGradient(radius, radius, getColors(mHSV), null);
    mColorPaint.setShader(sweepGradient);
    canvas.drawCircle(radius, radius, radius, mColorPaint);

    mHSV[0] = 0; mHSV[1] = 0; mHSV[2] = 1;   //white
    centerColor = Color.HSVToColor(255, mHSV);
    edgeColor = Color.HSVToColor(0, mHSV);
    RadialGradient radialGradient = new RadialGradient(radius, radius, radius, centerColor, edgeColor, TileMode.CLAMP);
    mColorPaint.setShader(radialGradient);
    canvas.drawCircle(radius, radius, radius, mColorPaint);

    return bitmap;
}
项目:AndroidDigIn    文件:SweepGradientRadarView.java   
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mCx = w / 2;
    mCy = h / 2;
    mSweepGradient = new SweepGradient(mCx, mCy,
            new int[]{Color.argb(25, 0, 255, 0),
                    Color.argb(80, 0, 255, 0),
                    Color.argb(200, 0, 255, 0)},
            new float[]{0, 0.95f, 1.0f});
    mPaint = new Paint();
    mPaint.setShader(mSweepGradient);
    mDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCircleDividerColor = Color.BLACK;
    mCrossDividerColor = Color.WHITE;
    mRadarBgColor = Color.rgb(154, 154, 154);
    mDividerPaint.setColor(mCircleDividerColor);
    mDividerPaint.setStrokeWidth(3);
    mDividerPaint.setStyle(Paint.Style.STROKE);
}
项目:buildAPKsApps    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:buildAPKsApps    文件:MultiColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:FamilyBond    文件:CountDownProgress.java   
private void drawCircle(Canvas canvas) {

        canvas.save();
        canvas.translate(getPaddingLeft(), getPaddingTop());
        canvas.drawCircle(defaultCircleRadius, defaultCircleRadius, defaultCircleRadius, defaultCriclePaint);
        mCenterPoint.x = defaultCircleRadius;
        mCenterPoint.y = defaultCircleRadius;
        canvas.rotate(270, mCenterPoint.x, mCenterPoint.y);
        mSweepGradient = new SweepGradient(mCenterPoint.x, mCenterPoint.y, mGradientColors, null);
        progressPaint.setShader(mSweepGradient);
        canvas.drawArc(new RectF(0, 0, defaultCircleRadius * 2, defaultCircleRadius * 2), 1, 360 * currentAngle, false, progressPaint);

        float currentDegreeFlag = 360 * currentAngle + extraDistance + 90;
        float smallCircleX = 0, smallCircleY = 0;
        float hudu = (float) Math.abs(Math.PI * currentDegreeFlag / 180);//Math.abs:绝对值 ,Math.PI:表示π , 弧度 = 度*π / 180
        smallCircleX = (float) Math.abs(Math.sin(hudu) * defaultCircleRadius + defaultCircleRadius);
        smallCircleY = (float) Math.abs(defaultCircleRadius - Math.cos(hudu) * defaultCircleRadius);
        canvas.drawCircle(smallCircleX, smallCircleY, smallCircleRadius, smallCirclePaint);
        canvas.drawCircle(smallCircleX, smallCircleY, smallCircleRadius - smallCircleStrokeWidth, smallCircleSolidePaint);//画小圆的实心
        canvas.restore();

    }
项目:androidShader_rippleView_radarView    文件:RadarView.java   
public RadarView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    init(context,attrs);


    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(mRadarBackGroundColor);
    mBgPaint.setStyle(Paint.Style.FILL);

    mRadarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mRadarPaint.setColor(mRadarCircleColor);
    mRadarPaint.setStyle(Paint.Style.STROKE);
    mRadarPaint.setStrokeWidth(2);

    mRadarGradient = new SweepGradient(0,0,mRadarStartColor,mRadarEndColor);

    mMatrix = new Matrix();
}
项目:controllerformote-android    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:px-android    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f, 1f, 1f};
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:TanTanPaneView    文件:TanTanpaneView.java   
private void init() {
    mPaint = new Paint();
    mPaint.setStrokeWidth(3);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setAntiAlias(true);
    mPaint.setColor(0xFFD72E1F);


    mGradientPaint = new Paint();
    mGradientPaint.setStrokeWidth(3);
    mGradientPaint.setAntiAlias(true);
    mGradientPaint.setColor(0xFFBC131F);
    SweepGradient shader = new SweepGradient(mWidth / 2, mHeight / 2, Color.TRANSPARENT, 0xFFD72E1F);
    mGradientPaint.setShader(shader);
    rotateMatrix = new Matrix();
}
项目:BLE_Toolbox_Android    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:XO    文件:ColorPickerDialog.java   
ColorPickerView(Context c, OnColorChangedListener l, int color) {
    super(c);
    mListener = l;
    mColors = new int[]{
            0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
            0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(32);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setColor(color);
    mCenterPaint.setStrokeWidth(5);
}
项目:WireGoggles    文件:ColorCircle.java   
/**
 * Initializes variables.
 */
void init() {

       mColors = new int[] {
           0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
           0xFFFFFF00, 0xFFFF0000
       };
       Shader s = new SweepGradient(0, 0, mColors, null);

       mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
       mPaint.setShader(s);
       mPaint.setStyle(Paint.Style.STROKE);

       mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
       mCenterPaint.setStrokeWidth(5);
}
项目:FingerColoring-Android    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f, 1f, 1f};
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:RadarAnimationView    文件:RadarAnimationView.java   
private void configurePaintParams() {
  int delta = (numberOfRings * outerRingsSpacingPx + innerRingRadiousPx * 2) / 2;
  radarShadowBoundsRectF =
      new RectF(viewWidth / 2 - delta, viewHeight / 2 - delta, viewWidth / 2 + delta,
          viewHeight / 2 + delta);

  innerLoadingViewBoundsRecF =
      new RectF(viewWidth / 2 - innerRingRadiousPx, viewHeight / 2 - innerRingRadiousPx,
          viewWidth / 2 + innerRingRadiousPx, viewHeight / 2 + innerRingRadiousPx);

  int colors[] = {
      Color.parseColor("#b5615e"), Color.parseColor("#b5a15c"), Color.parseColor("#93bb5c"),
      Color.parseColor("#b5615e")
  };
  float[] positions = { 0f, .25f, .50f, .95f };
  innerLoadingGradientPaint.setShader(
      new SweepGradient(viewWidth / 2, viewHeight / 2, colors, positions));

  shadowPaint.setShadowLayer(10.0f, 0.0f, 2.0f, Color.BLACK);

  int colors2[] = { Color.TRANSPARENT, Color.GRAY };
  float[] positions2 = { 0f, .90f, };
  radarFillSectionPaint.setShader(
      new SweepGradient(viewWidth / 2, viewHeight / 2, colors2, positions2));
}
项目:Triango    文件:ColorPickerDialog.java   
ColorPickerView(Context c, OnColorChangedListener l, int color, int pickerViewRadius, int pickerCentreRadius) {
    super(c);
    CENTER_X = pickerViewRadius * 2;
    CENTER_Y = pickerViewRadius * 2;
    CENTER_RADIUS = pickerCentreRadius;
    mListener = l;
    mColors = new int[]{
            0xFFFF0000, 0xFFFF00FF, 0xFFFFFFFF, 0xFF000000, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
            0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setAlpha(0x99);
    mPaint.setStrokeWidth((float) 0.6 * pickerViewRadius);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setColor(color);
    //mPaint.setAlpha(0x99);
    mCenterPaint.setStrokeWidth((float) 0.10 * pickerCentreRadius);
}
项目:UofT-Timetable    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:Mu-Retargeter-1.0    文件:ColorPickerDialog.java   
ColorPickerView(Context c, OnColorChangedListener l, int color, int pickerViewRadius, int pickerCentreRadius) {
    super(c);
    CENTER_X = pickerViewRadius * 2;
    CENTER_Y = pickerViewRadius * 2;
    CENTER_RADIUS = pickerCentreRadius;
    mListener = l;
    mColors = new int[]{
            0xFFFF0000, 0xFFFF00FF, 0xFFFFFFFF, 0xFF000000, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
            0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setAlpha(0x99);
    mPaint.setStrokeWidth((float) 0.6 * pickerViewRadius);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setColor(color);
    //mPaint.setAlpha(0x99);
    mCenterPaint.setStrokeWidth((float) 0.10 * pickerCentreRadius);
}
项目:Mu-Retargeter-1.0    文件:ColorPickerDialog.java   
ColorPickerView(Context c, OnColorChangedListener l, int color, int pickerViewRadius, int pickerCentreRadius) {
    super(c);
    CENTER_X = pickerViewRadius * 2;
    CENTER_Y = pickerViewRadius * 2;
    CENTER_RADIUS = pickerCentreRadius;
    mListener = l;
    mColors = new int[]{
            0xFFFF0000, 0xFFFF00FF, 0xFFFFFFFF, 0xFF000000, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
            0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setAlpha(0x99);
    mPaint.setStrokeWidth((float) 0.6 * pickerViewRadius);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setColor(color);
    //mPaint.setAlpha(0x99);
    mCenterPaint.setStrokeWidth((float) 0.10 * pickerCentreRadius);
}
项目:AyoSunny    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:faims-android    文件:ColorPickerDialog.java   
ColorPickerView(Context c, int color) {
    super(c);
    mColors = new int[] {
        0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
        0xFFFFFFFF, 0xFF000000, 0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(32);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setColor(color);
    mCenterPaint.setStrokeWidth(5);
    alpha = Color.alpha(color);

}
项目:Domo-Android    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:Domo-Android    文件:MultiColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:nightdream    文件:CustomAnalogClock.java   
private void drawBackgroundArc(Canvas canvas, float centerX, float centerY, int radius, double angle) {
    if (decoration != Decoration.MINUTE_HAND) return;
    canvas.save();
    paint.setAlpha(70);
    paint.setColorFilter(customColorFilter);
    final int[] colors = {Color.TRANSPARENT, Color.WHITE};
    final float[] positions = {0.5f, 1.f};
    Shader gradient = new SweepGradient(centerX, centerY, colors, positions);
    float rotate = (float) radiansToDegrees(angle);
    Matrix gradientMatrix = new Matrix();
    gradientMatrix.preRotate(rotate, centerX, centerY);
    gradient.setLocalMatrix(gradientMatrix);

    paint.setShader(gradient);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    canvas.drawCircle(centerX, centerY, handLengthMinutes * radius, paint);
    paint.setShader(null);
    canvas.restore();
}
项目:soulissapp    文件:ColorPickerView.java   
/**
 * @param context
 * @param listener
 * @param color
 */
ColorPickerView(Context context, T16RGBAdvancedFragment.OnColorChangedListener listener, int color, RelativeLayout canv, SoulissTypical16AdvancedRGB typ) {
    super(context);
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setShader(new SweepGradient(0, 0, colors, null));
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(STROKE_WIDTH);

    centerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    centerPaint.setColor(color);
    centerPaint.setStrokeWidth(5);

    dialogColorChangedListener = listener;
    colorSwitchRelativeLayout = canv;
    collected = typ;
}
项目:fakedawn    文件:TimeSlider.java   
public void onCursorsMoved(IntervalSlider i, float leftMovement,
        float rightMovement) {

    setLeftText(getLeftTime().toString());
    setRightText(getRightTime().toString());

    int colors[] = new int[] {0xFF000000, 0xFF000000, m_color, m_color};
    Shader s = new SweepGradient(0, 0, colors, null);
    s = new LinearGradient(
            getLeftPos()*getWidth()-0.1F, 0,
            getRightPos()*getWidth()+0.1F, 0, 
            0xFF000000, m_color,
            Shader.TileMode.CLAMP);
    m_paint.setShader(s);
    setRectPaint(m_paint);

    if((leftMovement != 0.0F || rightMovement != 0.0F) && 
            (m_timesChangedListener != null))
    {
        m_timesChangedListener.onTimesChanged((TimeSlider) i);
    }
}
项目:Mi-Band    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f, 1f, 1f};
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:Android-Paint    文件:ColorPickerDialog.java   
ColorPickerView(Context context, OnColorChangedListener l, int color){
    super(context);
    onColorChangedListener = l;
    colors = new int[]{
        0xFFFF0000,
        0xFFFF00FF,
        0xFF0000FF,
        0xFF00FFFF,
        0xFF00FF00,
        0xFFFFFF00,
        0xFFFF0000
    };
    Shader shader = new SweepGradient(0, 0, colors, null);

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setShader(shader);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(32);

    centerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    centerPaint.setColor(color);
    centerPaint.setStrokeWidth(5);
}
项目:circular-slider-android    文件:CircularSlider.java   
@Override
protected void onSizeChanged(int w, int h, int oldW, int oldH) {
    // use smaller dimension for calculations (depends on parent size)
    int smallerDim = w > h ? h : w;

    // find circle's rectangle points
    int largestCenteredSquareLeft = (w - smallerDim) / 2;
    int largestCenteredSquareTop = (h - smallerDim) / 2;
    int largestCenteredSquareRight = largestCenteredSquareLeft + smallerDim;
    int largestCenteredSquareBottom = largestCenteredSquareTop + smallerDim;

    // save circle coordinates and radius in fields
    mCircleCenterX = largestCenteredSquareRight / 2 + (w - largestCenteredSquareRight) / 2;
    mCircleCenterY = largestCenteredSquareBottom / 2 + (h - largestCenteredSquareBottom) / 2;
    mCircleRadius = smallerDim / 2 - mBorderThickness / 2 - mPadding;

    if (mBorderGradientColors != null) {
        mGradientShader = new SweepGradient(mCircleRadius, mCircleRadius, mBorderGradientColors, null);
    }

    // works well for now, should we call something else here?
    super.onSizeChanged(w, h, oldW, oldH);
}
项目:redalert-android    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f, 1f, 1f};
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:EspLight-APP    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:ProjectX    文件:CircleProgressBar.java   
/**
 * 绘制进度
 *
 * @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();
}
项目:ProjectX    文件:CircleProgressBar.java   
/**
 * 绘制载入
 *
 * @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();
}
项目:DMXControl-for-Android    文件:ColorCircle.java   
/**
 * Initializes variables.
 */
void init() {

    mColors = new int[]{
            0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
            0xFFFFFF00, 0xFFFF0000
    };
    Shader s = new SweepGradient(0, 0, mColors, null);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setShader(s);
    mPaint.setStyle(Paint.Style.STROKE);

    mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterPaint.setStrokeWidth(5);
}
项目:MWord    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:MWord    文件:MultiColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:BluetoothBacon    文件:ColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
项目:BluetoothBacon    文件:MultiColorPicker.java   
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }