MCPcopy Create free account
hub / github.com/braitsch/ofxDatGui / draw

Method draw

example-Matrices/src/ofApp.cpp:35–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void ofApp::draw()
36{
37 float w = ofGetWidth()/numCols;
38 float h = ofGetHeight()/numRows;
39
40 for (int i=0; i<numRows*numCols; i++) {
41 float x = w * (i%numCols);
42 float y = h * (floor(i/numCols));
43 // fill the box if the corresponding button in the matrix is selected //
44 if (matrix->getButtonAtIndex(i)->getSelected() == true) {
45 ofFill();
46 ofSetColor(ofColor::fromHex(0xEEEEEE));
47 ofDrawRectangle(x, y, w, h);
48 }
49 // draw wireframe /
50 ofNoFill();
51 ofSetColor(ofColor::fromHex(0x303030));
52 ofDrawRectangle(x, y, w, h);
53 // draw box number //
54 ofRectangle bounds = font.getStringBoundingBox(ofToString(i+1), 0, 0);
55 font.drawString(ofToString(i+1), x+w/2-bounds.width/2, y+h/2+bounds.height/2);
56 }
57 matrix->draw();
58}
59
60void ofApp::onMatrixEvent(ofxDatGuiMatrixEvent e)
61{

Callers

nothing calls this directly

Calls 2

getButtonAtIndexMethod · 0.80
getSelectedMethod · 0.45

Tested by

no test coverage detected