本文整理汇总了C++中ofRectangle::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ofRectangle::set方法的具体用法?C++ ofRectangle::set怎么用?C++ ofRectangle::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofRectangle
的用法示例。
在下文中一共展示了ofRectangle::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void ofCairoRenderer::setup(string _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle _viewport){
if( _viewport.width == 0 || _viewport.height == 0 ){
_viewport.set(0, 0, ofGetWidth(), ofGetHeight());
}
filename = _filename;
type = _type;
streamBuffer.clear();
if(type == FROM_FILE_EXTENSION){
string ext = ofFilePath::getFileExt(filename);
if(ofToLower(ext)=="svg"){
type = SVG;
}else if(ofToLower(ext)=="pdf"){
type = PDF;
}else{ // default to image
type = IMAGE;
}
}
switch(type){
case PDF:
if(filename==""){
surface = cairo_pdf_surface_create_for_stream(&ofCairoRenderer::stream_function,this,_viewport.width, _viewport.height);
}else{
surface = cairo_pdf_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height);
}
break;
case SVG:
if(filename==""){
surface = cairo_svg_surface_create_for_stream(&ofCairoRenderer::stream_function,this,_viewport.width, _viewport.height);
}else{
surface = cairo_svg_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height);
}
break;
case IMAGE:
imageBuffer.allocate(_viewport.width, _viewport.height, 4);
surface = cairo_image_surface_create_for_data(imageBuffer.getPixels(),CAIRO_FORMAT_ARGB32,_viewport.width, _viewport.height,_viewport.width*4);
break;
case FROM_FILE_EXTENSION:
ofLogFatalError("ofCairoRenderer") << "Type not determined from file extension!";
break;
default:
ofLogError("ofCairoRenderer") << "Unknown type encountered!";
break;
}
cr = cairo_create(surface);
cairo_set_antialias(cr,CAIRO_ANTIALIAS_SUBPIXEL);
viewportRect = _viewport;
viewport(viewportRect);
page = 0;
b3D = b3D_;
multiPage = multiPage_;
setStyle(ofGetStyle());
}
示例2: setup
//-----------------------------------------------------------------------------------
void ofxCairoTexture::setup(bool b3D_, ofRectangle viewport_){
if( viewport_.width == 0 || viewport_.height == 0 ){
viewport_.set(0, 0, ofGetWidth(), ofGetHeight());
}
//printf("ofxCairoTexture::setup %f %f\n", viewport_.width, viewport_.height);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, viewport_.width, viewport_.height);
cr = cairo_create (surface);
viewportRect = viewport_;
viewport(viewportRect);
b3D = b3D_;
}
示例3: setup
void ofCairoRenderer::setup(string filename, Type type, bool multiPage_, bool b3D_, ofRectangle _viewport){
if( _viewport.width == 0 || _viewport.height == 0 ){
_viewport.set(0, 0, ofGetWidth(), ofGetHeight());
}
switch(type){
case PDF:
surface = cairo_pdf_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height);
break;
case SVG:
surface = cairo_svg_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height);
break;
}
cr = cairo_create(surface);
viewportRect = _viewport;
viewport(viewportRect);
page = 0;
b3D = b3D_;
multiPage = multiPage_;
}
示例4: setup
void ofCairoRenderer::setup(string _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle _viewport){
if( _viewport.width == 0 || _viewport.height == 0 ){
_viewport.set(0, 0, ofGetViewportWidth(), ofGetViewportHeight());
}
filename = _filename;
type = _type;
streamBuffer.clear();
if(type == FROM_FILE_EXTENSION){
string ext = ofFilePath::getFileExt(filename);
if(ofToLower(ext)=="svg"){
type = SVG;
}else if(ofToLower(ext)=="pdf"){
type = PDF;
}else{ // default to image
type = IMAGE;
}
}
if(filename != "") {
switch(type) {
case PDF:
case SVG:
case IMAGE:
ofFilePath::createEnclosingDirectory(filename);
case FROM_FILE_EXTENSION:
break;
}
}
switch(type){
case PDF:
if(filename==""){
surface = cairo_pdf_surface_create_for_stream(&ofCairoRenderer::stream_function,this,_viewport.width, _viewport.height);
}else{
surface = cairo_pdf_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height);
}
break;
case SVG:
if(filename==""){
surface = cairo_svg_surface_create_for_stream(&ofCairoRenderer::stream_function,this,_viewport.width, _viewport.height);
}else{
surface = cairo_svg_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height);
}
break;
case IMAGE:
imageBuffer.allocate(_viewport.width, _viewport.height, OF_PIXELS_BGRA);
imageBuffer.set(0);
surface = cairo_image_surface_create_for_data(imageBuffer.getData(),CAIRO_FORMAT_ARGB32,_viewport.width, _viewport.height,_viewport.width*4);
break;
case FROM_FILE_EXTENSION:
ofLogFatalError("ofCairoRenderer") << "setup(): couldn't determine type from extension for filename: \"" << _filename << "\"!";
break;
default:
ofLogError("ofCairoRenderer") << "setup(): encountered unknown type for filename \"" << _filename << "\"";
break;
}
cr = cairo_create(surface);
cairo_set_antialias(cr,CAIRO_ANTIALIAS_SUBPIXEL);
viewportRect = _viewport;
originalViewport = _viewport;
viewport(viewportRect);
page = 0;
b3D = b3D_;
multiPage = multiPage_;
}
示例5: setup
void Controller::setup(ofTexture * texture, ofVec2f originalSize, ofRectangle originalCoordinates, ofPoint originalPerspective[4], string name, float guiWidth, float guiHeight ){
// Arguments
this->texture = texture;
this->name = name;
this->guiWidth = guiWidth;
this->guiHeight = guiHeight;
if(originalSize.x==0.0
&& originalSize.y==0.0){
originalSize.set(texture->getWidth(), texture->getHeight());
}
this->originalSize = originalSize;
if(originalCoordinates.x==0.0
&& originalCoordinates.y==0.0
&& originalCoordinates.width==0.0
&& originalCoordinates.height==0.0){
if(ofGetUsingNormalizedTexCoords())originalCoordinates.set(0.0, 0.0, 1.0, 1.0);
else originalCoordinates.set(0.0, 0.0, texture->getWidth(), texture->getHeight());
}
this->originalCoordinates = originalCoordinates;
if(originalPerspective[0].x == 0 && originalPerspective[0].y == 0
&& originalPerspective[1].x == 0 && originalPerspective[1].y == 0
&& originalPerspective[2].x == 0 && originalPerspective[2].y == 0
&& originalPerspective[3].x == 0 && originalPerspective[3].y == 0){
originalPerspective[0].x = ofGetWidth()/2 - texture->getWidth()/2;
originalPerspective[0].y = ofGetHeight()/2 - texture->getHeight()/2;
originalPerspective[1].x = ofGetWidth()/2 + texture->getWidth()/2;
originalPerspective[1].y = ofGetHeight()/2 - texture->getHeight()/2;
originalPerspective[2].x = ofGetWidth()/2 + texture->getWidth()/2;
originalPerspective[2].y = ofGetHeight()/2 + texture->getHeight()/2;
originalPerspective[3].x = ofGetWidth()/2 - texture->getWidth()/2;
originalPerspective[3].y = ofGetHeight()/2 + texture->getHeight()/2;
}
memcpy(this->originalPerspective,originalPerspective,sizeof(ofPoint)*4);
// Register draw event for the enable/disable magic
ofAddListener(ofEvents().draw, this, &Controller::drawEvent);
drawing = false;
drawn = true;
// Some intial setup
guiHelperFbo.allocate(150, 60);
blendB = blendL = blendR = blendT = 0;
lastClickTime = ofGetElapsedTimeMillis();
historyIndex = -1;
guiHasChanged = false;
perspectiveHasChanged = false;
// Generate filenames
safename = safe_string(name);
stringstream ss_guiFile;
ss_guiFile << safename << "/gui.xml";
guiFile = ss_guiFile.str();
stringstream ss_perspectiveFile;
ss_perspectiveFile << safename << "/perspective.xml";
perspectiveFile = ss_perspectiveFile.str();
stringstream ss_meshFile;
ss_meshFile << safename << "/mesh";
meshFile = ss_meshFile.str();
// Perspective
perspective.setup(0, 0, getWindowWidth(), getWindowHeight());
perspective.setCornerSensibility(0.03);
perspective.activate();
ofAddListener(perspective.changeEvent, this, &Controller::onPerspectiveChange);
// Meshes
controlMesh.setMode(OF_PRIMITIVE_POINTS);
internalMesh.setMode(OF_PRIMITIVE_TRIANGLES);
// GUI
gui.setup(name, guiFile,guiWidth, guiHeight);
gui.setPosition(originalPerspective[0].x, originalPerspective[0].y);
ofxButton * load = new ofxButton();
load->setup("Load", guiWidth, guiHeight);
load->addListener(this, &Controller::onLoad);
gui.add(load);
ofxButton * save = new ofxButton();
save->setup("Save", guiWidth, guiHeight);
save->addListener(this, &Controller::onSave);
gui.add(save);
ofxToggle * enablePerspective = new ofxToggle();
enablePerspective->setup("Perspective Warp", true, guiWidth, guiHeight);
enablePerspective->addListener(this, &Controller::onEnablePerspective);
gui.add(enablePerspective);
ofxButton * resetPerspective = new ofxButton();
resetPerspective->setup("Reset Perspective", guiWidth, guiHeight);
resetPerspective->addListener(this, &Controller::onResetPerspective);
gui.add(resetPerspective);
ofxButton * resetMesh = new ofxButton();
resetMesh->setup("Reset Mesh", guiWidth, guiHeight);
resetMesh->addListener(this, &Controller::onResetMesh);
gui.add(resetMesh);
//.........这里部分代码省略.........