what I'm trying to paint is the following: But with a plus instead of a minus sign in the center of the arrow.
I want to subtract the 'minus' from the white base shape. Strangely that works fine for the minus, but if I draw a plus sign instead it does not subtract it anymore but adds it to the underlying path.
My Code for subtracting the minus looks like this
Path base = new Path();
[... draw the arrow ]
Path subtract = new Path();
subtract.moveTo(-xBarWidth/2, -xBarHeight/2); // center the path
subtract.rLineTo(xBarWidth, 0);
subtract.rLineTo(0, xBarHeight);
subtract.rLineTo(-xBarWidth, 0);
subtract.rLineTo(0, -xBarHeight);
base.add(subtract);
[in paint() function: canvas.draw(base, paint)]
The code for the plus sign:
int halfBarWidth = xBarWidth/2;
subtract.moveTo(-halfBarWidth, -xBarHeight/2);
subtract.rLineTo(halfBarWidth, 0);
subtract.rLineTo(0, halfBarWidth);
subtract.rLineTo(xBarHeight, 0);
subtract.rLineTo(0, -halfBarWidth);
subtract.rLineTo(halfBarWidth, 0);
subtract.rLineTo(0, -xBarHeight);
subtract.rLineTo(-halfBarWidth, 0);
subtract.rLineTo(0, -halfBarWidth);
subtract.rLineTo(-xBarHeight, 0);
subtract.rLineTo(0, halfBarWidth);
subtract.rLineTo(-halfBarWidth, 0);
subtract.rLineTo(0, xBarHeight);
However, now it draws a white plus on top of the arrow. I tried subtract.setFillType(FillType.INVERSE_EVEN_ODD)
but it didn't change anything.
Unfortunately I can't find any help in the api.
maybe this will help someone: I had to set the fillType of base to EVEN_ODD
base.setFillType(FillType.EVEN_ODD);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With