List of usage examples for android.graphics SweepGradient SweepGradient
public SweepGradient(float cx, float cy, @ColorInt int color0, @ColorInt int color1)
From source file:Main.java
protected static void setSweepGradientGradientPaint(Paint paint, float width, float height, int colorStart, int colorEnd) { paint.setShader(new SweepGradient(width, height, colorStart, colorEnd)); paint.setAntiAlias(true);//from w ww . ja v a 2 s. com }
From source file:com.skumar.flexibleciruclarseekbar.CircularSeekBar.java
/** * Method to drawing the gradient color for the arc *///from w ww .ja v a2 s . com public void setShader() { SweepGradient sweepgradient = new SweepGradient(mArcRadius, mArcRadius, Color.parseColor("#2f8bca"), Color.parseColor("#c91200")); Matrix matrix = new Matrix(); matrix.reset(); sweepgradient.getLocalMatrix(matrix); matrix.postRotate(90, mArcRadius, mArcRadius); sweepgradient.setLocalMatrix(matrix); mArcPaint.setShader(sweepgradient); mNeedleScalePaint.setShader(sweepgradient); }
From source file:org.getlantern.firetweet.view.ShapedImageView.java
private void updateBorderShader() { final int[] colors = mBorderColors; if (colors == null || colors.length == 0) { mBorderAlpha = 0;/* w w w .java2 s .c om*/ return; } mDestination.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); final float cx = mDestination.centerX(), cy = mDestination.centerY(); final int[] sweepColors = new int[colors.length * 2]; final float[] positions = new float[colors.length * 2]; for (int i = 0, j = colors.length; i < j; i++) { sweepColors[i * 2] = sweepColors[i * 2 + 1] = colors[i]; positions[i * 2] = i == 0 ? 0 : i / (float) j; positions[i * 2 + 1] = i == j - 1 ? 1 : (i + 1) / (float) j; } final SweepGradient shader = new SweepGradient(cx, cy, sweepColors, positions); final Matrix matrix = new Matrix(); matrix.setRotate(90, cx, cy); shader.setLocalMatrix(matrix); mBorderPaint.setShader(shader); }
From source file:de.vanita5.twittnuker.view.ShapedImageView.java
private void updateBorderShader() { final int[] colors = mBorderColors; if (colors == null || colors.length == 0) { mBorderPaint.setShader(null);//from ww w .j a v a 2 s .c o m return; } mDestination.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); final float cx = mDestination.centerX(), cy = mDestination.centerY(); final int[] sweepColors = new int[colors.length * 2]; final float[] positions = new float[colors.length * 2]; for (int i = 0, j = colors.length; i < j; i++) { sweepColors[i * 2] = sweepColors[i * 2 + 1] = colors[i]; positions[i * 2] = i == 0 ? 0 : i / (float) j; positions[i * 2 + 1] = i == j - 1 ? 1 : (i + 1) / (float) j; } final SweepGradient shader = new SweepGradient(cx, cy, sweepColors, positions); final Matrix matrix = new Matrix(); matrix.setRotate(90, cx, cy); shader.setLocalMatrix(matrix); mBorderPaint.setShader(shader); }
From source file:com.owen.view.views.PieChart.java
/** * Do all of the recalculations needed when the data array changes. *///from ww w.j a va 2 s. c om private void onDataChanged() { // When the data changes, we have to recalculate // all of the angles. int currentAngle = 0; for (Item it : mData) { it.mStartAngle = currentAngle; it.mEndAngle = (int) ((float) currentAngle + it.mValue * 360.0f / mTotal); currentAngle = it.mEndAngle; // Recalculate the gradient shaders. There are // three values in this gradient, even though only // two are necessary, in order to work around // a bug in certain versions of the graphics engine // that expects at least three values if the // positions array is non-null. // it.mShader = new SweepGradient(mPieBounds.width() / 2.0f, mPieBounds.height() / 2.0f, new int[] { it.mHighlight, it.mHighlight, it.mColor, it.mColor, }, new float[] { 0, (float) (360 - it.mEndAngle) / 360.0f, (float) (360 - it.mStartAngle) / 360.0f, 1.0f }); } calcCurrentItem(); onScrollFinished(); }
From source file:devlight.io.library.ArcProgressStackView.java
@Override protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { // Get measured sizes final int width = MeasureSpec.getSize(widthMeasureSpec); final int height = MeasureSpec.getSize(heightMeasureSpec); // Get size for square dimension if (width > height) mSize = height;//from w w w . ja v a2 s .c o m else mSize = width; // Get progress offsets final float divider = mDrawWidthFraction == 0 ? mDrawWidthDimension : mSize * mDrawWidthFraction; mProgressModelSize = divider / mModels.size(); final float paintOffset = mProgressModelSize * 0.5F; final float shadowOffset = mIsShadowed ? (mShadowRadius + mShadowDistance) : 0.0F; // Set bound with offset for models for (int i = 0; i < mModels.size(); i++) { final Model model = mModels.get(i); final float modelOffset = (mProgressModelSize * i) + (paintOffset + shadowOffset) - (mProgressModelOffset * i); // Set bounds to progress model.mBounds.set(modelOffset, modelOffset, mSize - modelOffset, mSize - modelOffset); // Set sweep gradient shader if (model.getColors() != null) model.mSweepGradient = new SweepGradient(model.mBounds.centerX(), model.mBounds.centerY(), model.getColors(), null); } // Set square measured dimension setMeasuredDimension(mSize, mSize); }