ofDrawBox(const ofPoint& position, const ofPoint& size)


Why don’t we have a function like this?

void ofDrawBox(const ofPoint& position, const ofPoint& size) {
ofDrawBox( position.x, position.y, position.z, size.x, size.y, size.z);

Do you mean to have an ofPoint reference as the size parameter instead of passing 3 different values for the size?

yes, I thought that could be handy in many cases…
What do you think?

Sure. I guess that it is more suited to put an issue in github about it.


Currently the closest we have is:

ofPoint corner0;
ofPoint corner1;

ofRect(ofRectangle(corner0, corner1));

We do not have a dedicated class for describing dimensions. Without a dedicated dimension/size type a method signature like you suggest is ambiguous because we use the const ofPoint& position, const ofPoint& size signature to construct rectangles by defining two corners, which is very useful.

Many frameworks have a type to describe Size/Dimension (QSize, CGSize, etc). It has been proposed and discussed here in the past. I’m still a fan of the idea, but it didn’t win popular support.

Also, in the roadmap for 1.0, we are definitely planning to disambiguate drawing and shape classes (i.e. ofRect becomes ofDrawRect, etc).

Wouldn’t it be just something like typedef ofVec3f ofSize;?

@roymacdonald Unfortunately typedefs are not strictly typed and thus the method signatures would still be ambiguous or interpreted as an illegal redeclaration.


/// note, ofPoint is a typedef for ofVec3f
typedef ofPoint ofSize;
/// ...
class ofRectangle {	
    virtual ~ofRectangle();
    /// ...
    ofRectangle(const ofPoint& p0, const ofPoint& p1);
    ofRectangle(const ofPoint& p0, const ofSize& p1); 
        ///< This is a redeclaration of the above
    /// ...

@bakercp I see.
thanks for clarifying .

1 Like