views:

610

answers:

2

Given a closed Path object result is like this: http://www.tutorialguide.net/images/adobe_photoshop/0043/001.jpg. Although that is a rectangle I'm looking for something which works with any closed Path.

+1  A: 

this may help

protected void onDraw(Canvas canvas)
{
    super.onDraw(canvas);
    int w = getWidth();
    int h = getHeight();
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
    Path pth = new Path();
    pth.moveTo(w*0.27f,0);
    pth.lineTo(w*0.73f,0);
    pth.lineTo(w*0.92f,h);
    pth.lineTo(w*0.08f,h);
    pth.lineTo(w*0.27f,0);
    p.setColor(0xff800000);
    p.setShader(new LinearGradient(0,0,0,h,0xff000000,0xffffffff,Shader.TileMode.CLAMP));
    canvas.drawPath(pth,p);
}   
steelbytes