本文整理汇总了C++中TextLayout类的典型用法代码示例。如果您正苦于以下问题:C++ TextLayout类的具体用法?C++ TextLayout怎么用?C++ TextLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextLayout类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:kevinbs,项目名称:Cinder-portfolio,代码行数:28,代码来源:quickTimeSample.cpp
示例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();
}
开发者ID:ChadMcKinney,项目名称:Cinder,代码行数:28,代码来源:AccordionItem.cpp
示例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();
}
开发者ID:20SecondsToSun,项目名称:Funces,代码行数:55,代码来源:QRcode.cpp
示例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();
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:28,代码来源:QuickTimeBasicApp.cpp
示例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;
}
开发者ID:Amcut,项目名称:pizmidi,代码行数:11,代码来源:piz_LookAndFeel.cpp
示例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);
}
}
}
开发者ID:Emisense,项目名称:S3Test,代码行数:12,代码来源:juce_AttributedString.cpp
示例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 ) );
}
}
开发者ID:20SecondsToSun,项目名称:KinectPoseRecognition,代码行数:12,代码来源:Button.cpp
示例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;
}
开发者ID:Amcut,项目名称:pizmidi,代码行数:13,代码来源:LookAndFeel.cpp
示例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 ();
}
开发者ID:fserb,项目名称:lime,代码行数:14,代码来源:ExternalInterface.cpp
示例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(" ");
}
开发者ID:foxmadnes,项目名称:CatMemeMaker,代码行数:14,代码来源:CatMemeMakerApp.cpp
示例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 ) );
}
开发者ID:gitter-badger,项目名称:cpp-tetris,代码行数:14,代码来源:box2d_basicApp.cpp
示例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 ) );
}
}
开发者ID:H-Plus-Time,项目名称:Planetary,代码行数:14,代码来源:ScrollingLabel.cpp
示例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));
}
开发者ID:LarsEngeln,项目名称:orbZ,代码行数:15,代码来源:SceneInIsInside.cpp
示例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 ();
}
开发者ID:Rezmason,项目名称:lime,代码行数:16,代码来源:ExternalInterface.cpp
示例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) );
}
开发者ID:gregkepler,项目名称:CinderPathFitter,代码行数:52,代码来源:PathSimplificationApp.cpp
示例16: createLayout
void createLayout (TextLayout& layout, const AttributedString& text, IDWriteFactory& directWriteFactory,
ID2D1Factory& direct2dFactory, IDWriteFontCollection& fontCollection)
{
// To add color to text, we need to create a D2D render target
// Since we are not actually rendering to a D2D context we create a temporary GDI render target
D2D1_RENDER_TARGET_PROPERTIES d2dRTProp = D2D1::RenderTargetProperties (D2D1_RENDER_TARGET_TYPE_SOFTWARE,
D2D1::PixelFormat (DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_IGNORE),
0, 0,
D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE,
D2D1_FEATURE_LEVEL_DEFAULT);
ComSmartPtr<ID2D1DCRenderTarget> renderTarget;
HRESULT hr = direct2dFactory.CreateDCRenderTarget (&d2dRTProp, renderTarget.resetAndGetPointerAddress());
ComSmartPtr<IDWriteTextLayout> dwTextLayout;
if (! setupLayout (text, layout.getWidth(), layout.getHeight(), *renderTarget,
directWriteFactory, fontCollection, dwTextLayout))
return;
UINT32 actualLineCount = 0;
hr = dwTextLayout->GetLineMetrics (nullptr, 0, &actualLineCount);
layout.ensureStorageAllocated (actualLineCount);
{
ComSmartPtr<CustomDirectWriteTextRenderer> textRenderer (new CustomDirectWriteTextRenderer (fontCollection, text));
hr = dwTextLayout->Draw (&layout, textRenderer, 0, 0);
}
HeapBlock<DWRITE_LINE_METRICS> dwLineMetrics (actualLineCount);
hr = dwTextLayout->GetLineMetrics (dwLineMetrics, actualLineCount, &actualLineCount);
int lastLocation = 0;
const int numLines = jmin ((int) actualLineCount, layout.getNumLines());
float yAdjustment = 0;
const float extraLineSpacing = text.getLineSpacing();
for (int i = 0; i < numLines; ++i)
{
TextLayout::Line& line = layout.getLine (i);
line.stringRange = Range<int> (lastLocation, (int) lastLocation + dwLineMetrics[i].length);
line.lineOrigin.y += yAdjustment;
yAdjustment += extraLineSpacing;
lastLocation += dwLineMetrics[i].length;
}
}
开发者ID:AlessandroGiacomini,项目名称:pyplasm,代码行数:47,代码来源:juce_win32_DirectWriteTypeLayout.cpp
示例17: white
void ciApp::draw()
{
gl::clear();
gl::ScopedColor white(Color::white());
auto get_center_rect = [&](Area area) ->Rectf { return Rectf(area).getCenteredFit(getWindowBounds(), true); };
{
//auto tex = filter->getTexture();
auto tex = vector_blur.getTexture();
gl::draw(tex, get_center_rect(tex->getBounds()));
}
{
gl::ScopedMatrices scpMatrix;
gl::scale(0.2f, 0.2f);
gl::draw(mTexture);
}
vector_blur.drawDebug(vec2(0, 0), 0.2f);
mParams->draw();
{
TextLayout infoFps;
infoFps.clear(ColorA(0.2f, 0.2f, 0.2f, 0.5f));
infoFps.setColor(Color::white());
infoFps.setFont(Font("Arial", 16));
infoFps.setBorder(4, 2);
infoFps.addLine("App Framerate: " + tostr(getAverageFps(), 1));
auto tex = gl::Texture::create(infoFps.render(true));
gl::draw(tex, ivec2(20, getWindowHeight() - tex->getHeight() - 20));
}
}
开发者ID:shinabebel,项目名称:ci_blocks,代码行数:35,代码来源:ciApp.cpp
示例18: Capture
void RotatingCubeApp::setup()
{
try {
mCapture = Capture( 320, 240 );
mCapture.start();
}
catch( CaptureExc &exc ) {
console() << "failed to initialize the webcam, what: " << exc.what() << std::endl;
// create a warning texture
// if we threw in the start, we'll set the Capture to null
mCapture.reset();
TextLayout layout;
layout.clear( Color( 0.3f, 0.3f, 0.3f ) );
layout.setColor( Color( 1, 1, 1 ) );
layout.setFont( Font( "Arial", 96 ) );
layout.addCenteredLine( "No Webcam" );
layout.addCenteredLine( "Detected" );
mTexture = gl::Texture2d::create( layout.render() );
}
mCam.lookAt( vec3( 3, 2, -3 ), vec3( 0 ) );
gl::enableDepthRead();
gl::enableDepthWrite();
}
开发者ID:ChristophPacher,项目名称:Cinder,代码行数:26,代码来源:RotatingBox.cpp
示例19: drawAlertBox
void CabbageIDELookAndFeel::drawAlertBox (Graphics& g,
AlertWindow& alert,
const Rectangle<int>& textArea,
TextLayout& textLayout)
{
g.fillAll (CabbageSettings::getColourFromValueTree (colourTree, CabbageColourIds::alertWindowBackground, Colour (Colour::fromString("2ff52636a"))));
int iconSpaceUsed = 160;
if (alert.getAlertType() != AlertWindow::NoIcon)
{
Path icon;
if (alert.getAlertType() == AlertWindow::WarningIcon)
{
Rectangle<float> rect (alert.getLocalBounds().removeFromLeft (iconSpaceUsed).toFloat());
const Image warningImage = ImageCache::getFromMemory (CabbageBinaryData::WarningIcon_png, CabbageBinaryData::WarningIcon_pngSize);
//g.drawImage(warningImage, rect.reduced(20));
}
if (alert.getAlertType() == AlertWindow::QuestionIcon)
{
Rectangle<float> rect (alert.getLocalBounds().removeFromLeft (iconSpaceUsed - 20).toFloat());
const Image warningImage = ImageCache::getFromMemory (CabbageBinaryData::WarningIcon_png, CabbageBinaryData::WarningIcon_pngSize);
//g.drawImage(warningImage, rect.reduced(25));
}
MemoryInputStream svgStream (CabbageBinaryData::processstop_svg, CabbageBinaryData::processstop_svgSize, false);
ScopedPointer<XmlElement> svg (XmlDocument::parse (svgStream.readString()));
if (svg == nullptr)
jassert (false);
ScopedPointer<Drawable> drawable;
if (svg != nullptr)
{
drawable = Drawable::createFromSVG (*svg);
Rectangle<float> rect (20, 20, 80, 80);//alert.getLocalBounds().removeFromLeft (iconSpaceUsed - 20).withHeight(130).toFloat());
drawable->setTransformToFit (rect, RectanglePlacement::stretchToFit);
drawable->draw (g, 1.f, AffineTransform());
}
}
g.setColour (alert.findColour (AlertWindow::textColourId));
textLayout.draw (g, Rectangle<int> (textArea.getX() + iconSpaceUsed - 50,
textArea.getY(),
textArea.getWidth() - iconSpaceUsed - 40,
textArea.getHeight()).toFloat());
g.setColour (alert.findColour (AlertWindow::outlineColourId));
g.drawRect (0, 0, alert.getWidth(), alert.getHeight());
}
开发者ID:rorywalsh,项目名称:cabbage,代码行数:55,代码来源:CabbageIDELookAndFeel.cpp
示例20: createTabTextLayout
void CtrlrLuaMethodEditorTabsLF::createTabTextLayout (const TabBarButton& button, float length, float depth, Colour colour, TextLayout& textLayout)
{
Font font (12.0f);
font.setUnderline (button.hasKeyboardFocus (false));
AttributedString s;
s.setJustification (Justification::centred);
s.append (button.getButtonText().trim(), font, colour);
textLayout.createLayout (s, length);
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:11,代码来源:CtrlrLuaMethodEditorTabs.cpp
注:本文中的TextLayout类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论