Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
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();	
}
Exemplo n.º 4
0
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();
}
Exemplo n.º 5
0
static const TextLayout layoutTooltipText (const String& text) throw()
{
    const float tooltipFontSize = 11.0f;
    const int maxToolTipWidth = 400;

    const Font f (tooltipFontSize, Font::plain);
    TextLayout tl (text, f);
    tl.layout (maxToolTipWidth, Justification::left, true);

    return tl;
}
Exemplo n.º 6
0
void AttributedString::draw (Graphics& g, const Rectangle<float>& area) const
{
    if (text.isNotEmpty() && g.clipRegionIntersects (area.getSmallestIntegerContainer()))
    {
        if (! g.getInternalContext()->drawTextLayout (*this, area))
        {
            TextLayout layout;
            layout.createLayout (*this, area.getWidth());
            layout.draw (g, area);
        }
    }
}
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 ) );	
	}
}
Exemplo n.º 9
0
    static TextLayout layoutTooltipText (const String& text, const Colour& colour) noexcept
    {
        const float tooltipFontSize = 13.0f;
        const int maxToolTipWidth = 400;

        AttributedString s;
        s.setJustification (Justification::centred);
        s.append (text, Font (tooltipFontSize, Font::bold), colour);

        TextLayout tl;
        tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth);
        return tl;
    }
Exemplo n.º 10
0
	value lime_text_layout_position (value textHandle, value fontHandle, value size, value textString, value data) {
		
		#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
		
		TextLayout *text = (TextLayout*)(intptr_t)val_float (textHandle);
		Font *font = (Font*)(intptr_t)val_float (fontHandle);
		ByteArray bytes = ByteArray (data);
		text->Position (font, val_int (size), val_string (textString), &bytes);
		
		#endif
		
		return alloc_null ();
		
	}
Exemplo n.º 11
0
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(" ");
}
Exemplo n.º 12
0
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 ) );
}
Exemplo n.º 13
0
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 ) );        
    }
}
Exemplo n.º 14
0
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));
}
Exemplo n.º 15
0
	value lime_text_layout_position (value textHandle, value fontHandle, int size, HxString textString, value data) {
		
		#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
		
		TextLayout *text = (TextLayout*)val_data (textHandle);
		Font *font = (Font*)val_data (fontHandle);
		Bytes bytes;
		bytes.Set (data);
		text->Position (font, size, textString.__s, &bytes);
		return bytes.Value ();
		
		#endif
		
		return alloc_null ();
		
	}
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)  );
}
    void createLayout (TextLayout& layout, const AttributedString& text, IDWriteFactory& directWriteFactory,
                       ID2D1Factory& direct2dFactory, IDWriteFontCollection& fontCollection)
    {
        // To add color to text, we need to create a D2D render target
        // Since we are not actually rendering to a D2D context we create a temporary GDI render target

        D2D1_RENDER_TARGET_PROPERTIES d2dRTProp = D2D1::RenderTargetProperties (D2D1_RENDER_TARGET_TYPE_SOFTWARE,
                                                                                D2D1::PixelFormat (DXGI_FORMAT_B8G8R8A8_UNORM,
                                                                                                   D2D1_ALPHA_MODE_IGNORE),
                                                                                0, 0,
                                                                                D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE,
                                                                                D2D1_FEATURE_LEVEL_DEFAULT);
        ComSmartPtr<ID2D1DCRenderTarget> renderTarget;
        HRESULT hr = direct2dFactory.CreateDCRenderTarget (&d2dRTProp, renderTarget.resetAndGetPointerAddress());

        ComSmartPtr<IDWriteTextLayout> dwTextLayout;

        if (! setupLayout (text, layout.getWidth(), layout.getHeight(), *renderTarget,
                           directWriteFactory, fontCollection, dwTextLayout))
            return;

        UINT32 actualLineCount = 0;
        hr = dwTextLayout->GetLineMetrics (nullptr, 0, &actualLineCount);

        layout.ensureStorageAllocated (actualLineCount);

        {
            ComSmartPtr<CustomDirectWriteTextRenderer> textRenderer (new CustomDirectWriteTextRenderer (fontCollection, text));
            hr = dwTextLayout->Draw (&layout, textRenderer, 0, 0);
        }

        HeapBlock<DWRITE_LINE_METRICS> dwLineMetrics (actualLineCount);
        hr = dwTextLayout->GetLineMetrics (dwLineMetrics, actualLineCount, &actualLineCount);
        int lastLocation = 0;
        const int numLines = jmin ((int) actualLineCount, layout.getNumLines());
        float yAdjustment = 0;
        const float extraLineSpacing = text.getLineSpacing();

        for (int i = 0; i < numLines; ++i)
        {
            TextLayout::Line& line = layout.getLine (i);
            line.stringRange = Range<int> (lastLocation, (int) lastLocation + dwLineMetrics[i].length);
            line.lineOrigin.y += yAdjustment;
            yAdjustment += extraLineSpacing;
            lastLocation += dwLineMetrics[i].length;
        }
    }
Exemplo n.º 18
0
    AboutPage()
    {
        logo = ImageCache::getFromMemory (BinaryData::jules_jpg, BinaryData::jules_jpgSize);

        text1.appendText ("Programmer Julian Storer, seen here demonstrating a beard designed to "
                          "gain approval from the Linux programming community. Each hair of the beard "
                          "represents one line of source code from the ", Font (13.0f));
        text1.appendText ("Jucer", Font (13.0f, Font::bold));
        text1.appendText (" component design tool.", Font (13.0f));

        text2.appendText ("Jucer v" + JUCEApplication::getInstance()->getApplicationVersion()
                            + ", " + SystemStats::getJUCEVersion(), Font (14.0f, Font::bold));

        addAndMakeVisible (link = new HyperlinkButton ("www.rawmaterialsoftware.com/juce",
                                                       URL ("http://www.rawmaterialsoftware.com/juce")));
        link->setFont (Font (10.0f, Font::bold | Font::underlined), true);
    }
Exemplo n.º 19
0
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));
	}
}
Exemplo n.º 20
0
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();
}
Exemplo n.º 21
0
void CabbageIDELookAndFeel::drawAlertBox (Graphics& g,
                                          AlertWindow& alert,
                                          const Rectangle<int>& textArea,
                                          TextLayout& textLayout)
{
    g.fillAll (CabbageSettings::getColourFromValueTree (colourTree, CabbageColourIds::alertWindowBackground, Colour (Colour::fromString("2ff52636a"))));

    int iconSpaceUsed = 160;

    if (alert.getAlertType() != AlertWindow::NoIcon)
    {
        Path icon;

        if (alert.getAlertType() == AlertWindow::WarningIcon)
        {
            Rectangle<float> rect (alert.getLocalBounds().removeFromLeft (iconSpaceUsed).toFloat());

            const Image warningImage = ImageCache::getFromMemory (CabbageBinaryData::WarningIcon_png, CabbageBinaryData::WarningIcon_pngSize);
            //g.drawImage(warningImage, rect.reduced(20));
        }

        if (alert.getAlertType() == AlertWindow::QuestionIcon)
        {
            Rectangle<float> rect (alert.getLocalBounds().removeFromLeft (iconSpaceUsed - 20).toFloat());
            const Image warningImage = ImageCache::getFromMemory (CabbageBinaryData::WarningIcon_png, CabbageBinaryData::WarningIcon_pngSize);
            //g.drawImage(warningImage, rect.reduced(25));
        }

        MemoryInputStream svgStream (CabbageBinaryData::processstop_svg, CabbageBinaryData::processstop_svgSize, false);
        ScopedPointer<XmlElement> svg (XmlDocument::parse (svgStream.readString()));

        if (svg == nullptr)
            jassert (false);

        ScopedPointer<Drawable> drawable;

        if (svg != nullptr)
        {
            drawable = Drawable::createFromSVG (*svg);
            Rectangle<float> rect (20, 20, 80, 80);//alert.getLocalBounds().removeFromLeft (iconSpaceUsed - 20).withHeight(130).toFloat());
            drawable->setTransformToFit (rect, RectanglePlacement::stretchToFit);
            drawable->draw (g, 1.f, AffineTransform());
        }
    }


    g.setColour (alert.findColour (AlertWindow::textColourId));
    textLayout.draw (g, Rectangle<int> (textArea.getX() + iconSpaceUsed - 50,
                                        textArea.getY(),
                                        textArea.getWidth() - iconSpaceUsed - 40,
                                        textArea.getHeight()).toFloat());

    g.setColour (alert.findColour (AlertWindow::outlineColourId));
    g.drawRect (0, 0, alert.getWidth(), alert.getHeight());
}
Exemplo n.º 22
0
void CtrlrLuaMethodEditorTabsLF::createTabTextLayout (const TabBarButton& button, float length, float depth, Colour colour, TextLayout& textLayout)
{
    Font font (12.0f);
    font.setUnderline (button.hasKeyboardFocus (false));

    AttributedString s;
    s.setJustification (Justification::centred);
    s.append (button.getButtonText().trim(), font, colour);

    textLayout.createLayout (s, length);
}
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();
}
Exemplo n.º 24
0
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();				
	}
}
Exemplo n.º 25
0
void LookAndFeel_E1::createTabTextLayout (const TabBarButton& button, float length, float depth,
                                          Colour colour, TextLayout& textLayout)
{
    Font font (depth * 0.5f);
    font.setUnderline (button.hasKeyboardFocus (false));

    AttributedString s;
    s.setJustification (Justification::centred);
    s.append (button.getButtonText().trim(), font, colour);

    textLayout.createLayout (s, length);
}
Exemplo n.º 26
0
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();
}
Exemplo n.º 27
0
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;
    }
}
Exemplo n.º 28
0
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 createLayout (TextLayout& layout, const AttributedString& text,
                       IDWriteFactory& directWriteFactory,
                       IDWriteFontCollection& fontCollection,
                       ID2D1DCRenderTarget& renderTarget)
    {
        ComSmartPtr<IDWriteTextLayout> dwTextLayout;

        if (! setupLayout (text, layout.getWidth(), layout.getHeight(), renderTarget,
                           directWriteFactory, fontCollection, dwTextLayout))
            return;

        UINT32 actualLineCount = 0;
        HRESULT hr = dwTextLayout->GetLineMetrics (nullptr, 0, &actualLineCount);

        layout.ensureStorageAllocated (actualLineCount);

        {
            ComSmartPtr<CustomDirectWriteTextRenderer> textRenderer (new CustomDirectWriteTextRenderer (fontCollection, text));
            hr = dwTextLayout->Draw (&layout, textRenderer, 0, 0);
        }

        HeapBlock<DWRITE_LINE_METRICS> dwLineMetrics (actualLineCount);
        hr = dwTextLayout->GetLineMetrics (dwLineMetrics, actualLineCount, &actualLineCount);
        int lastLocation = 0;
        const int numLines = jmin ((int) actualLineCount, layout.getNumLines());
        float yAdjustment = 0;
        const float extraLineSpacing = text.getLineSpacing();

        for (int i = 0; i < numLines; ++i)
        {
            TextLayout::Line& line = layout.getLine (i);
            line.stringRange = Range<int> (lastLocation, (int) lastLocation + dwLineMetrics[i].length);
            line.lineOrigin.y += yAdjustment;
            yAdjustment += extraLineSpacing;
            lastLocation += dwLineMetrics[i].length;
        }
    }
Exemplo n.º 30
0
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));
}