danomatika / loaf

loaf: lua, osc, and openFrameworks
http://danomatika.com/code/loaf
GNU General Public License v3.0
53 stars 4 forks source link

A few other C++ vectors might need to be wrapped (ofPolyline, ofPath) #5

Closed dom1817 closed 3 years ago

dom1817 commented 5 years ago

This structure seems to be quite common in openFrameworks: vector<ofPath>vector<ofPolyline>vector<ofVertex>

A use case with a similar structure that I was trying to use in Loaf is: vector<ofPath> characters = font.getStringAsPoints(text) Then: vector <ofPolyline> outlines = characters[n].getOutline() Then: vector <ofVertex> vertices = outlines[n]

Now that vectors of vertices or points are now accessible, wrapping also the other containers would be a great addition to Loaf.

-- Define font
font = of.TrueTypeFont()
font:load("filename.ttf", 32)

-- Print each vertex of a character
characters = font:getStringAsPoints("Hello")
for i=0,characters:size() do
    outlines = characters[i]
    for n=0, outlines:size() do
        vertices = outlines[n]
        for m=0, vertices:size() do
            of.drawCircle(vertices[m],10)
        end
    end
end
danomatika commented 5 years ago

Ok. Can you provide a list? That would be the easiest for me, other than looking through the API again.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Oct 5, 2019, at 8:02 PM, dom1817 notifications@github.com wrote:

This structure seems to be quite common in openFrameworks: vector → vector → vector

A use case with a similar structure that I was trying to use in Loaf is: vector characters = font.getStringAsPoints(text) Then: vector outlines = characters[n].getOutline() Then: vector vertices = outlines[n]

Now that vectors of vertices or points are now accessible, wrapping also the other containers would be a great addition to Loaf.

-- Define font font = of.TrueTypeFont() font:load("filename.ttf", 32)

-- Print each vertex of a character characters = font:getStringAsPoints("Hello") for i=0,characters:size() do outlines = characters[i] for n=0, outlines:size() do vertices = outlines[n] for m=0, vertices:size() do of.drawCircle(vertices[m],10) end end end — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dom1817 commented 5 years ago

ofPolyline

ofPath

ofTrueTypeFont

Then I think that ofMesh and ofVboMesh will be a bit more complicated, as they have a lot of functions returning vectors (getIndices, getColors, getNormals, getTexCoords). I tried quickly and only getVertices seems to be wrapped correctly.

danomatika commented 3 years ago

I tried quickly and only getVertices seems to be wrapped correctly.

Note: Those are explicitly ignored when making the bindings. I don't try to make the Lua bindings cover 100% of the OF API. For things which have a function with arguments and an alternative version with a vector, I started by ignoring the vector version.

danomatika commented 3 years ago

Ok, all of these type vectors should now be wrapped, including those used by ofMesh. Can you try this test build?

http://docs.danomatika.com/releases/loaf/loaf-1.6.0-test1-macos.zip

danomatika commented 3 years ago

I'm going to assume they work now. Please test and reopen if not.