java类android.graphics.RadialGradient的实例源码

RangeSliderViewEx.java 文件源码 项目:AndroidReview 阅读 21 收藏 0 点赞 0 评论 0
@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();
}
ColorPicker.java 文件源码 项目:EspLight-APP 阅读 25 收藏 0 点赞 0 评论 0
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;

    }
MultiColorPicker.java 文件源码 项目:Domo-Android 阅读 25 收藏 0 点赞 0 评论 0
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;

    }
OldIconDrawable.java 文件源码 项目:minimalist-flashlight 阅读 24 收藏 0 点赞 0 评论 0
public void updateSize(int size) {
  mSize = size > 0 ? size : 100;
  createPath(size);

  mRadius = mSize * (0.8f / 2f);
  mShadowRadius = mSize * (0.95f / 2);

  float startRatio = mRadius / mShadowRadius;
  float midRatio = startRatio + ((1f - startRatio) / 2f);

  mShadow = new RadialGradient(mSize / 2, mSize / 2, mShadowRadius,
      new int[]{0, 0x44000000, 0x14000000, 0},
      new float[]{0f, startRatio, midRatio, 1f},
      Shader.TileMode.CLAMP);
  mLightShadow = new RadialGradient(mSize / 2, mSize / 2, mShadowRadius,
      new int[]{0, 0x6433b5e5, 0x1433b5e5, 0},
      new float[]{0f, startRatio, midRatio, 1f},
      Shader.TileMode.CLAMP);
}
SVGParser.java 文件源码 项目:FMTech 阅读 22 收藏 0 点赞 0 评论 0
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);
        }
    }
}
AndroidGraphics.java 文件源码 项目:CodenameOne 阅读 24 收藏 0 点赞 0 评论 0
public void fillRectRadialGradient(int startColor, int endColor, int x, int y, int width, int height, float relativeX, float relativeY, float relativeSize) {
    boolean antialias = paint.isAntiAlias();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(false);
    paint.setAlpha(255);
    float radius = Math.min((float)width, (float)height) * relativeSize;
    int centerX = (int) (width * (1 - relativeX));
    int centerY = (int) (height * (1 - relativeY));

    paint.setShader(new RadialGradient(x + centerX, y + centerY, radius, 0xff000000 | startColor, 0xff000000 | endColor, Shader.TileMode.MIRROR));
    canvas.save();
    applyTransform();
    canvas.drawRect(x, y, x + width, y + height, paint);
    paint.setAntiAlias(antialias);
    paint.setShader(null);
    unapplyTransform();
    canvas.restore();
}
AnimationCloning.java 文件源码 项目:ApiDemos 阅读 19 收藏 0 点赞 0 评论 0
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f * mDensity, 50f * mDensity);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(100 + Math.random() * 155);
    int green = (int)(100 + Math.random() * 155);
    int blue = (int)(100 + Math.random() * 155);
    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;
}
RadialGradientFillBitmapTextureAtlasSourceDecorator.java 文件源码 项目:AndroidCourses 阅读 19 收藏 0 点赞 0 评论 0
public RadialGradientFillBitmapTextureAtlasSourceDecorator(final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final IBitmapTextureAtlasSourceDecoratorShape pBitmapTextureAtlasSourceDecoratorShape, final int[] pColors, final float[] pPositions, final RadialGradientDirection pRadialGradientDirection, final TextureAtlasSourceDecoratorOptions pTextureAtlasSourceDecoratorOptions) {
    super(pBitmapTextureAtlasSource, pBitmapTextureAtlasSourceDecoratorShape, pTextureAtlasSourceDecoratorOptions);
    this.mColors = pColors;
    this.mPositions = pPositions;
    this.mRadialGradientDirection = pRadialGradientDirection;

    this.mPaint.setStyle(Style.FILL);

    final int width = pBitmapTextureAtlasSource.getTextureWidth();
    final int height = pBitmapTextureAtlasSource.getTextureHeight();

    final float centerX = width * 0.5f;
    final float centerY = height * 0.5f;

    final float radius = Math.max(centerX, centerY);

    switch (pRadialGradientDirection) {
        case INSIDE_OUT:
            this.mPaint.setShader(new RadialGradient(centerX, centerY, radius, pColors, pPositions, TileMode.CLAMP));
            break;
        case OUTSIDE_IN:
            ArrayUtils.reverse(pColors);
            this.mPaint.setShader(new RadialGradient(centerX, centerY, radius, pColors, pPositions, TileMode.CLAMP));
            break;
    }
}
CircleImageView.java 文件源码 项目:MyCTFWriteUps 阅读 34 收藏 0 点赞 0 评论 0
public OvalShadow(int i, int j)
{
    this$0 = CircleImageView.this;
    super();
    mShadowPaint = new Paint();
    mShadowRadius = i;
    mCircleDiameter = j;
    float f = mCircleDiameter / 2;
    float f1 = mCircleDiameter / 2;
    float f2 = mShadowRadius;
    circleimageview = android.graphics.Shader.TileMode.CLAMP;
    mRadialGradient = new RadialGradient(f, f1, f2, new int[] {
        0x3d000000, 0
    }, null, CircleImageView.this);
    mShadowPaint.setShader(mRadialGradient);
}
CustomEvaluator.java 文件源码 项目:ApiDemos 阅读 20 收藏 0 点赞 0 评论 0
private ShapeHolder createBall(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);
    return shapeHolder;
}


问题


面经


文章

微信
公众号

扫码关注公众号