Example #1
0
void WisteriaApp::update()
{
	// Iterate all the blossoms, update each one and notice if they are all idle
	bool isIdle = true;
	for( vector<Branch>::iterator blossomIt = mBlossoms.begin(); blossomIt != mBlossoms.end(); ++blossomIt ) {
		blossomIt->update();
		if( blossomIt->isAlive() )
			isIdle = false;
	}

	if( isIdle && ( ! mIsIdle ) ) {
		mIsIdle = true;  // first frame of idleness
		mIdleFrames = 0;
	}
	else if( isIdle ) { // the blossoms have all not changed in a while, let's clear them out and put up some new ones
		if( mIdleFrames++ > IDLE_RESTART_FRAMES ) {
			// clear the context
			mOffscreenContext.setSourceRgb( 0.23f, 0.23f, 0.23f );
			mOffscreenContext.paint();
			
			mBlossoms.clear();
			mBlossoms.push_back( Branch( Vec2f( Rand::randFloat( WIDTH ), Rand::randFloat( HEIGHT ) ), Branch::randomHue(), 0 ) );
			mBlossoms.push_back( Branch( Vec2f( Rand::randFloat( WIDTH ), Rand::randFloat( HEIGHT ) ), Branch::randomHue(), 180 ) );
			mBlossoms.push_back( Branch( Vec2f( Rand::randFloat( WIDTH ), Rand::randFloat( HEIGHT ) ), Branch::randomHue(), 320 ) );
			
			mIsIdle = false;
		}
	}
}
Example #2
0
void bsplineApp::drawBSpline( cairo::Context &ctx )
{
	if( mPoints.size() > (size_t)mDegree ) {
		ctx.setLineWidth( 2.5f );
		ctx.setSourceRgb( 1.0f, 0.5f, 0.25f );
		ctx.appendPath( Path2d( BSpline2f( mPoints, mDegree, mLoop, mOpen ) ) );
		ctx.stroke();
//		ctx.fill();
	}
}
Example #3
0
void fontSampleApp::drawCharacterVerbose( cairo::Context &ctx, vec2 where )
{
	cairo::Matrix prevMat;
	ctx.getMatrix( &prevMat );
	
	// draw it filled
	ctx.setSourceRgb( 1.0f, 1.0, 0.5f );
	ctx.translate( where );
	// Uncomment below to render the character filled
	// ctx.appendPath( mShape );
	// ctx.fill();
	
	VerboseCharDraw verb( ctx );
	mShape.iterate<VerboseCharDraw>( verb );
	
	ctx.setMatrix( prevMat );
}
Example #4
0
void WisteriaApp::setup()
{
	// allocate our offscreen buffer
	mOffscreenBuffer = cairo::SurfaceImage( WIDTH, HEIGHT, false );
	mOffscreenContext = cairo::Context( mOffscreenBuffer );

	// fill the buffer with gray
	mOffscreenContext.setSourceRgb( 0.23f, 0.23f, 0.23f );
	mOffscreenContext.paint();
	
	// Let the Branches know how big our windows is
	Branch::setWindowSize( WIDTH, HEIGHT );
	
	// Create some starting blossoms
	mBlossoms.push_back( Branch( Vec2f( WIDTH - 50, 50 ), 0.619444444f, 0 ) );
	mBlossoms.push_back( Branch( Vec2f( 60, HEIGHT - 60 ), 0.905f, 180 ) );
	mBlossoms.push_back( Branch( Vec2f( WIDTH / 2, HEIGHT / 2 ), 0.105555556f, 320 ) );
	
	mIsIdle = false;
	mIdleFrames = 0;
}
Example #5
0
void NodeView::draw(cairo::Context &theG) {
    _size = _calculateSize();

        
    cairo::GradientLinear myGradient(0, 0, 0, _size.y);
    
    if(_node->state() == WARNING) {
        myGradient.addColorStop(0.15, Colorf(0.518, 0.298, 0.298*0.5));
        myGradient.addColorStop(0.85, Colorf(0.898, 0.467, 0.0));
    } else if(_node->state() == ERROR) {
        myGradient.addColorStop(0.15, Colorf(0.5, 0, 0));
        myGradient.addColorStop(0.85, Colorf(0.8, 0, 0));

    } else {
        myGradient.addColorStop(0.15, Colorf(0.14, 0.12, 0.129));
        myGradient.addColorStop(0.85, Colorf(0.227, 0.188, 0.2));
        
    }
   
    
    
	Rectf myRect;
	myRect.set(0, 0, _size.x, _size.y);

    Vec2f myCorrection(0.5, 0.5);

    theG.translate(myCorrection);
   	theG.translate(_position);
    

    theG.setSourceRgb(0.7, 0.7, 0.7);
    
    theG.roundedRectangle(myRect, 2);
    theG.setLineWidth(1);
    theG.stroke();
    
    theG.translate(Vec2f(-0.5, -0.5));

    
    theG.setSource(myGradient);

    theG.roundedRectangle(myRect, 2);
    theG.fill(); 
    
    
    
    
    
//    for(int i = 0; i < _node->inputs().size(); i++) {
//        NodeInputBase *myInput = _node->inputs()[i];
//        int myX = _size.x - (i * PIN_WIDTH + (i-1) * PIN_SPACING + PIN_SPACING + PIN_WIDTH);
//        
//        theG.setSourceRgb(0.8, 0.8, 0.8);
//        theG.rectangle(myX - PIN_WIDTH, 0, PIN_WIDTH, PIN_HEIGHT);
//        theG.fill();
//        
//        
//        
//    }
//    
//    
//    
//    for(int i = 0; i < _node->outputs().size(); i++) {
//        NodeOutputBase *myOutput = _node->outputs()[i];
//        
//        int myX = _size.x - (i * PIN_WIDTH + (i-1) * PIN_SPACING + PIN_SPACING + PIN_WIDTH);
//        
//        theG.setSourceRgb(0.8, 0.8, 0.8);
//        theG.rectangle(myX - PIN_WIDTH, _size.y - PIN_HEIGHT, PIN_WIDTH, PIN_HEIGHT);
//        theG.fill();        
//    }
    
    
    
    
    theG.translate(Vec2f(5, _size.y - 5));
    theG.setSourceRgb(0.8, 0.8, 0.8);
    theG.setFont( _font );
    theG.setFontSize( 10 );
    theG.showText( _node->name() );
    theG.fill();
    
    theG.setSourceRgb(1.0, 0, 0);
    

    theG.flush();    
}