本文整理汇总了C++中ofTrueTypeFont::stringWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTrueTypeFont::stringWidth方法的具体用法?C++ ofTrueTypeFont::stringWidth怎么用?C++ ofTrueTypeFont::stringWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofTrueTypeFont
的用法示例。
在下文中一共展示了ofTrueTypeFont::stringWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMindsetStatus
void drawMindsetStatus(ofxThinkgearEventArgs& data){
// ofPushStyle(); // fucking bug
ofSetRectMode(OF_RECTMODE_CENTER);
ofPushMatrix();
ofTranslate(ofGetWidth() - 100, 100);
ofFill();
ofSetCircleResolution(100);
ofSetColor(0, 0, 0, 128);
ofCircle(0, 0, 52);
// Show connection state
switch (tgState){
case NONE:
ofSetColor(0, 0, 0);
break;
case CONNECTING:
ofSetColor(200, 200, 0);
break;
case BAD_SIGNAL:
ofSetColor(200, 0, 0);
break;
case READY:
ofSetColor(0, 200, 0);
break;
}
ofRect(0, 0, 10, 10);
if (true || tgState == READY){
// MindSet info pad
ofSetColor(200, 200, 200);
float w = smallFont.stringWidth(ofToString(data.raw));
smallFont.drawString(ofToString(data.raw), -w/2, -38);
ofSetColor(200+55*(medScore/200), 200, 200);
ofCircle(20, -20, min(1.0, data.meditation/100.0) * 16);
ofSetColor(200+55*(attScore/200), 200, 200);
ofCircle(-20, -20, min(1.0, data.attention/100.0) * 16);
ofSetColor(200, 200, 200);
ofRect(40-15*eegData.midGamma.ratio, 0, 30*eegData.midGamma.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.lowGamma.ratio, 0, 30*eegData.lowGamma.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.highBeta.ratio, 0, 30*eegData.highBeta.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.lowBeta.ratio, 0, 30*eegData.lowBeta.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.highAlpha.ratio, 0, 30*eegData.highAlpha.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.lowAlpha.ratio, 0, 30*eegData.lowAlpha.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.theta.ratio, 0, 30*eegData.theta.ratio, 10);
ofRotate(25.7, 0, 0, 1);
ofRect(40-15*eegData.delta.ratio, 0, 30*eegData.delta.ratio, 10);
}
ofPopMatrix();
// ofPopStyle(); // fucking bug
ofSetRectMode(OF_RECTMODE_CORNER); // fucking bug
}
示例2: wrapString
//------------------------------------------------------------
string wrapString(string text, ofTrueTypeFont &ofttf_object, int width) {
string typeWrapped = "";
string tempString = "";
vector <string> words = ofSplitString(text, " ");
for(int i=0; i<words.size(); i++) {
string wrd = words[i];
//cout << wrd << endl;
tempString += wrd + " ";
int stringwidth = ofttf_object.stringWidth(tempString);
if(stringwidth >= width) {
tempString = "";
typeWrapped += "\n";
}
typeWrapped += wrd + " ";
}
return typeWrapped;
}
示例3:
void PMSc10Thanks::drawRightAlignString(ofTrueTypeFont &font, string s, int x, int y)
{
int halfStringHeight = font.stringHeight(s) / 2;
int stringWidth = font.stringWidth(s);
font.drawString(s, x - stringWidth, y + halfStringHeight);
}