@antocreo wrote:
Hello everyone!
I am a bit rusty with C++ and OF and I am having trouble figuring this out, maybe the forum can help?
I created an array of"ofRectangles"
and I want to draw them on stage.in .h
ofRectangle topLeft, topRight, bottomLeft, bottomRight; ofRectangle corners[4] = {topLeft, topRight, bottomLeft, bottomRight};
in .cpp
setup(){ //define corners topLeft.set(x0,y0,w,h); topRight.set(x1,y1,w,h); bottomLeft.set(x2,y2,w,h); bottomLeft.set(x3,y3,w,h); } draw(){ for (int i=0; i<sizeof(corners)/sizeof(corners[0]); i++) { ofPushStyle(); ofSetColor(100,100,100); ofDrawRectangle(corners[i]); ofPopStyle(); } }
I don’t see them at all. So I guess it’s because in .h the
ofRectangles
are not defined yet.
So I thought to fill the array insetup()
but can’t find a quick way.
Is there any way other thancorners[0] = topLeft; corners[1] = topRight //etc. etc..
It sounds trivial and I know it’s only 4 items but still it would be nice to have it automated.
Anyone, any idea?
Cheers
Posts: 3
Participants: 2