Khawar Raza
Khawar Raza

Reputation: 16120

Android Drawing a shape programatically on bitmap

I want to draw a shape like:

enter image description here

I can use this shape to draw over canvas but I have to create this bitmap on runtime with black and what color. Is there any way to do this like using path or something else?

Upvotes: 1

Views: 1164

Answers (1)

user
user

Reputation: 87064

Is there any way to do this like using path or something else?

Yes, you could create it with a Path:

// the Paint for the path
Paint p = new Paint();
p.setAntiAlias(true);
p.setColor(Color.BLACK);
p.setStyle(Style.FILL);
// the path
Path pth = new Path();      
pth.moveTo(50, 200); // example values, modify with your own, or to improve the path
pth.lineTo(70, 140);
pth.quadTo(150, 115, 230, 140);
pth.lineTo(250, 200);
pth.quadTo(150, 165, 50, 200);
pth.close();

Make sure that the values you use for the path are in the Bitmap's bounds so you can see the path.

Upvotes: 4

Related Questions