just a quick question that im just having a little bit of trouble figuring out.
but what im doing is trying to assign a video to a rectangle shape. then ill further manipulate it. so it really just shows in that rectangle.
cant set names to ofRect, so how else could i go about this?
You can use an ofMesh shape, then during draw(), get the texture of the videoplayer and bind it before drawing the ofMesh…
Or, much simple, use the draw(float x, float y, float w, float h) method of ofVideoplayer - By passing the position and dimensions of the desired image size you’ll draw the video frames like if it was inside a simple rectangle…
oh fantastic. ill give a bash at that when i get to my computer
Hi, try using an instance of ofRectangle. besides storing the x and y positions and width and height it also has a lot of really useful methods. take a look at it.
v.draw(r.x, r.y, r.width, r.height);
actually. i did just do that. and it works the way i need it to
but thanks for coming up with exactly the same way
the only problem is coloring the rectangle, you cant seem to do it. because whilst i need it around, it cant be seen.
does anyone know how to alpha it? there are no settings, or any setColor() for ofRectangle
aaah please excuse, i actually had a ofRect drawing in the ofRectangle.
its all good now. silly code
originally i was thinking mesh, but when i thought about it, ofRectangle works the best in what i need.
maybe a little bit long winded, but id rather type a few more lines and see where and how everything is talking to each other
thanks all for the guidance anyhow
There’s a bit of confusion about ofRect(…) and ofRectangle.
ofRectangle is a class, hence you can create objects (instances) of it. It simply holds the values that define a rectangle; x, y, width and height.
ofRect is a function used to draw a rectangle, according to the parameters given to it. Actually this function is going to be deprecated in the next release and changed for ofDrawRectangle, to avoid this sort of confusion.
for drawing the rectangle you can simply pass it to ofRect.
remember that anything you draw is sequential, thus in your code anything that’s drawn, gets drawn over the previous things, so the order in which you go drawing your things matter.
To draw an instance of ofRectangle you can do the following.
ofSetColor(255,0,0,120);//red, green, blue, alpha
ofFill();// will draw a filled rectangle;
ofSetColor(ofColor::blue, 200);/there's a long list of predefined colors you can call this way. In this case also with an alpha of 200.
ofNoFill();//this will draw just the borders of the rectangle.
ofSetLineWidth(3); //the default is 1.
Remember the order in which you draw.
If you want a colored rectangle around your video I’d recomend you to draw a filled rectangle behind the video.
This means, draw the rectangle first, then draw the video.
ofRectangle has a very useful method called scaleFromCenter(…). you can use it to scale your rectangle but keep it in place.
aye, i think a name change is good indeed. more to save confusion for users who are new to the platform