void ContinuousPathApp::drawCurves(cairo::Context &ctx, Path2d path, float thickness, Color col) { ctx.setLineWidth(thickness); ctx.setSource(col); ctx.newSubPath(); int pointIndex = 0; for (int i=0; i<path.getNumSegments(); i++) { int segType = path.getSegmentType(i); // change jumpIndex depending on the type of segment switch(segType){ case Path2d::CUBICTO: if(i==0) ctx.moveTo(path.getPoint(pointIndex)); // do a curve to using the next 2 points as the curves and the 3rd as the end point ctx.curveTo(path.getPoint(pointIndex+1), path.getPoint(pointIndex+2), path.getPoint(pointIndex+3)); pointIndex += 3; break; case Path2d::MOVETO: // don't do anything with this point ctx.moveTo(path.getPoint(pointIndex)); pointIndex += 0; break; default: pointIndex += 1; break; } } ctx.stroke(); }
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(); } }
void PathSimplificationApp::drawLine(cairo::Context &ctx, Vec2f const &pt1, Vec2f const &pt2, float thickness, Color col) { ctx.setLineWidth(thickness); ctx.setSource(col); ctx.newSubPath(); ctx.moveTo(pt1.x, pt1.y); ctx.lineTo(pt2.x, pt2.y); ctx.closePath(); ctx.stroke(); }
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(); } }
void ChessPiece::Render(cairo::Context &ctx) { /*if (team = Black) { ctx.setSourceRgb(0.3, 0.3, 0.3); } else { ctx.setSourceRgb(0.7, 0.7, 0.7); } switch (type) { case King: ctx.showText("King"); break; case Queen: ctx.showText("Queen"); break; case Knight: ctx.showText("Knight"); break; case Bishop: ctx.showText("Bishop"); break; case Rook: ctx.showText("Rook"); break; case Pawn: ctx.showText("Pawn"); break; case Invalid: break; default: break; }*/ int verticalOffset; int horizontalOffset; switch (type) { case King: horizontalOffset = 37; verticalOffset = 17; break; case Queen: horizontalOffset = 35; verticalOffset = 17; break; case Knight: horizontalOffset = 26; verticalOffset = 17; break; case Bishop: horizontalOffset = 33; verticalOffset = 17; break; case Rook: horizontalOffset = 27; verticalOffset = 17; break; case Pawn: horizontalOffset = 26; verticalOffset = 17; break; case Invalid: break; default: break; } cinder::Vec2f TLPoint = GetTopLeftBoxPoint(); horizontalOffset += (int)TLPoint.x; verticalOffset += (int)TLPoint.y; ctx.translate(horizontalOffset, verticalOffset); cinder::cairo::SurfaceImage siPiece(surface); cinder::cairo::SurfaceBase* sb = &siPiece; ctx.setSourceSurface(siPiece, 0, 0); ctx.maskSurface(sb, 0, 0); ctx.stroke(); ctx.translate(-horizontalOffset, -verticalOffset); }
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(); }