Esempio n. 1
0
void Branch::draw( cairo::Context ctx )
{
    if ( mLaunchDelay > 0 )
        return;

    if( ( mLifespan > 0 ) && ( ! mIsRoot ) ) {
        float ageLerp = 1.0 - mLifespan / (float)mTotalLifespan;
        float radius = lerp( mStartEllipseRadius, mEndEllipseRadius, ageLerp );
        ColorA drawColor = lerp( mStartColor, mEndColor, ageLerp );
        ctx.setSourceRgba( drawColor.r, drawColor.g, drawColor.b, 0.075f );
        ctx.circle( mPos, ( 5.0f * mScale + radius * 1.3f ) / 2 );
        ctx.fill();
        ctx.setSource( drawColor );
        ctx.circle( mPos, radius / 2 );
        ctx.fill();
    }

    for( vector<Branch>::iterator blossomIt = mBranches.begin(); blossomIt != mBranches.end(); ++blossomIt ) {
        blossomIt->draw( ctx );
    }
}
Esempio n. 2
0
	void draw( cairo::Context &ctx ) const
	{
		// draw the solid petals
		ctx.setSource( mColor );
		makePath( ctx );
		ctx.fill();
		
		// draw the petal outlines
		ctx.setSource( mColor * 0.8f );
		makePath( ctx );
		ctx.stroke();
	};
void ContinuousPathApp::drawCircle(cairo::Context &ctx, Vec2f const &pt, double diameter,  Color col, bool outline)
{
    ctx.setLineWidth(1);
    ctx.setSource( col );
    ctx.newSubPath();
    ctx.circle( pt.x, pt.y, diameter );
    ctx.closePath();
    
    if(outline){
        ctx.stroke();
    }else{
        ctx.fill();   
    }
}
Esempio n. 4
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();    
}