About the basics question of the arc,thanks

ofPath curve;	
curve.arc(400,300,0, 100, 100, 180, 360);


I draw an arc through ofPath,
what is a good way to map a rectangular texture directly onto this arc? Thank you

Hi @mawof42626, ofPath is sort of like a set of directions for drawing a shape. If you want to bind a texture, a class that has texture coordinates like ofMesh should work great. Sometimes its easier to create an ofMesh from scratch too, rather tessellating one from ofPath.

Here is a quick study:

#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
    void setup();
    void update();
    void draw();

    ofPath path;
    ofMesh mesh;
    ofImage image;


#include "ofApp.h"
void ofApp::setup(){
    path.arc(400, 300, 0, 100, 100, 180, 360);
    mesh = path.getTessellation();
    // mesh still needs some texture coordinates;
    // let's get some from the vertices:
    for(size_t i{0}; i < mesh.getVertices().size(); ++i){
        glm::vec3 vertex = mesh.getVertices().at(i);
        glm::vec2 tc(vertex.x, vertex.y);

void ofApp::update(){

void ofApp::draw(){
    // this didn't get the texture, but there is some color:
//    path.draw();
1 Like

thanks,texture coordinates are difficult to correspond to vertex coordinates one by one

Yeah this is definitely true if the texture is smaller.Texture coordinates can be scaled or translated if needed, and the texture can also be distorted when it maps to the texture coordinates. Sometimes it helps to work with normalized values.

An ofTexture has a few different ways it can “repeat”, which can be helpful when the texture is smaller or the coordinates are too close to the edge. I like to use GL_MIRRORED_REPEAT. The default is GL_CLAMP_TO_EDGE. It can be set like this:

    image.getTexture().setTextureWrap(GL_MIRRORED_REPEAT, GL_MIRRORED_REPEAT);

Well, thank you very much for your patience

Is there a way to map a rectangular texture to an arc without losing the content and distorting the texture,thanks

I can’t think of a way to do this. You can “crop” an image to an arc shape, but some content will be lost. Mapping a full rectangle to an arc shape results in distortion as the cartesian coordinates of a rectangle conform (distort) to the polar coordinates of the arc shape. In other words, the texture is like a rectangular piece of paper. To get the paper into an arc shape, you have to either cut it with scissors (crop), or fold it a certain way (distort).

You’re welcome to post some code and/or an image of what you’d like to do.

Okay, thanks. I haven’t found a good way yet.