Exemple #1
0
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 ) );
}
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();
}
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;
    }
}
void SerialCommunicationApp::update()
{
//	console() << "Bytes available: " << serial.getNumBytesAvailable() << std::endl;
	
	double now = getElapsedSeconds();
	double deltaTime = now - lastUpdate;
	lastUpdate = now;
	sinceLastRead += deltaTime;
	
	if(sinceLastRead > READ_INTERVAL)
	{
		bSendSerialMessage = true;
		sinceLastRead = 0.0;
	}
		
	
	if (bSendSerialMessage)
	{
		// request next chunk
		serial.writeByte(ctr);
		
		try{
			// read until newline, to a maximum of BUFSIZE bytes
			lastString = serial.readStringUntil('\n', BUFSIZE );

		} catch(SerialTimeoutExc e) {
			console() << "timeout" << endl;
		}
		
		
		bSendSerialMessage = false;
		
		ctr+=8;
		console() << lastString << endl;
		
		
		TextLayout simple;
		simple.setFont( Font( "Arial Black", 24 ) );
		simple.setColor( Color( .7, .7, .2 ) );
		simple.addLine( lastString );
		simple.setLeadingOffset( 0 );
		mTexture = gl::Texture( simple.render( true, false ) );
		bTextureComplete = true;
		
		serial.flush();
	}
}
void SerialCommunicationApp::update()
{
//	console() << "Bytes available: " << mSerial->getNumBytesAvailable() << std::endl;
	
	double now = getElapsedSeconds();
	double deltaTime = now - mLastUpdate;
	mLastUpdate = now;
	mLastRead += deltaTime;
	
	if( mLastRead > READ_INTERVAL )	{
		mSendSerialMessage = true;
		mLastRead = 0.0;
	}

	if( mSendSerialMessage ) {
		// request next chunk
		mSerial->writeByte( mCounter );
		
		try{
			// read until newline, to a maximum of BUFSIZE bytes
			mLastString = mSerial->readStringUntil( '\n', BUFSIZE );

		}
		catch( SerialTimeoutExc &exc ) {
			CI_LOG_EXCEPTION( "timeout", exc );
		}
		
		mSendSerialMessage = false;
		mCounter += 8;

		console() << "last string: " << mLastString << endl;
		
		TextLayout simple;
		simple.setFont( Font( "Arial Black", 24 ) );
		simple.setColor( Color( .7, .7, .2 ) );
		simple.addLine( mLastString );
		simple.setLeadingOffset( 0 );
		mTexture = gl::Texture::create( simple.render( true, false ) );

		mSerial->flush();
	}
}
Exemple #6
0
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();
}
Exemple #7
0
Star::Star( Vec3f pos, float appMag, float absMag, float color, std::string name, std::string spectrum, const Font &fontS, const Font &fontM )
	: mPos( pos ), mApparentMag( appMag ), mAbsoluteMag( absMag ), mColor( color ), mName( name )
{
	mInitPos		= mPos;
	mDistToMouse	= 1000.0f;
	mIsSelected		= false;
	mRadius			= ( 10.0f - mAbsoluteMag ) * 0.025f;
	mRadiusMulti	= 1.0f; // not implemented yet
	
	if( mName.length() > 1 && appMag < 6.0f ){
		TextLayout layout;
		layout.clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ) );
		layout.setFont( fontM );
		layout.setColor( Color( 1.0f, 1.0f, 1.0f ) );
		layout.addLine( name );
		layout.setFont( fontS );
		layout.setLeadingOffset( 3 );
		layout.addLine( spectrum );
		mNameTex = gl::Texture( layout.render( true, false ) );
		mSphere.setCenter( mPos );
		mSphere.setRadius( mRadius );
	}
}
void QTimeline::init()
{
    QTimeline::thisRef      = this;
    
    mApp                    = ci::app::App::get();
    
    registerCallbacks();
    
    // initialise AT LEAST one color for the menu color palette
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.86f, 0.18f, 0.11f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 1.00f, 0.34f, 0.00f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.86f, 0.62f, 0.00f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.00f, 0.65f, 0.58f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.45f, 0.60f, 0.00f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.50f, 0.50f, 0.50f, 1.0f ) );

    mTimeline = ci::Timeline::create();
    
    mTransportRect  = Rectf( 0, getWindowHeight() - TIMELINE_TRANSPORT_HEIGHT, getWindowWidth(), getWindowHeight() );
    
    mFontSmall              = ci::gl::TextureFont::create( ci::Font( "Helvetica", 12 ) );
    mFontMedium             = ci::gl::TextureFont::create( ci::Font( "Helvetica", 14 ) );
    mFontBig                = ci::gl::TextureFont::create( ci::Font( "Helvetica", 16 ) );
    
    mZoom                   = 1.0f;
    
    mIsVisible              = true;
    
    mMouseDragTimeBar       = false;
    mMouseOnTimeBar         = false;
    
    mSelectedMenu           = NULL;
    
    mCueManager             = new QTimelineCueManager();
    
    // create default track
    mTracks.push_back( QTimelineTrackRef( new QTimelineTrack( "track 0" ) ) );
    
    play( false, FREE_RUN );
    
    mRenderDebug            = true;
    
    mRenderHelp             = false;
    
    TextLayout layout;
	layout.clear( ColorA( 0.0f, 0.0f, 0.0f, 0.8f ) );
    layout.setBorder( 5, 5 );
	layout.setFont( ci::Font( "Helvetica", 12 ) );
	layout.setColor( Color( 0.0f, 0.8f, 0.8f ) );
    layout.setLeadingOffset( 3 );
	layout.addLine( "HELP\n\n" );
	layout.addLine( "? \t\t\t\t toggle help\n" );
	layout.addLine( "space_bar \t\t play/pause FREE RUN mode\n" );
	layout.addLine( "return \t\t\t play/pause CUE LIST mode\n" );
	layout.addLine( "delete \t\t\t set time to 0\n\n" );
    mHelpTex = gl::Texture( layout.render( true ) );
    
    updateTime();
    
    updateTimeWindow();

    // init BASS library
    BASS_Init( -1, 44100, 0, 0, NULL );
}