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

Method layoutWords

samples/_timeline/VisualDictionary/src/VisualDictionaryApp.cpp:65–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void VisualDictionaryApp::layoutWords( vector<string> words, float radius )
66{
67 int radiusDivisor = 26;//std::max<int>( 10, words.size() ); // don't let the circles get too small
68 mCurrentCircleRadius = radius / radiusDivisor * M_PI;
69 for( size_t w = 0; w < words.size(); ++w ) {
70 int wordLength = words[w].length();
71 string s = words[w];
72 int charIndex = (int)s[wordLength-1] - 97;
73 float charPer = charIndex/26.0f;
74 float angle = charPer * 2.0f * M_PI;
75 //float angle = w / (float)words.size() * 2 * M_PI;
76 vec2 pos = getWindowCenter() + radius * vec2( cos( angle ), sin( angle ) );
77 Color col( CM_HSV, charPer, 0.875f, 1 );
78 mNodes.push_back( WordNode( words[w] ) );
79 mNodes.back().mPos = getWindowCenter() + radius * 0.5f * vec2( cos( angle ), sin( angle ) );
80 mNodes.back().mColor = ColorA( col, 0.0f );
81 mNodes.back().mRadiusDest = mCurrentCircleRadius;
82 mNodes.back().mRadius = 0;
83
84 timeline().apply( &mNodes.back().mRadius, mNodes.back().mRadiusDest, 0.4f, EaseOutAtan( 10 ) ).timelineEnd( -0.39f );
85 timeline().apply( &mNodes.back().mPos, pos, 0.4f, EaseOutAtan( 10 ) ).timelineEnd( -0.39f );
86 timeline().apply( &mNodes.back().mColor, ColorA( col, 1.0f ), 0.4f, EaseOutAtan( 10 ) ).timelineEnd( -0.39f );
87 }
88}
89
90void VisualDictionaryApp::setup()
91{

Callers

nothing calls this directly

Calls 11

getWindowCenterFunction · 0.85
cosFunction · 0.85
sinFunction · 0.85
WordNodeClass · 0.85
EaseOutAtanClass · 0.85
backMethod · 0.80
timelineEndMethod · 0.80
sizeMethod · 0.45
lengthMethod · 0.45
push_backMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected