MCPcopy Create free account
hub / github.com/cinder/Cinder / draw

Method draw

samples/FontSample/src/FontSampleApp.cpp:147–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void fontSampleApp::draw()
148{
149#if defined( CINDER_LINUX ) || defined( CINDER_MAC )
150 // On Linux/Mac, render to an image surface and then draw to window
151 cairo::SurfaceImage surface( getWindowWidth(), getWindowHeight(), true );
152 cairo::Context ctx( surface );
153#else
154 cairo::Context ctx( cairo::createWindowSurface() );
155#endif
156
157 // clear the screen
158 ctx.setSourceRgb( 0.2f, 0.2f, 0.2f );
159 ctx.paint();
160
161 // draw the current character including the control points as dots
162 ctx.setSourceRgb( 1.0f, 1.0, 0.5f );
163 drawCharacterVerbose( ctx, vec2( getWindowWidth() / 2.0f, getWindowHeight() / 2.0f ) );
164
165 // Render the name of the font in the font itself
166 ctx.setFont( mFont );
167 ctx.setFontSize( 18 );
168 ctx.moveTo( 10, getWindowHeight() - 10 );
169 ctx.setSourceRgb( 0.5f, 0.75f, 1.0f );
170 ctx.showText( mFont.getFullName() );
171 ctx.stroke();
172
173 // draw a lower case 'a'
174#if 0
175 Shape2d aPath;
176 ctx.setSourceRgba( 0.5f, 0.75f, 1.0f, 0.2f );
177 mFont.getGlyphPath( mFont.getGlyph( 'a' ), &aPath );
178 ctx.translate( getWindowWidth() / 2.0f, getWindowHeight() / 2.0f );
179 ctx.appendPath( aPath );
180 ctx.fill();
181#endif
182
183#if defined( CINDER_LINUX ) || defined( CINDER_MAC )
184 // Convert to Cinder surface and draw to window
185 Surface8u cinderSurface = surface.getSurface();
186 auto tex = gl::Texture2d::create( cinderSurface );
187 gl::draw( tex );
188#endif
189}
190
191
192#if defined( CINDER_LINUX ) || defined( CINDER_MAC )

Callers

nothing calls this directly

Calls 15

getWindowWidthFunction · 0.85
getWindowHeightFunction · 0.85
createWindowSurfaceFunction · 0.85
setSourceRgbMethod · 0.80
paintMethod · 0.80
setFontSizeMethod · 0.80
showTextMethod · 0.80
getFullNameMethod · 0.80
strokeMethod · 0.80
setSourceRgbaMethod · 0.80
appendPathMethod · 0.80
createFunction · 0.50

Tested by

no test coverage detected