MCPcopy Create free account
hub / github.com/cinder/Cinder / operator()

Method operator()

samples/FontSample/src/FontSampleApp.cpp:83–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81struct VerboseCharDraw {
82 VerboseCharDraw( cairo::Context &ctx ) : mCtx( ctx ) { }
83 bool operator()( Path2d::SegmentType type, const vec2 *points, const vec2 *previousPoint )
84 {
85 const float radius = 3.0f;
86 const ColorA dotColor( 0.5f, 0.75f, 1.0f, 0.4f );
87 const ColorA lineColor( 0.5f, 1.0f, 0.5f, 0.8f );
88 if( type == Path2d::MOVETO ) {
89 mCtx.circle( points[0], radius );
90 }
91 else if( type == Path2d::LINETO ) {
92 mCtx.setSource( dotColor );
93 mCtx.circle( points[0], radius );
94 mCtx.fill();
95 mCtx.setSource( lineColor );
96 mCtx.line( points[0], *previousPoint );
97 mCtx.stroke();
98 }
99 else if( type == Path2d::QUADTO ) {
100 mCtx.setSource( dotColor );
101 mCtx.circle( points[0], radius );
102 mCtx.circle( points[1], radius );
103 mCtx.fill();
104 mCtx.setSource( lineColor );
105 mCtx.moveTo( *previousPoint ); mCtx.quadTo( points[0], points[1] );
106 mCtx.stroke();
107 }
108 else if( type == Path2d::CUBICTO ) {
109 mCtx.setSource( dotColor );
110 mCtx.circle( points[0], radius );
111 mCtx.circle( points[1], radius );
112 mCtx.circle( points[2], radius );
113 mCtx.fill();
114 mCtx.setSource( lineColor );
115 mCtx.moveTo( *previousPoint ); mCtx.curveTo( points[0], points[1], points[2] );
116 mCtx.stroke();
117 }
118 else if( type == Path2d::CLOSE ) {
119 mCtx.setSource( lineColor );
120 mCtx.line( points[0], *previousPoint );
121 mCtx.stroke();
122 }
123 return true;
124 }
125
126 cairo::Context &mCtx;
127};

Callers

nothing calls this directly

Calls 8

strokeMethod · 0.80
circleMethod · 0.45
setSourceMethod · 0.45
fillMethod · 0.45
lineMethod · 0.45
moveToMethod · 0.45
quadToMethod · 0.45
curveToMethod · 0.45

Tested by

no test coverage detected