@Dazzid_of wrote:
Hi Of,
I'm using getStringAsPoints to find the outline of a text. The method paths[i].getOutline(), gives me all points of the text outline. How can I have all points of the text? I mean inside the character as well?Do I need to create a fbo to then draw the text as a texture, to create an image and scan it using getPixel? Or there is something in my code that can by changed to do the same idea?
string uWord = "testing"; ofRectangle r = ttf.getStringBoundingBox(uWord, 0, 0); center = ofVec2f(floor(-r.x - r.width * 0.5f), floor(-r.y - r.height * 0.5f)); center.x += ofGetWidth() / 2; center.y += ofGetHeight() / 2; // get the string as paths vector <ofTTFCharacter> paths = ttf.getStringAsPoints(uWord); for(int i = 0; i < paths.size(); i++){ // for every character break it out to polylines vector <ofPolyline> polylines = paths[i].getOutline(); for(int j = 0; j < polylines.size(); j++){ vector <ofVec2f> linePoints; ofPolyline spacePoly = polylines[j].getResampledBySpacing(1); // add all the points of the resampled polyline to the character vector for(int k = 0; k < spacePoly.size(); k++){ linePoints.push_back(spacePoly[k]); } // add the vector of points to the main vector (which is indeed a vector of vectors) points.push_back(linePoints); } } for(int i = 0; i < points.size(); i++){ vector <ofVec2f> charPoints = points[i]; for(int j = 0; j < charPoints.size(); j++){ coordinates.push_back(ofVec2f(charPoints[j].x+center.x, charPoints[j].y+center.y)); } }
Posts: 1
Participants: 1