Image inside a polygon with java2D
in
Programming Questions
•
4 months ago
Hi,
i'd like to display a shape (polygon) with an image inside.
There is the texture function with openGL graphics, but even with smooth(n) the render is too ugly.
The only nice render is the native one (Java2D).
But I didn't find any way to display my image inside a polygon with java2D:
- texture not available
- createshape not available
I tried to make a shape with a whole to hide the part of the image I don't want to show, but I didn't success...
I tried this but even the whole is filled:
- fill(0,0,0,255);
- g.rect(0,0,300,300);
- fill(255,255,255,255);
- beginShape();
- // Exterior part of shape
- beginContour();
- vertex(50,50);
- vertex(250,50);
- vertex(250,250);
- vertex(50,250);
- vertex(50,50);
- endContour();
- // Interior part of shape
- beginContour();
- vertex(140,140);
- vertex(160,140);
- vertex(160,160);
- vertex(140,160);
- vertex(140,140);
- endContour();
- // Finishing off shape
- endShape(CLOSE);
Any idea?
1