本文整理汇总了C++中TextLayout类的典型用法代码示例。如果您正苦于以下问题:C++ TextLayout类的具体用法?C++ TextLayout怎么用?C++ TextLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMovieFile
void QuickTimeSampleApp::loadMovieFile( const fs::path& moviePath )
{
try {
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieGl( moviePath );
mMovie.setLoop();
mMovie.play();
// create a texture for showing some info about the movie
TextLayout infoText;
infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
infoText.setColor( Color::white() );
infoText.addCenteredLine( getPathFileName( moviePath.string() ) );
infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" );
infoText.addLine( toString( mMovie.getDuration() ) + " seconds" );
infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" );
infoText.addLine( toString( mMovie.getFramerate() ) + " fps" );
infoText.setBorder( 4, 2 );
mInfoTexture = gl::Texture( infoText.render( true ) );
}
catch( ... ) {
console() << "Unable to load the movie." << std::endl;
mMovie.reset();
mInfoTexture.reset();
}
mFrameTexture.reset();
}
示例2: mTimeline
AccordionItem::AccordionItem( Timeline &timeline, float x, float y, float height, float contractedWidth, float expandedWidth, gl::Texture image, string title, string subtitle )
: mTimeline(timeline), mX(x), mY(y), mWidth(contractedWidth), mHeight(height), mExpandedWidth(expandedWidth), mImage(image), mTitle(title), mSubtitle(subtitle)
{
#if defined( CINDER_COCOA )
std::string normalFont( "Arial" );
std::string boldFont( "Arial-BoldMT" );
#else
std::string normalFont( "Arial" );
std::string boldFont( "ArialBold" );
#endif
mAnimEase = EaseOutAtan(25);
mAnimDuration = 0.7f;
mTextAlpha = 0.0f;
TextLayout layout;
layout.clear( ColorA( 0.6f, 0.6f, 0.6f, 0.0f ) );
layout.setFont( Font( boldFont, 26 ) );
layout.setColor( Color( 1, 1, 1 ) );
layout.addLine( mTitle );
layout.setFont( Font( normalFont, 16 ) );
layout.addLine( mSubtitle );
layout.setBorder(11, 6);
mText = gl::Texture( layout.render( true ) );
update();
}
示例3: drawError
void QRcode::draw()
{
gl::pushMatrices();
gl::translate(startQRCodeHolderXY);
gl::draw(qrCodeFon);
if (isError)
{
drawError();
}
else
{
if (isReady == false)
{
gl::pushMatrices();
gl::translate(220, 650);
preloader.draw();
gl::popMatrices();
}
else
{
if(stringQrcode=="") return;
//if (isRender == false)
//{
isRender = true;
qrCodeTexture = loadImageFromString(stringQrcode);
TextLayout simple;
simple.setFont( qrCodeFont );
simple.setColor( Color( 1, 1, 1 ) );
simple.addLine(url);
qrCodeTextTexture = gl::Texture( simple.render( true, false ) );
//}
if(qrCodeTextTexture)
{
gl::pushMatrices();
gl::translate(33, 885);
gl::draw(qrCodeTextTexture);
gl::popMatrices();
}
if(qrCodeTexture)
{
gl::pushMatrices();
gl::translate(86, 505);
gl::draw(qrCodeTexture);
gl::popMatrices();
}
}
}
gl::popMatrices();
}
示例4: loadMovieFile
void QuickTimeSampleApp::loadMovieFile( const fs::path &moviePath )
{
try {
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieGl::create( moviePath );
mMovie->setLoop();
mMovie->play();
// create a texture for showing some info about the movie
TextLayout infoText;
infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
infoText.setColor( Color::white() );
infoText.addCenteredLine( moviePath.filename().string() );
infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
infoText.setBorder( 4, 2 );
mInfoTexture = gl::Texture::create( infoText.render( true ) );
}
catch( ci::Exception &exc ) {
console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
mMovie.reset();
mInfoTexture.reset();
}
mFrameTexture.reset();
}
示例5: layoutTooltipText
static const TextLayout layoutTooltipText (const String& text) throw()
{
const float tooltipFontSize = 11.0f;
const int maxToolTipWidth = 400;
const Font f (tooltipFontSize, Font::plain);
TextLayout tl (text, f);
tl.layout (maxToolTipWidth, Justification::left, true);
return tl;
}
示例6: draw
void AttributedString::draw (Graphics& g, const Rectangle<float>& area) const
{
if (text.isNotEmpty() && g.clipRegionIntersects (area.getSmallestIntegerContainer()))
{
if (! g.getInternalContext()->drawTextLayout (*this, area))
{
TextLayout layout;
layout.createLayout (*this, area.getWidth());
layout.draw (g, area);
}
}
}
示例7: setBtnId
void Button::setBtnId(string value)
{
if (isTextField )
{
code = value;
TextLayout simple;
simple.setFont( *textFont );
simple.setColor(Color::black());
simple.addLine(Utils::cp1251_to_utf8(value.c_str()));
textTexture = gl::Texture( simple.render( true, false ) );
}
}
示例8: layoutTooltipText
static TextLayout layoutTooltipText (const String& text, const Colour& colour) noexcept
{
const float tooltipFontSize = 13.0f;
const int maxToolTipWidth = 400;
AttributedString s;
s.setJustification (Justification::centred);
s.append (text, Font (tooltipFontSize, Font::bold), colour);
TextLayout tl;
tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth);
return tl;
}
示例9: lime_text_layout_position
value lime_text_layout_position (value textHandle, value fontHandle, value size, value textString, value data) {
#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
TextLayout *text = (TextLayout*)(intptr_t)val_float (textHandle);
Font *font = (Font*)(intptr_t)val_float (fontHandle);
ByteArray bytes = ByteArray (data);
text->Position (font, val_int (size), val_string (textString), &bytes);
#endif
return alloc_null ();
}
示例10: saveFirst
void CatMemeMakerApp::saveFirst()
{
TextLayout simple;
std::string normalFont( "Arial" );
simple.setFont( Font(normalFont,48) );
simple.setColor( Color( 1, 1, 1 ) );
simple.addCenteredLine(mMessage.str());
mFirstLine = gl::Texture( simple.render( true , false ) );
mMessage.str(" ");
}
示例11: make_tex
gl::TextureRef make_tex(std::string const& line)
{
TextLayout layout;
layout.setFont( Font( "Arial", 32 ) );
layout.setColor( Color( 1, 1, 0 ) );
layout.addLine( line );
//if (stat_ == stat::over) {
// //layout.addLine( std::string("synths: ") );
//} else if (stat_ == stat::pause) {
// layout.addLine( std::string("Pause") );
//}
return gl::Texture::create( layout.render( true ) );
}
示例12: updateTexture
void ScrollingLabel::updateTexture()
{
if (mText == "") {
mTexture.reset();
}
else {
TextLayout layout;
layout.setFont( mFont );
layout.setColor( mColor );
layout.addLine( mText );
bool PREMULT = false;
mTexture = gl::Texture( layout.render( true, PREMULT ) );
}
}
示例13: getWindowWidth
SceneInIsInside::SceneInIsInside()
{
mmgr = make_shared<MovieManager>();
mmgr->addMovie("innen.mp4", getWindowWidth()*0.5, getWindowHeight()*0.5, getWindowWidth(), getWindowHeight());
std::string arial("Arial");
TextLayout simple;
simple.setFont(Font(arial, 16));
simple.setColor(Color(1, 1, 1));
simple.addLine("SceneInIsInside");
text = gl::Texture2d::create(simple.render(true, PREMULT));
}
示例14: lime_text_layout_position
value lime_text_layout_position (value textHandle, value fontHandle, int size, HxString textString, value data) {
#if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ)
TextLayout *text = (TextLayout*)val_data (textHandle);
Font *font = (Font*)val_data (fontHandle);
Bytes bytes;
bytes.Set (data);
text->Position (font, size, textString.__s, &bytes);
return bytes.Value ();
#endif
return alloc_null ();
}
示例15: Color
void PathSimplificationApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
cairo::SurfaceImage surface( getWindowWidth(), getWindowHeight());
cairo::Context ctx( surface );
// draw each path
for(int i=0; i<mSmPaths.size(); i++){
// pass the cairo context to draw onto
drawPath(ctx, mSmPaths[i], drawMode);
}
// draw the surface
gl::Texture myTexture = surface.getSurface();
gl::draw(myTexture);
TextLayout layout;
layout.clear(ColorA(0.1f,0.1f,0.1f,0.7f));
layout.setColor( Color( 0.9f, 0.9f, 0.9f ) );
layout.setFont( Font( "Arial", 14 ) );
SmoothPath* lastPath;
if(mSmPaths.size() > 0){
lastPath = mSmPaths[mSmPaths.size()-1];
}
if(mSmPaths.size() == 0){
layout.addCenteredLine("Click and drag to draw a line.");
layout.addCenteredLine("Press 'R' to clear.");
}else if(mSmPaths.size() > 0 && lastPath->inProgress){
int segCount = (lastPath->getPathPoints().size()>0) ? lastPath->getPathPoints().size()-1 : 0;
layout.addCenteredLine( "Segment Count: " + boost::lexical_cast<std::string>(segCount));
}else if(mSmPaths.size() > 0 && !lastPath->inProgress){
int oldSegCount = (lastPath->getPathPoints().size()>0) ? lastPath->getPathPoints().size()-1 : 0;
int segCount = lastPath->getCurrentPath().getNumSegments();
int diff = oldSegCount - segCount;
float per = (float(diff)/float(oldSegCount)) * 100.0f;
string msg = boost::lexical_cast<std::string>(diff) + " of " + boost::lexical_cast<std::string>(oldSegCount) + " segments were removed. Saving " +boost::lexical_cast<std::string>(per) + "%";
layout.addCenteredLine(msg);
}
Surface8u rendered = layout.render( true, PREMULT );
mTextTexture = gl::Texture( rendered );
if( mTextTexture )
gl::draw( mTextTexture, Vec2f(10, 10) );
}