0

i am able to draw arc using Paint and passing some gradient color to it, my problem is that i need draw the arc using a gradient image.Is it possible to draw arc using an image?

If so how to do it?

this is my current code:

Paint nPaint = new Paint();
        nPaint.setAntiAlias(true);
        nPaint.setDither(true);
        nPaint.setStrokeJoin(Paint.Join.ROUND);
        nPaint.setStrokeCap(Paint.Cap.ROUND);
        int gradientStart = getResources().getInteger(R.integer.gradient_start);
        int gradientend = getResources().getInteger(R.integer.gradient_end);

        nPaint.setShader(new RadialGradient(getWidth() / 2, getHeight() / 2, getWidth() / 2,
            gradientStart, gradientend, Shader.TileMode.CLAMP));
Goofy
  • 6,098
  • 17
  • 90
  • 156

1 Answers1

0

Try this code i hope this will help you

     @Override
    protected void onDraw(Canvas canvas) {

        canvas.drawColor(Color.CYAN);
        Paint p = new Paint();
        // smooths
        p.setAntiAlias(true);
        p.setColor(Color.RED);
        p.setStyle(Paint.Style.STROKE); 
        p.setStrokeWidth(5);
        // opacity
        //p.setAlpha(0x80); //

        RectF rectF = new RectF(50, 20, 100, 80);
        canvas.drawOval(rectF, p);
        p.setColor(Color.BLACK);
        canvas.drawArc (rectF, 90, 45, true, p);
    }
Rashad
  • 11,057
  • 4
  • 45
  • 73