当前位置: 首页>>代码示例>>C++>>正文


C++ TextLayout::addCenteredLine方法代码示例

本文整理汇总了C++中TextLayout::addCenteredLine方法的典型用法代码示例。如果您正苦于以下问题:C++ TextLayout::addCenteredLine方法的具体用法?C++ TextLayout::addCenteredLine怎么用?C++ TextLayout::addCenteredLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextLayout的用法示例。


在下文中一共展示了TextLayout::addCenteredLine方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

void RotatingCubeApp::setup()
{
	try {
		mCapture = Capture( 320, 240 );
		mCapture.start();
	}
	catch( CaptureExc &exc ) {
	    console() << "failed to initialize the webcam, what: " << exc.what() << std::endl;

	    // create a warning texture
		// if we threw in the start, we'll set the Capture to null
		mCapture.reset();
		
		TextLayout layout;
		layout.clear( Color( 0.3f, 0.3f, 0.3f ) );
		layout.setColor( Color( 1, 1, 1 ) );
		layout.setFont( Font( "Arial", 96 ) );
		layout.addCenteredLine( "No Webcam" );
		layout.addCenteredLine( "Detected" );
		mTexture = gl::Texture2d::create( layout.render() );
	}
	
	mCam.lookAt( vec3( 3, 2, -3 ), vec3( 0 ) );
	gl::enableDepthRead();
	gl::enableDepthWrite();
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:26,代码来源:RotatingBox.cpp

示例2: setup

void TextTestApp::setup()
{
    printFontNames();

#if defined( CINDER_COCOA_TOUCH )
    std::string normalFont( "Arial" );
    std::string boldFont( "Arial-BoldMT" );
    std::string differentFont( "AmericanTypewriter" );
#else
    std::string normalFont( "Arial" );
    std::string boldFont( "Arial Bold" );
    std::string differentFont( "Papyrus" );
#endif

    // Japanese
    unsigned char japanese[] = { 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC, 0xE8, 0xAA, 0x9E, 0 };
    // this does a complicated layout
    TextLayout layout;
    layout.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.2f ) );
    layout.setFont( Font( normalFont, 24 ) );
    layout.setColor( Color( 1, 1, 1 ) );
    layout.addLine( std::string( "Unicode: " ) + (const char*)japanese );
    layout.setColor( Color( 0.5f, 0.25f, 0.8f ) );
    layout.setFont( Font( boldFont, 12 ) );
    layout.addRightLine( "Now is the time" );
    layout.setFont( Font( normalFont, 22 ) );
    layout.setColor( Color( 0.75f, 0.25f, 0.6f ) );
    layout.append( " for all good men" );
    layout.addCenteredLine( "center justified" );
    layout.addRightLine( "right justified" );
    layout.setFont( Font( differentFont, 24 ) );
    layout.addCenteredLine( "A different font" );
    layout.setFont( Font( normalFont, 22 ) );
    layout.setColor( Color( 1.0f, 0.5f, 0.25f ) );
    layout.addLine( " • Point 1 " );
    layout.setLeadingOffset( -10 );
    layout.addLine( " • Other point with -10 leading offset " );
    layout.setLeadingOffset( 0 );
    layout.setColor( ColorA( 0.25f, 0.5f, 1, 0.5f ) );
    layout.addLine( " • Back to regular leading but translucent" );
    Surface8u rendered = layout.render( true, PREMULT );
    mTexture = gl::Texture( rendered );

    // Create a custom font by loading it from a resource
    Font customFont( Font( loadResource( RES_CUSTOM_FONT ), 72 ) );
    console() << "This font is called " << customFont.getFullName() << std::endl;

    TextLayout simple;
    simple.setFont( customFont );
    simple.setColor( Color( 1, 0, 0.1f ) );
    simple.addLine( "Cinder" );
    simple.addLine( "Font From Resource" );
    mSimpleTexture = gl::Texture( simple.render( true, PREMULT ) );
}
开发者ID:Jornason,项目名称:Cinder,代码行数:54,代码来源:TextTestApp.cpp

示例3: draw

void PathSimplificationApp::draw()
{
   	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
    
    cairo::SurfaceImage surface( getWindowWidth(), getWindowHeight());
    cairo::Context ctx( surface );
    
    // draw each path
    for(int i=0; i<mSmPaths.size(); i++){
        // pass the cairo context to draw onto
        drawPath(ctx, mSmPaths[i], drawMode);
    }
    
    // draw the surface
    gl::Texture myTexture = surface.getSurface();
    gl::draw(myTexture);
    
    
    TextLayout layout;
    layout.clear(ColorA(0.1f,0.1f,0.1f,0.7f));
    layout.setColor( Color( 0.9f, 0.9f, 0.9f ) );
    layout.setFont( Font( "Arial", 14 ) );
    
    
    SmoothPath* lastPath;
    if(mSmPaths.size() > 0){
        lastPath = mSmPaths[mSmPaths.size()-1];
    }
    
    if(mSmPaths.size() == 0){
        layout.addCenteredLine("Click and drag to draw a line.");
        layout.addCenteredLine("Press 'R' to clear.");
    }else if(mSmPaths.size() > 0 && lastPath->inProgress){
        int segCount = (lastPath->getPathPoints().size()>0) ? lastPath->getPathPoints().size()-1 : 0;
        layout.addCenteredLine( "Segment Count: " + boost::lexical_cast<std::string>(segCount));
    }else if(mSmPaths.size() > 0 && !lastPath->inProgress){
        int oldSegCount = (lastPath->getPathPoints().size()>0) ? lastPath->getPathPoints().size()-1 : 0;
        int segCount = lastPath->getCurrentPath().getNumSegments();
        int diff = oldSegCount - segCount;
        float per = (float(diff)/float(oldSegCount)) * 100.0f;
        string msg = boost::lexical_cast<std::string>(diff) + " of " + boost::lexical_cast<std::string>(oldSegCount) + " segments were removed. Saving " +boost::lexical_cast<std::string>(per) + "%";
        layout.addCenteredLine(msg);
    }
    
    
    Surface8u rendered = layout.render( true, PREMULT );
    mTextTexture = gl::Texture( rendered );
    
    if( mTextTexture )
		gl::draw( mTextTexture,  Vec2f(10, 10)  );
}
开发者ID:gregkepler,项目名称:CinderPathFitter,代码行数:52,代码来源:PathSimplificationApp.cpp

示例4: loadMovieFile

void QuickTimeSampleApp::loadMovieFile( const fs::path& moviePath )
{
	try {
		// load up the movie, set it to loop, and begin playing
		mMovie = qtime::MovieGl( moviePath );
		mMovie.setLoop();
		mMovie.play();
		
		// create a texture for showing some info about the movie
		TextLayout infoText;
		infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
		infoText.setColor( Color::white() );
		infoText.addCenteredLine( getPathFileName( moviePath.string() ) );
		infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" );
		infoText.addLine( toString( mMovie.getDuration() ) + " seconds" );
		infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" );
		infoText.addLine( toString( mMovie.getFramerate() ) + " fps" );
		infoText.setBorder( 4, 2 );
		mInfoTexture = gl::Texture( infoText.render( true ) );
	}
	catch( ... ) {
		console() << "Unable to load the movie." << std::endl;
		mMovie.reset();
		mInfoTexture.reset();
	}

	mFrameTexture.reset();
}
开发者ID:kevinbs,项目名称:Cinder-portfolio,代码行数:28,代码来源:quickTimeSample.cpp

示例5: loadMovieFile

void QuickTimeSampleApp::loadMovieFile( const fs::path &moviePath )
{
	try {
		// load up the movie, set it to loop, and begin playing
		mMovie = qtime::MovieGl::create( moviePath );
		mMovie->setLoop();
		mMovie->play();
		
		// create a texture for showing some info about the movie
		TextLayout infoText;
		infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
		infoText.setColor( Color::white() );
		infoText.addCenteredLine( moviePath.filename().string() );
		infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
		infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
		infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
		infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
		infoText.setBorder( 4, 2 );
		mInfoTexture = gl::Texture::create( infoText.render( true ) );
	}
	catch( ci::Exception &exc ) {
		console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
		mMovie.reset();
		mInfoTexture.reset();
	}

	mFrameTexture.reset();
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:28,代码来源:QuickTimeBasicApp.cpp

示例6: setTitle

void MenuObject::setTitle(string tit){
	title = tit;
	TextLayout layout;
	layout.setFont(Font(loadAsset("ArcadeClassic.ttf"), 60));
	layout.setColor(Color( 1.0f, 1.0f, 1.0f) );
	layout.clear(ColorA(1.0f, 1.0f, 1.0f, 0.0f));
	layout.addCenteredLine(title);
	renderedTitle = gl::Texture(layout.render(true, true));
}
开发者ID:davertron,项目名称:DAME,代码行数:9,代码来源:MenuObject.cpp

示例7: Font

Quake::Quake( float aLat, float aLong, float aMag, string aTitle )
{
	mLat	= aLat;
	mLong	= aLong;
	mMag	= aMag;
	mTitle	= aTitle;
	
	TextLayout layout;
	ostringstream os;
	os << mMag;
	if( os.str().length() == 1 ){
		os << ".0";
	}
	
	
	
	if( mMag > 5.5 ){
		layout.setFont( Font( "HelveticaNeue-Bold", mMag * mMag + 26.0f ) );
		layout.setColor( Color( 1, 0, 0 ) );
	} else {
		layout.setFont( Font( "HelveticaNeue-Bold", mMag * mMag + 10.0f ) );
		layout.setColor( Color( 1, 1, 1 ) );
	}
	layout.addCenteredLine( os.str() );
	
	
	if( mMag > 5.5 ){
		layout.setLeadingOffset( -10 );
		layout.setFont( Font( "HelveticaNeue", mMag + 16 ) );
		layout.setColor( Color( 1, 1, 1 ) );
		layout.addCenteredLine( mTitle );
	}
	

	mLabel = gl::Texture( layout.render( true ) );
	
	setLoc();
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:38,代码来源:Quake.cpp

示例8: saveFirst

void CatMemeMakerApp::saveFirst()
{
	TextLayout simple;

	std::string normalFont( "Arial" );

	simple.setFont( Font(normalFont,48) );
	simple.setColor( Color( 1, 1, 1 ) );
	simple.addCenteredLine(mMessage.str());

	mFirstLine = gl::Texture( simple.render( true , false ) );

	mMessage.str(" ");
}
开发者ID:foxmadnes,项目名称:CatMemeMaker,代码行数:14,代码来源:CatMemeMakerApp.cpp

示例9: setInfo

void ardroneApp::setInfo(const std::string& path, const std::string& errorMessage){
    // create a texture for showing some info about the movie
    TextLayout infoText;
    infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.25f ) );
    infoText.setColor( Color::white() );
    infoText.addCenteredLine( path);
    if (!errorMessage.empty()) {
        infoText.addLine(errorMessage);
    } else {
        infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
        if (mMovie->getDuration() > 0.f) infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
        infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
        infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
    }
    infoText.setBorder( 4, 2 );
    mInfoTexture = gl::Texture( infoText.render( true ) );
}
开发者ID:eighteight,项目名称:CinderEight,代码行数:17,代码来源:ardroneApp.cpp

示例10: onReadySignal

void MovieBasicApp::onReadySignal()
{    
	// create a texture for showing some info about the movie
	TextLayout infoText;
	infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
	infoText.setColor( Color::white() );
	infoText.addCenteredLine( mMoviePath.filename().string() );
	infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
	infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
	infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
	infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
	infoText.setBorder( 4, 2 );
	mInfoTexture = gl::Texture( infoText.render( true ) );

	mMovie->setVolume(1.0f);
	mMovie->play();
}
开发者ID:calebjohnston,项目名称:Cinder-AvfImpl,代码行数:17,代码来源:MovieBasiciOSApp.cpp

示例11: draw

void CatMemeMakerApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::enableAlphaBlending();

	//Check that the url fetch was successful
	if (mImage) {
		//Draw the Cat!
		mImage.enableAndBind();
		gl::draw( mImage, getWindowBounds() );
	}

	//If we are on the second line, write what we used to have for the first line up top
	if (mFirstLine) {
		gl::draw(mFirstLine,Vec2f( getWindowSize().x/2 - mFirstLine.getWidth()/2, 10 ));
	}

	//Render the texture with the message
	TextLayout simple;

	std::string normalFont( "Arial" );

	simple.setFont( Font(normalFont,48) );
	simple.setColor( Color( 1, 1, 1 ) );

	//White looked bad on the second line... so change to black if on second line
	if (mFirstLine) {
		simple.setColor( Color( 255, 255, 255 ) );
	}
	simple.addCenteredLine(mMessage.str());

	mTexture = gl::Texture( simple.render( true , false ) );

	//Draw the message, centered!
	if (mFirstLine) {
		gl::draw(mTexture,Vec2f( getWindowSize().x/2 - mTexture.getWidth()/2, getWindowSize().y -50));
	}
	else {
		gl::draw(mTexture,Vec2f( getWindowSize().x/2 - mTexture.getWidth()/2, 10 ));
	}
}
开发者ID:foxmadnes,项目名称:CatMemeMaker,代码行数:42,代码来源:CatMemeMakerApp.cpp

示例12: loadMovieFile

	void loadMovieFile( const std::string &moviePath )
	{
		glEnable(GL_TEXTURE_RECTANGLE_ARB);
		gl::Texture::Format format;
		format.setTargetRect();

		try {
			// load up the movie, set it to loop, and begin playing
			mMovie = qtime::MovieGl( moviePath );
			mMovie.setLoop();
//			mMovie.play();

			// create a texture for showing some info about the movie
			TextLayout infoText;
			infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
			infoText.setColor( Color::white() );
			infoText.addCenteredLine( getPathFileName( moviePath ) );
			infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" );
			infoText.addLine( toString( mMovie.getDuration() ) + " seconds" );
			infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" );
			infoText.addLine( toString( mMovie.getFramerate() ) + " fps" );
			infoText.setBorder( 4, 2 );
			mInfoTexture = gl::Texture( infoText.render( true ) );
			
			setWindowSize(mMovie.getWidth(), mMovie.getHeight());
			mHasMovie = true;
		}
		catch( ... ) {
			console() << "Unable to load the movie." << std::endl;
			mMovie.reset();
			mInfoTexture.reset();
			mHasMovie = false;
			//exit(1);
		}
		mFrameTexture.reset();
	}
开发者ID:toshinoritakata,项目名称:MeshWarp,代码行数:36,代码来源:MeshWarpApp.cpp

示例13: update

void ardroneApp::update()
{
	if( mMovie )
		mFrameTexture = mMovie->getTexture();

    float s = 0.02;
    
    if(keys[cinder::app::KeyEvent::KEY_UP]) drone.controller.pitchAmount -= s;
    else if(keys[cinder::app::KeyEvent::KEY_DOWN]) drone.controller.pitchAmount += s;
    
    if(keys['a']) drone.controller.rollAmount -= s;
    else if(keys['d']) drone.controller.rollAmount += s;
    
    if(keys['w']) drone.controller.liftSpeed += s;
    else if(keys['s']) drone.controller.liftSpeed -= s;
    
    if(keys[cinder::app::KeyEvent::KEY_LEFT]) drone.controller.spinSpeed -= s;
    else if(keys[cinder::app::KeyEvent::KEY_RIGHT]) drone.controller.spinSpeed += s;
    
    // update the drone (process and send queued commands to drone, receive commands from drone and update state
    drone.update();
    
    // update position of simulator (OPTIONAL)
    droneSimulator.update();
    
    TextLayout infoText;
    infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.25f ) );
    infoText.setColor( Color::white() );
//    infoText.addCenteredLine( path);
//    if (!errorMessage.empty()) {
//        infoText.addLine(errorMessage);
//    } else {
//        infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
//        if (mMovie->getDuration() > 0.f) infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
//        infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
//        infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
//    }
    infoText.setBorder( 4, 2 );


    
    string controllerString = "fps: " + toString(getFrameRate()) + "\n";
    controllerString += "millisSinceLastSend: " + toString(drone.controller.getMillisSinceLastSend()) + "\n";
    controllerString += "\n";
    controllerString += "takeOff (t)\n";
    controllerString += "land (l)\n";
    controllerString += "calibrateHorizontal (c)\n";
    controllerString += "calibrateMagnetometer (m)\n";
    controllerString += "EMERGENCY (E)\n";
    controllerString += "\n";
    controllerString += "roll (a/d)        : " + toString(drone.controller.rollAmount) + "\n";
    controllerString += "pitch (up/down)   : " + toString(drone.controller.pitchAmount) + "\n";
    controllerString += "lift (w/s)        : " + toString(drone.controller.liftSpeed) + "\n";
    controllerString += "spin (left/right) : " + toString(drone.controller.spinSpeed) + "\n";
    controllerString += "\n";
    controllerString += "reset droneSimulator (r)\n";
    controllerString += "debug history (h)\n";
    controllerString += "fullscreen (f)\n";
    controllerString += "PAUSE (p)\n";
    
    infoText.addCenteredLine( controllerString);
    
    ofxARDrone::State &state = drone.state;
    string stateString = "";
    stateString += "isFlying : " + toString(state.isFlying()) + "\n";
    stateString += "isTakingOff : " + toString(state.isTakingOff()) + ", " + toString(state.isTakingOffMillis()) + "\n";
    stateString += "isLanding : " + toString(state.isLanding()) + ", " + toString(state.isLandingMillis()) + "\n";
    stateString += "isCalibratingHorizontal : " + toString(state.isCalibratingHorizontal()) + ", " + toString(state.isCalibratingHorizontalMillis()) + "\n";
    stateString += "isCalibratingMagnetometer : " + toString(state.isCalibratingMagnetometer()) + ", " + toString(state.isCalibratingMagnetometerMillis()) + "\n";
    
    
    stateString += "\n\nisConnected: " + toString(state.isConnected()) + ", " + toString(state.isCalibratingMagnetometerMillis()) + "\n";
    stateString += "altitude: "+ toString(state.getAltitude())+"\n";
    stateString += "emergency state: "+ toString(state.inEmergencyMode())+"\n";
    stateString += "battery level: "+ toString(state.getBatteryPercentage())+"%\n";
    stateString += "vx: "+ toString(state.getVx())+" vy: "+ toString(state.getVy())+" vz: "+ toString(state.getVz())+"\n";
    
    infoText.addCenteredLine(stateString);
    mInfoTexture = gl::Texture( infoText.render( true ) );
}
开发者ID:eighteight,项目名称:CinderEight,代码行数:80,代码来源:ardroneApp.cpp


注:本文中的TextLayout::addCenteredLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。