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


Java RadialGradient類代碼示例

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


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

示例1: setup

import android.graphics.RadialGradient; //導入依賴的package包/類
public void setup(DisplayMetrics dm, DeviceProfile grid, View invalidateDelegate,
           int availableSpace, int topPadding) {
    mInvalidateDelegate = invalidateDelegate;

    final int previewSize = grid.folderIconSizePx;
    final int previewPadding = grid.folderIconPreviewPadding;

    this.previewSize = (previewSize - 2 * previewPadding);

    basePreviewOffsetX = (availableSpace - this.previewSize) / 2;
    basePreviewOffsetY = previewPadding + grid.folderBackgroundOffset + topPadding;

    // Stroke width is 1dp
    mStrokeWidth = dm.density;

    float radius = getScaledRadius();
    float shadowRadius = radius + mStrokeWidth;
    int shadowColor = Color.argb(SHADOW_OPACITY, 0, 0, 0);
    mShadowShader = new RadialGradient(0, 0, 1,
            new int[] {shadowColor, Color.TRANSPARENT},
            new float[] {radius / shadowRadius, 1},
            Shader.TileMode.CLAMP);

    invalidate();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:26,代碼來源:FolderIcon.java

示例2: drawScanLine

import android.graphics.RadialGradient; //導入依賴的package包/類
private void drawScanLine(Canvas canvas, Rect frame) {
    Shader shader = new RadialGradient(
            (float)(frame.left + frame.width() / 2),
            (float)(scannerStart + SCANNER_LINE_HEIGHT / 2),
            360f,
            laserColor,
            shadeColor(laserColor),
            Shader.TileMode.MIRROR);
    paint.setAlpha(CURRENT_POINT_OPACITY);
    paint.setShader(shader);
    if (scannerStart <= scannerEnd) {
        canvas.drawRect(frame.left, scannerStart, frame.right, scannerStart + SCANNER_LINE_HEIGHT, paint);
        scannerStart += SCANNER_LINE_MOVE_DISTANCE;
    } else {
        scannerStart = frame.top;
    }
    paint.setShader(null);
}
 
開發者ID:kkyflying,項目名稱:CodeScaner,代碼行數:19,代碼來源:ViewfinderView.java

示例3: createColorWheelBitmap

import android.graphics.RadialGradient; //導入依賴的package包/類
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;

    }
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:27,代碼來源:ColorPicker.java

示例4: createColorDiscBitmap

import android.graphics.RadialGradient; //導入依賴的package包/類
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;
}
 
開發者ID:dftec-es,項目名稱:planetcon,代碼行數:20,代碼來源:ColorPicker.java

示例5: startLightAnimation

import android.graphics.RadialGradient; //導入依賴的package包/類
private void startLightAnimation() {

        if (mLightAnimation == null) {

            mLightAnimation = ObjectAnimator.ofFloat(10, getMeasuredWidth());
            mLightAnimation.setRepeatCount(ValueAnimator.INFINITE);
            mLightAnimation.setDuration(3000);
            mLightAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    float lightMove = (float) animation.getAnimatedValue();
                    if (Math.abs(lightMove) < getMeasuredWidth()) {
                        mShader = new RadialGradient(lightMove, getMeasuredHeight() / 2, 90f
                                , new int[]{Color.WHITE, mBackgroudColor}, null, Shader.TileMode.CLAMP);
                        postInvalidate();
                    }

                }
            });
        }

        if (mLightAnimation != null && !mLightAnimation.isRunning()) {
            mLightAnimation.start();
        }

    }
 
開發者ID:arjinmc,項目名稱:AndroidButtonLib,代碼行數:27,代碼來源:SlideButton.java

示例6: addBall

import android.graphics.RadialGradient; //導入依賴的package包/類
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f, 50f);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(Math.random() * 255);
    int green = (int)(Math.random() * 255);
    int blue = (int)(Math.random() * 255);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    balls.add(shapeHolder);
    return shapeHolder;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:21,代碼來源:BouncingBalls.java

示例7: finishGradients

import android.graphics.RadialGradient; //導入依賴的package包/類
private void finishGradients() {
	for(Gradient gradient : gradientMap.values()) {
        if (gradient.xlink != null) {
            Gradient parent = gradientMap.get(gradient.xlink);
            if (parent != null) {
                gradient.inherit(parent);
            }
        }
        int[] colors = new int[gradient.colors.size()];
        for (int i = 0; i < colors.length; i++) {
            colors[i] = gradient.colors.get(i);
        }
        float[] positions = new float[gradient.positions.size()];
        for (int i = 0; i < positions.length; i++) {
            positions[i] = gradient.positions.get(i);
        }
        if (colors.length == 0) {
       		Log.d("BAD", "BAD gradient, id="+gradient.id);
        }
        if (gradient.isLinear) {
        	gradient.shader= new LinearGradient(gradient.x1, gradient.y1, gradient.x2, gradient.y2, colors, positions, gradient.tilemode);
        } else {
        	gradient.shader= new RadialGradient(gradient.x, gradient.y, gradient.radius, colors, positions, gradient.tilemode);
        }
	}
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:27,代碼來源:SVGParser.java

示例8: setRadius

import android.graphics.RadialGradient; //導入依賴的package包/類
@AnimateMethod
public void setRadius(final float radius) {
    rippleRadius = radius;
    if (rippleRadius > 0) {
        RadialGradient radialGradient = new RadialGradient(
                downX,
                downY,
                rippleRadius * 3,
                Color.TRANSPARENT,
                Color.BLACK,
                Shader.TileMode.MIRROR
        );
        ripplePaint.setShader(radialGradient);
    }
    invalidate();
}
 
開發者ID:FallenCrood,項目名稱:Review-,代碼行數:17,代碼來源:RangeSliderViewEx.java

示例9: draw

import android.graphics.RadialGradient; //導入依賴的package包/類
@Override
    public void draw(Canvas canvas) {
        if (keepShow||inMerge) {
        canvas.save();
        canvas.clipRect(getBounds());
        mRectF.set(getBounds());

        mRectF.inset(mOutlinePadding, mOutlinePadding);
        if (mOutLineWidth > 0) {
            mOutlinePaint.setStrokeWidth(mOutLineWidth);
            mRectF.inset(mOutLineWidth, mOutLineWidth);
            mOutlinePaint.setColor(mOutLineColor);
            canvas.drawRoundRect(mRectF, mRadius, mRadius, mOutlinePaint);
        }
//            mPaint.setShader(new SweepGradient(mRectF.centerX(),mRectF.centerY(),mColors,mPositions));
        mPaint.setShader(new RadialGradient(mRectF.centerX(), mRectF.centerY(), mRectF.width(), mCenterColor, mEdgeColor, Shader.TileMode.CLAMP));
        canvas.drawRoundRect(mRectF, mRadius, mRadius, mPaint);
        canvas.restore();
        }
    }
 
開發者ID:AlphaBoom,項目名稱:ClassifyView,代碼行數:21,代碼來源:BagDrawable.java

示例10: drawBeaconBackground

import android.graphics.RadialGradient; //導入依賴的package包/類
protected void drawBeaconBackground(Canvas canvas, Beacon beacon, PointF beaconCenter) {
    float advertisingRadius = (float) canvasProjection.getCanvasUnitsFromMeters(beacon.getEstimatedAdvertisingRange());

    Paint innerBeaconRangePaint = new Paint(beaconRangePaint);
    innerBeaconRangePaint.setAlpha(100);
    Shader rangeShader = new RadialGradient(
            beaconCenter.x,
            beaconCenter.y,
            advertisingRadius - (pixelsPerDip * 0),
            primaryFillPaint.getColor(), beaconRangePaint.getColor(),
            Shader.TileMode.MIRROR);

    innerBeaconRangePaint.setShader(rangeShader);
    //canvas.drawCircle(beaconCenter.x, beaconCenter.y, advertisingRadius, innerBeaconRangePaint);
    canvas.drawCircle(beaconCenter.x, beaconCenter.y, advertisingRadius, beaconRangePaint);
}
 
開發者ID:neXenio,項目名稱:BLE-Indoor-Positioning,代碼行數:17,代碼來源:BeaconMap.java

示例11: buildShadowCorners

import android.graphics.RadialGradient; //導入依賴的package包/類
private void buildShadowCorners() {
    RectF innerBounds = new RectF(-this.mCornerRadius, -this.mCornerRadius, this.mCornerRadius, this.mCornerRadius);
    RectF outerBounds = new RectF(innerBounds);
    outerBounds.inset(-this.mShadowSize, -this.mShadowSize);
    if (this.mCornerShadowPath == null) {
        this.mCornerShadowPath = new Path();
    } else {
        this.mCornerShadowPath.reset();
    }
    this.mCornerShadowPath.setFillType(FillType.EVEN_ODD);
    this.mCornerShadowPath.moveTo(-this.mCornerRadius, 0.0f);
    this.mCornerShadowPath.rLineTo(-this.mShadowSize, 0.0f);
    this.mCornerShadowPath.arcTo(outerBounds, 180.0f, 90.0f, false);
    this.mCornerShadowPath.arcTo(innerBounds, 270.0f, -90.0f, false);
    this.mCornerShadowPath.close();
    float startRatio = this.mCornerRadius / (this.mCornerRadius + this.mShadowSize);
    this.mCornerShadowPaint.setShader(new RadialGradient(0.0f, 0.0f, this.mCornerRadius + this.mShadowSize, new int[]{this.mShadowStartColor, this.mShadowStartColor, this.mShadowEndColor}, new float[]{0.0f, startRatio, 1.0f}, TileMode.CLAMP));
    this.mEdgeShadowPaint.setShader(new LinearGradient(0.0f, (-this.mCornerRadius) + this.mShadowSize, 0.0f, (-this.mCornerRadius) - this.mShadowSize, new int[]{this.mShadowStartColor, this.mShadowStartColor, this.mShadowEndColor}, new float[]{0.0f, 0.5f, 1.0f}, TileMode.CLAMP));
    this.mEdgeShadowPaint.setAntiAlias(false);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:RoundRectDrawableWithShadow.java

示例12: buildShadowCorners

import android.graphics.RadialGradient; //導入依賴的package包/類
private void buildShadowCorners() {
    RectF innerBounds = new RectF(-this.mCornerRadius, -this.mCornerRadius, this.mCornerRadius, this.mCornerRadius);
    RectF outerBounds = new RectF(innerBounds);
    outerBounds.inset(-this.mShadowSize, -this.mShadowSize);
    if (this.mCornerShadowPath == null) {
        this.mCornerShadowPath = new Path();
    } else {
        this.mCornerShadowPath.reset();
    }
    this.mCornerShadowPath.setFillType(FillType.EVEN_ODD);
    this.mCornerShadowPath.moveTo(-this.mCornerRadius, 0.0f);
    this.mCornerShadowPath.rLineTo(-this.mShadowSize, 0.0f);
    this.mCornerShadowPath.arcTo(outerBounds, 180.0f, 90.0f, false);
    this.mCornerShadowPath.arcTo(innerBounds, 270.0f, -90.0f, false);
    this.mCornerShadowPath.close();
    float shadowRadius = -outerBounds.top;
    if (shadowRadius > 0.0f) {
        float startRatio = this.mCornerRadius / shadowRadius;
        float midRatio = startRatio + ((1.0f - startRatio) / 2.0f);
        this.mCornerShadowPaint.setShader(new RadialGradient(0.0f, 0.0f, shadowRadius, new int[]{0, this.mShadowStartColor, this.mShadowMiddleColor, this.mShadowEndColor}, new float[]{0.0f, startRatio, midRatio, 1.0f}, TileMode.CLAMP));
    }
    this.mEdgeShadowPaint.setShader(new LinearGradient(0.0f, innerBounds.top, 0.0f, outerBounds.top, new int[]{this.mShadowStartColor, this.mShadowMiddleColor, this.mShadowEndColor}, new float[]{0.0f, SHADOW_HORIZ_SCALE, 1.0f}, TileMode.CLAMP));
    this.mEdgeShadowPaint.setAntiAlias(false);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:ShadowDrawableWrapper.java

示例13: drawLaserScanner

import android.graphics.RadialGradient; //導入依賴的package包/類
/**
 * 繪製移動掃描線
 * @param canvas
 * @param frame
 */
private void drawLaserScanner(Canvas canvas, Rect frame) {
     linePaint.setColor(laserColor);
     radialGradient = new RadialGradient(
            (float)(frame.left + frame.width() / 2),
            (float)(scannerStart + SCANNER_LINE_HEIGHT / 2),
            360f,
            laserColor,
            shadeColor(laserColor),
            Shader.TileMode.MIRROR);
    linePaint.setShader(radialGradient);
    if(scannerStart < scannerEnd) {
        rectF.set(frame.left + 2 * SCANNER_LINE_HEIGHT,
                scannerStart, frame.right - 2 * SCANNER_LINE_HEIGHT,
                scannerStart + SCANNER_LINE_HEIGHT);
        canvas.drawOval(rectF, linePaint);
        scannerStart += SCANNER_LINE_MOVE_DISTANCE;
    } else {
        scannerStart = frame.top;
    }
    linePaint.setShader(null);
    radialGradient=null;
}
 
開發者ID:RuanXiaoHui,項目名稱:ZxingScan,代碼行數:28,代碼來源:ViewfinderView.java

示例14: createShaderFactory

import android.graphics.RadialGradient; //導入依賴的package包/類
private ShapeDrawable.ShaderFactory createShaderFactory() {
    return new ShapeDrawable.ShaderFactory() {
        @Override
        public Shader resize(int width, int height) {
            switch (type) {
                case RADIAL:
                    return new RadialGradient(parentWidth / 2,
                            parentHeight / 2, getParentRadius(),
                            upper, lower,
                            Shader.TileMode.CLAMP);

                case LINEAR:
                default:
                    return new LinearGradient(0, 0,
                            0, parentHeight,
                            upper, lower,
                            Shader.TileMode.CLAMP);
            }
        }
    };
}
 
開發者ID:alxgrk,項目名稱:BlendedBackground,代碼行數:22,代碼來源:Gradient.java

示例15: createColorWheelBitmap

import android.graphics.RadialGradient; //導入依賴的package包/類
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;

    }
 
開發者ID:mercadopago,項目名稱:px-android,代碼行數:27,代碼來源:ColorPicker.java


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