Created
October 15, 2012 21:42
-
-
Save jkosoy/3895744 to your computer and use it in GitHub Desktop.
Cinder Drawing Tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// originally from http://redpaperheart.com/blog/2012/08/handy-snippets-for-drawing-image-textures-in-cinder/ | |
// thanks Daniel! | |
// --------------------- | |
/* draw a texture */ | |
gl::draw(texture); | |
// --------------------- | |
/* Draw a texture into a specified rectangle, distort texture to fill rectangle: */ | |
gl::draw(texture, Rectf(0,0,200,200)); | |
// --------------------- | |
/* Draw a texture to fit completely into specified rectangle (no distortion/keeps aspect ratio, shows white space): */ | |
Rectf destRect = Rectf(0,0,200,200); | |
gl::draw(texture, Rectf(texture.getBounds()).getCenteredFit(destRect, true)); | |
// --------------------- | |
/* Draw a texture to fill a specified rectangle while retaining image proportions and not showing white space (texture is centered within the rectangle and overflow is masked/cropped): */ | |
Rectf destRect = Rectf(0,0,200,200); | |
gl::draw(texture, Area(destRect.getCenteredFit(texture.getBounds(), true)), destRect); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment