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 makePath( cairo::Context &ctx ) const { for( int petal = 0; petal < mNumPetals; ++petal ) { ctx.newSubPath(); float petalAngle = ( petal / (float)mNumPetals ) * 2 * M_PI; Vec2f outsideCircleCenter = mLoc + Vec2f::xAxis() * cos( petalAngle ) * mRadius + Vec2f::yAxis() * sin( petalAngle ) * mRadius; Vec2f insideCircleCenter = mLoc + Vec2f::xAxis() * cos( petalAngle ) * mPetalInsideRadius + Vec2f::yAxis() * sin( petalAngle ) * mPetalInsideRadius; ctx.arc( outsideCircleCenter, mPetalOutsideRadius, petalAngle + M_PI / 2 + M_PI, petalAngle + M_PI / 2 ); ctx.arc( insideCircleCenter, mPetalInsideRadius, petalAngle + M_PI / 2, petalAngle + M_PI / 2 + M_PI ); ctx.closePath(); } }
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(); } }