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(); }
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(); }
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(); }
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(); }
void MovieLoaderApp::movieReady() { 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.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 ) ); }
void CinderIldaApp::update() { mLaserDac->setPoints(mIldaFrame); // mLaserDac->send(); float fps = getFrameRate(); TextLayout simple; simple.setFont( mFont ); simple.setColor( Color( 1, 1, 1 ) ); simple.addLine( "CinderIlda" ); simple.addLine( "Framerate: " + toString((int)fps) ); mTexture = gl::Texture( simple.render( true, PREMULT ) ); }
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)); } }
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; } } }
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 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 ) ); }
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 ) ); }
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(); }
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(); }
void FrownLogoParticlesApp::setup() { mKeyPressed = false; // Lets load a font from the the installed fonts of the OS // and set its size to 90 mFont = Font("Arial",90 ); //Clear the layout to black mLayout.clear(Color::black() ); //Set the text color of the layout mLayout.setColor(Color(1,1,1)); //Set the font of the layout mLayout.setFont(mFont); //Add the following line to the layout mLayout.addLine("FROWN"); //Render the layout into a cinder Surface mSurface = mLayout.render(); //We will now iterate through every pixel in the surface: //First get the iterator Surface::Iter iter = mSurface.getIter(); // For every line in the surface // while ( iter.line() ) { // For every pixel in the line while (iter.pixel()) { //Check if the color of the current pixel is not black if ( ( iter.r() != 0.0f ) && ( iter.g() != 0.0f ) && ( iter.b() != 0.0f ) ) { //If its not black, push the position of the pixel into // the initial positions mInitialPositions.push_back(ci::Vec2f(iter.x(), iter.y())); // Also, lets make the current positions equal to the initial // ones mCurrentPositions.push_back(ci::Vec2f(iter.x(), iter.y())); //lets also keep the color of every pixel mPixelColors.push_back(Colorf(iter.r(), iter.g(), iter.b())); } } } //Print the size of non-black pixels found in the surface console() << "We found " << mInitialPositions.size() << " non black pixels" << endl; console() << "Spacebar changes: explode /move back" << endl; console() << "P or p changes: whether the particles are paused or not" << endl; }
void Button::setBtnId(string value) { if (isTextField ) { code = value; TextLayout simple; simple.setFont( *textFont ); simple.setColor(Color::black()); simple.addLine(Utils::cp1251_to_utf8(value.c_str())); textTexture = gl::Texture( simple.render( true, false ) ); } }
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 ); }
void Utils::textFieldDraw(std::string text,Font font, Vec2f coords, ColorA color) { gl::pushMatrices(); gl::translate(coords); TextLayout simple; simple.clear(ColorA(1,1,1,0)); simple.setFont( font ); simple.setColor(color ); simple.addLine(cp1251_to_utf8(text.c_str())); gl::draw(gl::Texture( simple.render( true, false ) )); gl::popMatrices(); }
gl::TextureRef make_tex(std::string const& line) { TextLayout layout; layout.setFont( Font( "Arial", 32 ) ); layout.setColor( Color( 1, 1, 0 ) ); layout.addLine( line ); //if (stat_ == stat::over) { // //layout.addLine( std::string("synths: ") ); //} else if (stat_ == stat::pause) { // layout.addLine( std::string("Pause") ); //} return gl::Texture::create( layout.render( true ) ); }
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 ScrollingLabel::updateTexture() { if (mText == "") { mTexture.reset(); } else { TextLayout layout; layout.setFont( mFont ); layout.setColor( mColor ); layout.addLine( mText ); bool PREMULT = false; mTexture = gl::Texture( layout.render( true, PREMULT ) ); } }
SceneInIsInside::SceneInIsInside() { mmgr = make_shared<MovieManager>(); mmgr->addMovie("innen.mp4", getWindowWidth()*0.5, getWindowHeight()*0.5, getWindowWidth(), getWindowHeight()); std::string arial("Arial"); TextLayout simple; simple.setFont(Font(arial, 16)); simple.setColor(Color(1, 1, 1)); simple.addLine("SceneInIsInside"); text = gl::Texture2d::create(simple.render(true, PREMULT)); }
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(); }
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 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 ) ); }
EaseBox( std::function<float (float)> fn, string name ) : mFn( fn ) { // create label TextLayout text; text.clear( Color::white() ); text.setColor( Color(0.5f, 0.5f, 0.5f) ); try { text.setFont( Font( "Futura-CondensedMedium", 18 ) ); } catch( ci::Exception &exc ) { CI_LOG_W( "failed to load specified font, what: " << exc.what() ); text.setFont( Font( "Arial", 18 ) ); } text.addLine( name ); mLabelTex = gl::Texture::create( text.render( true ) ); }
void VSyncTest::draw() { // start all timers for(auto t : timers) { t->renderStart(); } gl::clear(Color::black()); gl::color(Color::white()); std::string str; str += kVersionString + "\n"; str += FrameTimerBase::getTimeStr() + "\n"; str += "\n"; // add all text for(auto t : timers) { str += t->getResolutionStr()+ "\n"; str += t->getStatsDetailedStr() + "\n"; str += "\n"; } // draw text TextLayout textLayout; textLayout.clear(Color(Color::black())); textLayout.setFont(Font("Arial", 18)); textLayout.setColor(Color::white()); textLayout.addLine(str); gl::draw( gl::Texture2d::create( textLayout.render( true, true) ), vec2( 10, 10 ) ); // log CI_LOG_I(FrameTimerBase::getTimeStr()); for(auto t : timers) { CI_LOG_I(t->getStatsCompactStr()); } // end all timers for(auto t : timers) { t->renderEnd(); } }
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(); } }
void InfoPanel::createTexture() { TextLayout layout; layout.setFont( Font( "Arial-BoldMT", 14 ) ); layout.setColor( Color( 1.0f, 1.0f, 0.0f ) ); layout.addLine( "Hodgin Particles Redux" ); layout.setFont( Font( "ArialMT", 10 ) ); layout.setColor( Color( 1.0f, 0.7f, 0.0f ) ); layout.addLine( "click and drag to create particles" ); layout.setColor( Color( 0.5f, 0.2f, 0.0f ) ); layout.addLine( "C toggle constraints (floor plane)" ); layout.addLine( "Q render particle quads" ); layout.addLine( "T render particle trail" ); layout.addLine( "P toggle perlin noise force" ); layout.addLine( "G toggle gravitational force" ); layout.addLine( "F toggle fullscreen" ); layout.addLine( "? toggle information panel" ); mTexture = gl::Texture( layout.render( true ) ); }
void EmailForm::drawAdditionEmails() { if (emailVector.size() == 0 ) return; for (size_t i = 0, ilen = emailVector.size(); i < ilen; i++) { TextLayout simple; simple.setFont( emailAddFont ); simple.setColor( Color::white()); simple.addLine(emailVector[i]); gl::Texture textTexture = gl::Texture( simple.render( true, false ) ); gl::color(Color::white()); gl::pushMatrices(); gl::translate(Vec2f(393.0f + 1108.0f -textTexture.getWidth() ,246.0f + i *(textTexture.getHeight() + 3.0f))); gl::draw(textTexture); gl::popMatrices(); } }