Skip to content

Commit 9d272ad

Browse files
authored
MIN -> std::min in examples (#8490)
1 parent d55ecf7 commit 9d272ad

File tree

7 files changed

+65
-67
lines changed

7 files changed

+65
-67
lines changed

examples/3d/quaternionArcballExample/src/ofApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void ofApp::draw(){
7272
float redValueFromXspeed = ofMap( fabs(xspeed), 1, 15, 100, 255, true );
7373
float greenValueFromYspeed = ofMap( fabs(yspeed), 1, 15, 100, 255, true );
7474

75-
ofSetColor( redValueFromXspeed, greenValueFromYspeed, MIN(redValueFromXspeed, greenValueFromYspeed) );
75+
ofSetColor( redValueFromXspeed, greenValueFromYspeed, std::min(redValueFromXspeed, greenValueFromYspeed) );
7676
ofDrawSphere(0, -newSize, 0, 10.0 );
7777
ofDrawSphere(0, newSize, 0, 10.0 );
7878
ofDrawSphere(newSize, 0, 0, 10.0 );

examples/computer_vision/opencvOpticalFlowExample/src/ofApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void ofApp::update(){
9595
// store as floats
9696
flowMat = cv::Mat(scaledHeight, scaledWidth, CV_32FC2);
9797

98-
ofSetWindowShape(MIN(sourceWidth, 1920), MIN(sourceHeight, 1200));
98+
ofSetWindowShape(std::min(sourceWidth, 1920), std::min(sourceHeight, 1200));
9999

100100
// clear the previous vectors
101101
spinCubes.clear();

examples/gl/fboHighResOutputExample/src/ofApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ void ofApp::setup(){
1010
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
1111

1212
// take the smaller size
13-
int fboWidth = MIN(8192,maxSize);
14-
int fboHeight = MIN(8192,maxSize);
13+
int fboWidth = std::min(8192,maxSize);
14+
int fboHeight = std::min(8192,maxSize);
1515
//allocate our fbo with 3 color channels and 4x multisample
1616
#ifdef TARGET_EMSCRIPTEN
1717
fboOutput.allocate(fboWidth, fboHeight, GL_RGB);

examples/input_output/xmlSettingsExample/src/ofApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ofApp::setup(){
6969

7070
//we have only allocated a certan amount of space for our array
7171
//so we don't want to read more than that amount of points
72-
int totalToRead = MIN(numPtTags, NUM_PTS);
72+
int totalToRead = std::min(numPtTags, NUM_PTS);
7373

7474
for(int i = 0; i < totalToRead; i++){
7575
//the last argument of getValue can be used to specify

examples/ios/xmlSettingsExample/src/ofApp.mm

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
//we load our settings file
1616
//initially we do this from the data/ folder
1717
//but when we save we are saving to the documents folder which is the only place we have write access to
18-
//thats why we check if the file exists in the documents folder.
19-
18+
//thats why we check if the file exists in the documents folder.
19+
2020
if( XML.loadFile(ofxiOSGetDocumentsDirectory() + "mySettings.xml") ){
2121
message = "mySettings.xml loaded from documents folder!";
2222
}else if( XML.loadFile("mySettings.xml") ){
2323
message = "mySettings.xml loaded from data folder!";
2424
}else{
2525
message = "unable to load mySettings.xml check data/ folder";
2626
}
27-
27+
2828
//read the colors from XML
2929
//if the settings file doesn't exist we assigns default values (170, 190, 240)
3030
red = XML.getValue("BACKGROUND:COLOR:RED", 170);
@@ -74,7 +74,7 @@
7474

7575
//we have only allocated a certan amount of space for our array
7676
//so we don't want to read more than that amount of points
77-
int totalToRead = MIN(numPtTags, NUM_PTS);
77+
int totalToRead = std::min(numPtTags, NUM_PTS);
7878

7979
for(int i = 0; i < totalToRead; i++){
8080
//the last argument of getValue can be used to specify
@@ -110,11 +110,11 @@
110110
string drawString = "How the data is stored:\n\n";
111111
if(xmlStructure.size() > 0){
112112
ofEnableAlphaBlending();
113-
ofSetColor(255-red, 255-green, 255-blue, 180);
113+
ofSetColor(255-red, 255-green, 255-blue, 180);
114114
drawString += xmlStructure+"</STROKE>";
115115
TTF.drawString(drawString, 5, 60);
116116
}
117-
117+
118118
//---------
119119
//Lets draw the stroke as a continous line
120120
ofSetHexColor(0x222222);
@@ -146,7 +146,7 @@
146146

147147
//--------------------------------------------------------------
148148
void ofApp::exit(){
149-
149+
150150
}
151151

152152
//--------------------------------------------------------------
@@ -226,7 +226,7 @@
226226
dragPts[pointCount].set(touch.x, touch.y);
227227
pointCount++;
228228
}
229-
229+
230230
}
231231

232232
}
@@ -254,21 +254,20 @@
254254

255255
//--------------------------------------------------------------
256256
void ofApp::lostFocus(){
257-
257+
258258
}
259259

260260
//--------------------------------------------------------------
261261
void ofApp::gotFocus(){
262-
262+
263263
}
264264

265265
//--------------------------------------------------------------
266266
void ofApp::gotMemoryWarning(){
267-
267+
268268
}
269269

270270
//--------------------------------------------------------------
271271
void ofApp::deviceOrientationChanged(int newOrientation){
272-
273-
}
274272

273+
}

examples/shader/07_fboAlphaMaskExample/src/ofApp.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ void ofApp::setup(){
88
}else{
99
shader.load("shadersGL2/shader");
1010
}
11-
11+
1212
brushImage.load("brush.png");
1313
// change the image to draw from the center
1414
// the default is from top left
1515
brushImage.setAnchorPercent(0.5f, 0.5f);
16-
16+
1717
textures.resize(5);
1818
for( int i = 0; i < textures.size(); i++ ){
1919
ofLoadImage(textures[i], "tex"+ofToString(i,0)+".jpg");
2020
}
21-
21+
2222
bBrushDown = false;
23-
23+
2424
}
2525

2626
//--------------------------------------------------------------
2727
void ofApp::update(){
28-
28+
2929
// check to see if we need a new fbo size
3030
// if the window size changes or the fbo is not allocated, we can catch it here and reallocate
3131
if( !maskFbo.isAllocated() || maskFbo.getWidth() != ofGetWidth() || maskFbo.getHeight() != ofGetHeight() ){
@@ -36,7 +36,7 @@ void ofApp::update(){
3636
maskFbo.begin();
3737
ofClear(0,0,0,255);
3838
maskFbo.end();
39-
39+
4040
drawMesh = ofMesh::plane(maskFbo.getWidth(), maskFbo.getHeight() );
4141
// the plane has tex coords from 0 - 1, but we need tex coords from 0 -> maskFbo.getWidth()
4242
auto& texCoords = drawMesh.getTexCoords();
@@ -45,11 +45,11 @@ void ofApp::update(){
4545
for( auto& tc : texCoords ){
4646
tc = maskFbo.getTexture().getCoordFromPercent(tc.x, (1.0-tc.y));
4747
}
48-
48+
4949
// lets reload the font at a size in relation to width or height
5050
ofTrueTypeFont tf;
51-
tf.load("Batang.ttf", MIN(maskFbo.getWidth(), maskFbo.getHeight()) / 2, true, true, true);
52-
51+
tf.load("Batang.ttf", std::min(maskFbo.getWidth(), maskFbo.getHeight()) / 2, true, true, true);
52+
5353
oLine.clear();
5454
// pull out the polylines of the O character for later use
5555
// getCharacterAsPoints returns an ofPath
@@ -60,7 +60,7 @@ void ofApp::update(){
6060
for( auto op : opolys ){
6161
oLine.addVertices( op.getVertices() );
6262
}
63-
63+
6464
fLine.clear();
6565
// pull out the polylines of the F character for later use
6666
opath = tf.getCharacterAsPoints('F', true, false);
@@ -75,7 +75,7 @@ void ofApp::update(){
7575
void ofApp::draw(){
7676

7777
ofSetColor(255);
78-
78+
7979
//----------------------------------------------------------
8080
// draw the brush into the fbo with the position based on the polylines derived from the font
8181
maskFbo.begin();
@@ -87,21 +87,21 @@ void ofApp::draw(){
8787
// store the elapsed time in a variable for later use
8888
float elapsedTime = ofGetElapsedTimef();
8989
float deltaTime = ofClamp( ofGetLastFrameTime(), 1.f / 1000.0, 1.f / 5.0f );
90-
90+
9191
float mouseXPercent = ofMap( ofGetMouseX(), 0, ofGetWidth(), 0.05, 1.0, true );
9292
eTimeCounter += deltaTime * mouseXPercent;
93-
93+
9494
float offset = ofMap( ofGetMouseY(), 10, ofGetHeight()-10, 0, 100, true);
95-
95+
9696
float polylinePercent = ofWrap( eTimeCounter, 0, 1);
9797
float findex = oLine.getIndexAtPercent(polylinePercent);
98-
98+
9999
auto position = oLine.getPointAtPercent( polylinePercent );
100100
auto normal = oLine.getNormalAtIndexInterpolated(findex);
101101
normal *= sin( elapsedTime * 13.4f ) * cos(elapsedTime * 2.4f);
102102
normal.z = 0.0;
103103
position += normal * offset;
104-
104+
105105
ofPushMatrix();
106106
// translate to the center of the fbo //
107107
ofTranslate( maskFbo.getWidth()/2., maskFbo.getHeight() / 2. );
@@ -110,15 +110,15 @@ void ofApp::draw(){
110110
ofTranslate( -oLine.getBoundingBox().getWidth()*0.75f, 0.0f );
111111
brushImage.draw(position.x, position.y, brushSize, brushSize);
112112
ofPopMatrix();
113-
114-
113+
114+
115115
findex = fLine.getIndexAtPercent(polylinePercent);
116116
position = fLine.getPointAtPercent( polylinePercent );
117117
normal = fLine.getNormalAtIndexInterpolated(findex);
118118
normal *= sin( elapsedTime * 9.4f ) * cos(elapsedTime * 5.4f);
119119
normal.z = 0.0;
120120
position += normal * offset;
121-
121+
122122
ofPushMatrix();
123123
// translate to the center of the fbo //
124124
ofTranslate( maskFbo.getWidth()/2., maskFbo.getHeight() / 2. );
@@ -127,7 +127,7 @@ void ofApp::draw(){
127127
ofTranslate( fLine.getBoundingBox().getWidth()*0.75f, 0.0f );
128128
brushImage.draw(position.x, position.y, brushSize, brushSize);
129129
ofPopMatrix();
130-
130+
131131
maskFbo.end();
132132

133133
//----------------------------------------------------------
@@ -144,7 +144,7 @@ void ofApp::draw(){
144144
brushImage.draw(brushImageX, brushImageY, brushSize, brushSize);
145145
maskFbo.end();
146146
}
147-
147+
148148
//----------------------------------------------------------
149149
// HERE the shader-masking happens
150150
shader.begin();
@@ -169,9 +169,9 @@ void ofApp::draw(){
169169
ofTranslate(ofGetWidth()/2, ofGetHeight()/2 );
170170
drawMesh.draw();
171171
ofPopMatrix();
172-
172+
173173
shader.end();
174-
174+
175175
//----------------------------------------------------------
176176
float drawStringY = 0;
177177
ofDrawBitmapStringHighlight("Drag the Mouse to draw. Mode (e): "+string(bEraser?"eraser":"brush"), 15,drawStringY+=15);
@@ -217,7 +217,7 @@ void ofApp::keyReleased(int key){
217217

218218
//--------------------------------------------------------------
219219
void ofApp::mouseMoved(int x, int y){
220-
220+
221221
}
222222

223223
//--------------------------------------------------------------
@@ -246,6 +246,6 @@ void ofApp::gotMessage(ofMessage msg){
246246
}
247247

248248
//--------------------------------------------------------------
249-
void ofApp::dragEvent(ofDragInfo dragInfo){
249+
void ofApp::dragEvent(ofDragInfo dragInfo){
250250

251251
}

0 commit comments

Comments
 (0)