本文整理汇总了C++中GlyphArrangement::addLineOfText方法的典型用法代码示例。如果您正苦于以下问题:C++ GlyphArrangement::addLineOfText方法的具体用法?C++ GlyphArrangement::addLineOfText怎么用?C++ GlyphArrangement::addLineOfText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlyphArrangement
的用法示例。
在下文中一共展示了GlyphArrangement::addLineOfText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawSingleLineText
//==============================================================================
void Graphics::drawSingleLineText (const String& text, const int startX, const int baselineY,
const Justification& justification) const
{
if (text.isNotEmpty()
&& startX < context.getClipBounds().getRight())
{
GlyphArrangement arr;
arr.addLineOfText (context.getFont(), text, (float) startX, (float) baselineY);
// Don't pass any vertical placement flags to this method - they'll be ignored.
jassert (justification.getOnlyVerticalFlags() == 0);
const int flags = justification.getOnlyHorizontalFlags();
if (flags != Justification::left)
{
float w = arr.getBoundingBox (0, -1, true).getWidth();
if ((flags & (Justification::horizontallyCentred | Justification::horizontallyJustified)) != 0)
w /= 2.0f;
arr.draw (*this, AffineTransform::translation (-w, 0));
}
else
{
arr.draw (*this);
}
}
}
示例2: getAverageY
static float getAverageY (const Font& font, const char* chars, bool getTop)
{
GlyphArrangement ga;
ga.addLineOfText (font, chars, 0, 0);
Array<float> y;
DefaultElementComparator<float> sorter;
for (int i = 0; i < ga.getNumGlyphs(); ++i)
{
Path p;
ga.getGlyph (i).createPath (p);
Rectangle<float> bounds (p.getBounds());
if (! p.isEmpty())
y.addSorted (sorter, getTop ? bounds.getY() : bounds.getBottom());
}
float median = y[y.size() / 2];
float total = 0;
int num = 0;
for (int i = 0; i < y.size(); ++i)
{
if (std::abs (median - y.getUnchecked(i)) < 0.05f * (float) standardHeight)
{
total += y.getUnchecked(i);
++num;
}
}
return num < 4 ? 0.0f : total / (num * (float) standardHeight);
}
示例3: drawTextAsPath
void Graphics::drawTextAsPath (const String& text, const AffineTransform& transform) const
{
if (text.isNotEmpty())
{
GlyphArrangement arr;
arr.addLineOfText (context.getFont(), text, 0.0f, 0.0f);
arr.draw (*this, transform);
}
}
示例4: drawSingleLineText
//==============================================================================
void Graphics::drawSingleLineText (const String& text, const int startX, const int baselineY) const
{
if (text.isNotEmpty()
&& startX < context->getClipBounds().getRight())
{
GlyphArrangement arr;
arr.addLineOfText (context->getFont(), text, (float) startX, (float) baselineY);
arr.draw (*this);
}
}
示例5: paint
void UploadWindow::paint(Graphics& g)
{
g.fillAll(Colours::black);
Colour border = Colours::wheat;
juce::Rectangle<int> rc(0, 0, getWidth(), getHeight());
for (int i = 0; i < 4; i++)
{
g.setColour(i == 0 ? Colours::black : border);
g.drawRect(rc.getX(), rc.getY(), rc.getWidth(), rc.getHeight());
rc.reduce(1, 1);
border = border.brighter(0.4f);
}
ColourGradient gf(Colours::red, 0, getHeight()/2.0f, Colours::darkred, float(getWidth()), getHeight()/2.0f, false);
FillType ft(gf);
int cx = getWidth() / 2;
int cy = getHeight() / 2;
const float r = 12.0f;
for (int i = 3; i >= 0; i--)
{
if (i % 2 != 0)
g.setFillType(ft);
else
g.setColour(Colours::white);
g.fillEllipse(cx - (r * i), cy - (r * i), (r * i) * 2, (r * i) * 2);
}
g.setFillType(Colours::transparentWhite);
if (smugMug.isUploading())
{
int64 n = smugMug.getTotalbytesUploaded();
int64 d = smugMug.getTotalBytesToUpload();
double percent = (d == 0) ? 0 : (double(n)/double(d)*100);
GlyphArrangement glyphs;
glyphs.addLineOfText(Font(25.0f, Font::bold), String(percent, 1) + ("%"), 0, 0);
Path p;
glyphs.createPath(p);
juce::Rectangle<float> bounds = p.getBounds();
float cx = getWidth() / 2.0f - bounds.getWidth() / 2.0f - bounds.getX();
float cy = getHeight() / 2.0f - bounds.getHeight() / 2.0f - bounds.getY();
AffineTransform trans = AffineTransform::translation(cx, cy);
g.setColour(Colours::black);
g.fillPath(p, trans);
g.setColour(Colours::white);
g.strokePath(p, PathStrokeType(1), trans);
}
}