How to map a texture to an 2D ellipse?
in
Programming Questions
•
8 months ago
I know to map a texture we go like:
PImage myImg;
void setup() {
size(300, 300, P2D);
myImg = loadImage("some_image.ext");
textureMode(NORMAL);
}
void draw() {
background(0);
translate(width/2, height/2);
textureWrap(CLAMP);
beginShape();
texture(myImg);
vertex(-100, -100, 0, 0);
vertex(100, -100, 1, 0);
vertex(100, 100, 1, 1);
vertex(-100, 100, 0, 1);
endShape();
}
But how to actually map, or more specific, crop an image and fit it in an ellipse? Do I have to draw the ellipse with vertex() functions? Please help!
1