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

Method draw

samples/_timeline/VisualDictionary/src/WordNode.cpp:47–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void WordNode::draw() const
48{
49 // draw shadows
50 gl::color( ColorA( 0, 0, 0, mColor().a * 0.5f ) );
51 vec2 p = mPos();
52 p += vec2( 1.0f, 1.0f );
53 gl::drawSolidRect( Rectf( p.x - mRadius, p.y - mRadius, p.x + mRadius, p.y + mRadius ) );
54 p += vec2( 1.0f, 1.0f );
55 gl::drawSolidRect( Rectf( p.x - mRadius, p.y - mRadius, p.x + mRadius, p.y + mRadius ) );
56
57
58 // draw color circle
59 gl::color( mColor );
60 p = mPos();
61 gl::drawSolidRect( Rectf( p.x - mRadius, p.y - mRadius, p.x + mRadius, p.y + mRadius ) );
62
63
64 // draw string
65 // biggest square that can fit in the circle is radius * sqrt(2) per side x^2 = (r^2)/2
66 const float squareSide = sqrtf( ( mRadius * mRadius ) / 2.0f );
67 float pixelScale = std::min( squareSide / mWordPixelLength, squareSide / 72 ) * 2.25f;
68 gl::TextureFont::DrawOptions options = gl::TextureFont::DrawOptions().scale( pixelScale ).pixelSnap( false );
69
70 const vec2 offset = (vec2)mPos + vec2( -mRadius + ( mRadius * 2 - mWordPixelLength * pixelScale ) / 2, mRadius - (mRadius * 2.0f - 20 * pixelScale ) / 2 );
71
72 gl::color( ColorA( Color::black(), mColor().a * 0.5f ) );
73 sFont->drawString( mWord, offset + vec2( pixelScale, pixelScale ) * 1.5f, options );
74
75 gl::color( ColorA( ( mColor() + Color::white() ) * 0.65f, mColor().a ) );
76 sFont->drawString( mWord, offset, options );
77}
78
79void WordNode::setFont( gl::TextureFontRef font )
80{

Callers

nothing calls this directly

Calls 8

drawSolidRectFunction · 0.85
DrawOptionsFunction · 0.85
blackFunction · 0.85
whiteFunction · 0.85
drawStringMethod · 0.80
colorFunction · 0.50
minFunction · 0.50
scaleMethod · 0.45

Tested by

no test coverage detected