예제 #1
0
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();
}
예제 #2
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();
}
예제 #3
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();
}
예제 #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();
}
예제 #5
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();
}
예제 #6
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));
	}
}
예제 #7
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));
}
예제 #8
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 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 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)  );
}
예제 #11
0
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();	

}
예제 #12
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 ) );
}
예제 #13
0
	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 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();
}
예제 #15
0
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 ) );
}
예제 #16
0
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();
	}
}
예제 #17
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 );
	}
}
예제 #18
0
	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();
	}
예제 #19
0
void RecipeView::update(){
    
    
    //console() << ":::TIMED OUT:::" << endl;
    if((curStep==0 && stepState==0) || stepState==1){
        // it's already at the start, or if it's on a video...
        delayTimeOut();
    } else {
        double curTime = getElapsedSeconds();
        if((curTime-lastTouched)>timeOut){
            console() << "going to start: " << recipeModel.name << endl;
            goStart();
        }
    }
    
    
      for(int i=0;i<videos.size();i++){
        if(i!=curStep){
                      // videos.at(i).stop();
        }
    }
    if(stepState==1){
        if(videos.size()>curStep){
            videos.at(curStep).update();
            if(videos.at(curStep).isDone()) forwardRelease();
        }
    }
    
    char buffer [40];
    sprintf (buffer, "curStep: %i \n stepState: %i", curStep, stepState);
    TextLayout layout;
	layout.clear( ColorA( 0.5f, 0.5f, 0.5f, 0.5f ) );
	layout.setFont( Font( "Arial", 18 ) );
	layout.setColor( Color( 1, 1, 1 ) );
    layout.addLine(recipeModel.name.c_str());
	layout.addLine( buffer);
	Surface8u rendered = layout.render( true, false );
    text_texture = gl::Texture( rendered );
    
    
    // this needs work here....
    // this is specifically to handle a goStart() situation...
    if(prevStepState==0 && stepState == 0 && prevStep!=curStep){
        console() << "THIS SHOULD BE FIRING on TIMEOUT >>> " << recipeModel.name << endl;
        if(images.size()>prevStep) images.at(prevStep).hide();
        if(images.size()>curStep) images.at(curStep).show();
        prevStep = curStep;
        
    } else {
        
    if(prevStep!=curStep){
        // moved from video to new start image
        // load both the image and the video for the new step
       if(prevStep>-1) videos.at(prevStep).stop();
        prevStep = curStep;
    }
    if(prevStepState!=stepState){
        // moved from start image to video
        if(stepState==1){
            if(videos.size()>curStep)    videos.at(curStep).show();
            if(images.size()>curStep)  images.at(curStep).hide();
            if(videos.size()>curStep)   videos.at(curStep).play();
        } else {
            if(images.size()>curStep) images.at(curStep).show();
            if(videos.size()>curStep)  videos.at(curStep).hide();
            if(videos.size()>curStep)  videos.at(curStep).stop();
        }
        prevStepState = stepState;
    }
        }
    
}
예제 #20
0
RecipeView::RecipeView(UserAreaModel _area, RecipeModel _recipe){
   
    lastTouched = getElapsedSeconds();
    
    recipeModel = _recipe;
    areaModel = _area;
    timeOut = areaModel.timeout;
    // menu_img.load(_model.getMenuImage());
    debugState = 2;
    
    curStep = 0;
    stepState = 0;
    prevStepState = -1;
    prevStep = -1;
    
    pos = Vec2f(_area.x,_area.y);
    rotation = _area.r;
    
    align=TOP_LEFT;
    
    if(_area.name.compare("bottom-left")==0) align=BOTTOM_LEFT;
    if(_area.name.compare("bottom-right")==0) align=BOTTOM_RIGHT;
    if(_area.name.compare("top-left")==0){
     align=BOTTOM_RIGHT;
        console() << "aligning top left";
    }
    if(_area.name.compare("top-right")==0){
        align=BOTTOM_LEFT;
    console() << "aligning top right";
    }
    console() << "this recipemodel has this many steps: " << recipeModel.getNumSteps() << "." << endl;
    for(int i=0;i<recipeModel.getNumSteps();i++){
        console() << "wtf: " << recipeModel.getCookStep(i).img.at(0) << endl;
        gallerytools::Image anImage;
        anImage.load(recipeModel.getCookStep(i).img.at(recipeModel.curLanguage));
        anImage.hide();
        images.push_back(anImage);
        gallerytools::Video aVideo;
        console() << "loading video::: " << aVideo.load(recipeModel.getCookStep(i).video.at(recipeModel.curLanguage)) << endl;
        aVideo.hide();
        videos.push_back(aVideo);
    }
    back_btn.load(areaModel.back_btn.path);
    back_btn.moveTo(areaModel.back_btn.x,areaModel.back_btn.y,false);
    fwd_btn.load(areaModel.fwd_btn.path);
    fwd_btn.moveTo(areaModel.fwd_btn.x,areaModel.fwd_btn.y,false);
    select_btn.load(areaModel.select_btn.path);
    select_btn.moveTo(areaModel.select_btn.x,areaModel.select_btn.y,false);
    
    string normalFont( "Arial" );
    
	TextLayout layout;
	layout.clear( ColorA( 0.5f, 0.5f, 0.5f, 0.5f ) );
	layout.setFont( Font( normalFont, 24 ) );
	layout.setColor( Color( 1, 1, 1 ) );
	layout.addLine( "testing here");
	Surface8u rendered = layout.render( true, false );
	text_texture = gl::Texture( rendered );
    select_btn.setHalfHidden();
    back_btn.setHalfHidden();
    fwd_btn.setHalfHidden();
    
}
예제 #21
0
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 );
}
예제 #22
0
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 ) );
}