← Back

ofxCropper

github.com/bgirschig/ofxCropper · @bgirschig
OF 0.9 Graphics Geometry

An openframeworks utility for setting the transform matrix to fit objects into others

0 0 Last commit 11y ago Created 11y ago

README

Cropper



The cropper class can be used to select a region of interest and crop / scale it to fit in a target region.

Basic use:

void ofApp::draw(){
  myCropper.setSource(0,0,200,200);   // the cropper will select an area of 200x200px at the top left...
  myCropper.setFitMode(STRETCH);      // ... then stretch it in ...
  myCropper.setTarget(0,0,300,100);   // ... an area of 300x100px

  myCropper.begin();
  // here, draw stuff that will be transformed, scaled and cropped by the cropper
  myCropper.end();
  
  myCropper.draw();
}


Fitmodes

There are three fit modes:

AlignModes

In the FIT and FILL mode, part of the selected source will have to be cropped. By default, the source is centered inside the target, but it can be placed at the top-left, bottom-center... Using this function:
	myCropper.setAlignMode(TOP_LEFT);


Available align modes:

Get this addon

HTTPS
SSH