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


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

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


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

示例1: 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

示例2: mIndex

Item::Item( int index, vec2 pos, const string &title, const string &desc, Surface palette )
	: mIndex(index), mTitle( title ), mDesc( desc ), mPalette(palette)
{
	// TODO: can you reuse layouts? If so, how do you clear the text?
	// textures
	TextLayout layout;
	layout.clear( ColorA( 1, 1, 1, 0 ) );
	layout.setFont( sSmallFont );
	layout.setColor( Color::white() );
	layout.addLine( mTitle );
	mTitleTex = gl::Texture::create( layout.render( true ) );
	
	TextLayout bigLayout;
	bigLayout.clear( ColorA( 1, 1, 1, 0 ) );
	bigLayout.setFont( sBigFont );
	bigLayout.setColor( Color::white() );
	bigLayout.addLine( mTitle );
	mTitleBigTex = gl::Texture::create( bigLayout.render( true ) );
	
	// title
	mTitleStart		= pos;
	mTitleDest1		= vec2( pos.x - 25.0f, pos.y );
	mTitleFinish	= vec2( pos.x - 4.0f, 120.0f );
	mTitleDest2		= vec2( mTitleFinish.x - 25.0f, mTitleFinish.y );
	mMouseOverDest	= mTitleStart + vec2( 7.0f, 0.0f );
	mTitlePos		= mTitleStart;
	mTitleColor		= Color( 0.7f, 0.7f, 0.7f );
	mTitleAlpha		= 1.0f;
	mTitleWidth		= mTitleTex->getWidth();
	mTitleHeight	= mTitleTex->getHeight();
	
	// desc
	mDescStart		= vec2( mTitleStart.x + 25.0f, mTitleFinish.y + mTitleBigTex->getHeight() + 5.0f );
	mDescDest		= vec2( mTitleStart.x + 35.0f, mDescStart.y );
	mDescPos		= mDescStart;
	mDescAlpha		= 0.0f;
	TextBox tbox	= TextBox().alignment( TextBox::LEFT ).font( sSmallFont ).size( ivec2( 650.0f, TextBox::GROW ) ).text( mDesc );
	mDescTex		= gl::Texture::create( tbox.render() );
	
	// bar
	mBarPos			= pos - vec2( 4.0f, 1.0f );
	mBarWidth		= 0.0f;
	mBarHeight		= mTitleHeight + 2.0f;
	mMaxBarWidth	= mTitleWidth + 22.0f;
	mBarColor		= Color::white();
	mBarAlpha		= 0.3f;
	
	mFadeFloat		= 1.0f;
	mIsSelected		= false;
	mIsBeingSelected = false;

	setColors();
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:53,代码来源:Item.cpp

示例3: drawText

void millionParticlesApp::drawText()
{
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    TextLayout layout;
    layout.setFont( Font( "Arial-BoldMT", 14 ) );
    layout.setColor( Color( 1.0f, 1.0f, 1.0f ) );
    layout.addLine( "1 Million Particles" );
    layout.addLine( " " );

    layout.setColor( Color( 0.9f, 0.9f, 0.9f ) );
    layout.setFont( Font( "ArialMT", 12 ) );

    layout.addLine("F - switch to fullscreen");
    layout.addLine("t - draw textures");

    char fps[50];
    sprintf(fps, "FPS: %.2f", getAverageFps());

    char particleCount[50];
    sprintf(particleCount, "Particles: %d", PARTICLES*PARTICLES);

    layout.addLine(fps);
    layout.addLine(particleCount);

    glEnable( GL_TEXTURE_2D );
    gl::draw(layout.render(true), Vec2f(getWindowWidth() - 150,25));
    glDisable( GL_TEXTURE_2D );
}
开发者ID:ThomasLengeling,项目名称:millionParticles,代码行数:29,代码来源:millionParticlesApp.cpp

示例4: draw

void ciApp::draw()
{
	gl::clear();

	gl::ScopedColor white(Color::white());

	auto get_center_rect = [&](Area area) ->Rectf { return Rectf(area).getCenteredFit(getWindowBounds(), true); };

	{	
		//auto tex = filter->getTexture();
		auto tex = vector_blur.getTexture();
		gl::draw(tex, get_center_rect(tex->getBounds()));
	}
	
	{
		gl::ScopedMatrices scpMatrix;
		gl::scale(0.2f, 0.2f);
		gl::draw(mTexture);
	}

	vector_blur.drawDebug(vec2(0, 0), 0.2f);

	mParams->draw();

	{
		TextLayout infoFps;
		infoFps.clear(ColorA(0.2f, 0.2f, 0.2f, 0.5f));
		infoFps.setColor(Color::white());
		infoFps.setFont(Font("Arial", 16));
		infoFps.setBorder(4, 2);
		infoFps.addLine("App Framerate: " + tostr(getAverageFps(), 1));
		auto tex = gl::Texture::create(infoFps.render(true));
		gl::draw(tex, ivec2(20, getWindowHeight() - tex->getHeight() - 20));
	}
}
开发者ID:shinabebel,项目名称:ci_blocks,代码行数:35,代码来源:ciApp.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( 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

示例6: setup

void CaptureApp::setup()
{	
	// list out the devices
	vector<Capture::DeviceRef> devices( Capture::getDevices() );
	for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
		Capture::DeviceRef device = *deviceIt;
		console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
		try {
			if( device->checkAvailable() ) {
				mCaptures.push_back( Capture::create( WIDTH, HEIGHT, device ) );
				mCaptures.back()->start();
			
				// placeholder text
				mTextures.push_back( gl::TextureRef() );

				// render the name as a texture
				TextLayout layout;
				layout.setFont( Font( "Arial", 24 ) );
				layout.setColor( Color( 1, 1, 1 ) );
				layout.addLine( device->getName() );
				mNameTextures.push_back( gl::Texture::create( layout.render( true ) ) );
			}
			else
				console() << "device is NOT available" << std::endl;
		}
		catch( CaptureExc & ) {
			console() << "Unable to initialize device: " << device->getName() << endl;
		}
	}
}
开发者ID:labatrockwell,项目名称:Cinder,代码行数:30,代码来源:CaptureAdvancedApp.cpp

示例7: 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

示例8: update

void SerialCommunicationApp::update()
{
	if (serialInitiallized()){
        if(serial.getNumBytesAvailable() > 0){
            console() << "Bytes available: " << serial.getNumBytesAvailable() << std::endl;
            try{
                lastString = serial.readStringUntil('\n');
            } catch(SerialTimeoutExc e) {
                console() << "timeout" << endl;
            }
            console() << lastString << endl;
            int16_t temp = lastString[0];
            
            //OSC MESSAGE
            osc::Message message;
            message.addIntArg(temp);
            message.setAddress("coinTrigger");
            message.setRemoteEndpoint(host, port);
            sender.sendMessage(message);
           
            TextLayout simple;
            simple.setFont( Font( "Arial Black", 54 ) );
            simple.setColor( Color( .7, .7, .2 ) );
            simple.addLine( lastString );
            simple.setLeadingOffset( 0 );
            mTexture = gl::Texture( simple.render( true, false ) );
            bTextureComplete = true;
            serial.flush();
        }
    }
    serial.flush();
}
开发者ID:dmelancon,项目名称:Prototypes,代码行数:32,代码来源:SerialCommunicationApp.cpp

示例9: normalFont

AccordionItem::AccordionItem( Timeline &timeline, float x, float y, float height, float contractedWidth, float expandedWidth, gl::Texture image, string title, string subtitle ) 
	: mTimeline(timeline), mX(x), mY(y), mWidth(contractedWidth), mHeight(height), mExpandedWidth(expandedWidth), mImage(image), mTitle(title), mSubtitle(subtitle)
{
#if defined( CINDER_COCOA )
	std::string normalFont( "Arial" );
	std::string boldFont( "Arial-BoldMT" );
#else
	std::string normalFont( "Arial" );
	std::string boldFont( "ArialBold" );
#endif
	
	mAnimEase = EaseOutAtan(25);
	mAnimDuration = 0.7f;
	
	mTextAlpha = 0.0f;
	
	TextLayout layout;
	layout.clear( ColorA( 0.6f, 0.6f, 0.6f, 0.0f ) );
	layout.setFont( Font( boldFont, 26 ) );
	layout.setColor( Color( 1, 1, 1 ) );
	layout.addLine( mTitle );
	layout.setFont( Font( normalFont, 16 ) );
	layout.addLine( mSubtitle );
	layout.setBorder(11, 6);
	mText = gl::Texture( layout.render( true ) );
	
	update();
}
开发者ID:ChadMcKinney,项目名称:Cinder,代码行数:28,代码来源:AccordionItem.cpp

示例10: keyDown

void SerialCommunicationApp::keyDown(KeyEvent event)
{
    //DEBUG 
    int16_t temp = 0;

    switch (event.getChar()) {
        case '1':
            temp = 49;
            break;
        case '2':
            temp = 50;
            break;
        case '3':
            temp = 51;
            break;
    }
    
    if (temp > 48 && temp < 52) {
        osc::Message message;
        //message.addStringArg(lastString);
        message.addIntArg(temp);
        message.setAddress("coinTrigger");
        message.setRemoteEndpoint(host, port);
        sender.sendMessage(message);
        TextLayout simple;
        simple.setFont( Font( "Arial Black", 54 ) );
        simple.setColor( Color( .7, .7, .2 ) );
        simple.addLine( to_string(event.getChar()) );
        simple.setLeadingOffset( 0 );
        mTexture = gl::Texture( simple.render( true, false ) );
        bTextureComplete = true;
    }
}
开发者ID:dmelancon,项目名称:Prototypes,代码行数:33,代码来源:SerialCommunicationApp.cpp

示例11: 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

示例12: createTextField

void Button::createTextField()
{
	TextLayout simple;
	simple.setFont( *textFont );	
	simple.setColor( Color::black());
	simple.addLine(Utils::cp1251_to_utf8(label.c_str()));		
	textTexture = gl::Texture( simple.render( true, false ) );	
}
开发者ID:20SecondsToSun,项目名称:KinectPoseRecognition,代码行数:8,代码来源:Button.cpp

示例13: 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

示例14: Surface

void HW2App::setup()
{
    //create surface
    mySurface_ = new Surface(1024,1024,false);
    // set variable to toggle help; credit for help screen layout to Markus Ernst (https://github.com/cluelesswalnut)
    help = 1;
    //set font of help
    font = Font( "", 14.0 );
    // set up text for the help
    text = new TextLayout();
    text->setFont(font);
    text->setColor( ColorA( 1.0f, 1.0f, 1.0f, 1.0f ) );
    text->addLine("Select a shape/layer to modify by using the following keys:");
    text->addLine("	q: Background");
    text->addLine("	w: Red Rectangle");
    text->addLine("	e: Green Rectangle");
    text->addLine("	r: Blue Rectangle");
    text->addLine("	t: Yellow Rectangle");
    text->addLine("	y: Purple Rectangle");
    text->addLine("Once a shape is selected:");
    text->addLine("	a: Moves the shape up in the list");
    text->addLine("	z: Moves the shape back in the list");
    text->addLine("	Arrow Keys: Move the shape around");
    text->addLine("Additional key commands:");
    text->addLine("	?: Toggle help menu");
    text->addLine("	f: Reverses layer list");
    // make a surface out of the text
    tex = text->render(true,true);

    //set initial selected shape
    shape = 'q';

    //create head of shape list
    lst = new node();
    temp = lst;
    //add the shapes in
    insertAfter(new node(pixelArray,0,0,640,480,Color8u(0, 0, 255)),temp,lst);
    background = lst->next;
    temp = temp->next;
    insertAfter(new node(pixelArray,100,100,100,100,Color8u(255, 0, 0)),temp,lst);
    temp = temp->next;
    rec1 = temp;
    insertAfter(new node(pixelArray,1,150,75,75,Color8u(0, 255, 0)),temp,lst);
    temp = temp->next;
    rec2 = temp;
    insertAfter(new node(pixelArray,300,10,80,80,Color8u(0, 125, 255)),temp,lst);
    temp = temp->next;
    rec3 = temp;
    insertAfter(new node(pixelArray,300,150,60,90,Color8u(255, 255, 0)),temp,lst);
    temp = temp->next;
    rec4 = temp;
    insertAfter(new node(pixelArray,500,10,125,125,Color8u(0, 255, 255)),temp,lst);
    rec5 = temp->next;

};
开发者ID:deckerbd,项目名称:HW2,代码行数:55,代码来源:HW02App.cpp

示例15: draw

void QRcode::draw()
{
	gl::pushMatrices();					
		gl::translate(startQRCodeHolderXY);
		gl::draw(qrCodeFon);

		if (isError)
		{
			drawError();			
		}
		else
		{
			if (isReady == false)
			{
				gl::pushMatrices();
					gl::translate(220, 650);	
					preloader.draw();			
				gl::popMatrices();
			}
			else
			{
				if(stringQrcode=="") return;
				//if (isRender == false)
				//{
					isRender = true;		
					qrCodeTexture = loadImageFromString(stringQrcode);

					TextLayout simple;
					simple.setFont( qrCodeFont );
					simple.setColor( Color( 1, 1, 1 ) );
					simple.addLine(url);
					qrCodeTextTexture = gl::Texture( simple.render( true, false ) );
				//}

				if(qrCodeTextTexture)
				{
					gl::pushMatrices();			
					gl::translate(33, 885);	
					gl::draw(qrCodeTextTexture);
					gl::popMatrices();
				}	

				if(qrCodeTexture)
				{
					gl::pushMatrices();			
					gl::translate(86, 505);		
					gl::draw(qrCodeTexture);
					gl::popMatrices();
				}

			}
		}

	gl::popMatrices();	
}
开发者ID:20SecondsToSun,项目名称:Funces,代码行数:55,代码来源:QRcode.cpp


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