当前位置: 首页>>代码示例>>C++>>正文


C++ DrawingContext::DrawString方法代码示例

本文整理汇总了C++中DrawingContext::DrawString方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawingContext::DrawString方法的具体用法?C++ DrawingContext::DrawString怎么用?C++ DrawingContext::DrawString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DrawingContext的用法示例。


在下文中一共展示了DrawingContext::DrawString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Draw

//-----------------------------------------------------------------------
void DebugNavigator::Draw(DrawingContext & drawingContext)
{
    constexpr float minFramerate = 10.0f;
    constexpr float maxFramerate = 60.0f;
    constexpr std::uint16_t maxHistories = 20;

    {
        if (clock->TotalGameTime() - duration > Duration(0.2))
        {
            auto frameRate = clock->FrameRate();
            frameRateString = StringFormat("%4.2f fps", frameRate);
            frameRates.push_back(MathHelper::Clamp(frameRate, minFramerate, maxFramerate));

            if (frameRates.size() > maxHistories)
            {
                frameRates.pop_front();
            }
            duration = clock->TotalGameTime();
        }
    }

    auto transform = Transform() * drawingContext.Top();
    {
        auto graphTransform = Matrix3x2::CreateTranslation(Vector2{0, 16}) * transform;

        constexpr std::uint16_t maxGraphHeight = 26;
        constexpr float graphMarginLeft = 1.0f;

        auto graghWidth = (static_cast<float>(Width()) / maxHistories);

        std::int32_t startPosition = graghWidth * (maxHistories - frameRates.size());
        std::int32_t graphX = startPosition;
        for (auto & frameRate: frameRates)
        {
            auto amount = ((frameRate - minFramerate) / (maxFramerate - minFramerate));
            auto graphHeight = MathHelper::Clamp<std::uint16_t>(maxGraphHeight * amount, 1, maxGraphHeight);

            drawingContext.DrawRectangle(graphTransform, Color::CornflowerBlue,
                Rectangle(graphX, maxGraphHeight - graphHeight, graghWidth - graphMarginLeft, graphHeight));
            graphX += graghWidth;
        }
    }

    drawingContext.DrawString(transform * Matrix3x2::CreateTranslation({0.5f, -2.5f}),
        Color::White, FontWeight::Bold, FontSize::Medium, frameRateString);
}
开发者ID:Mourtz,项目名称:pomdog,代码行数:47,代码来源:DebugNavigator.cpp

示例2: Draw

//-----------------------------------------------------------------------
void TextBlock::Draw(DrawingContext & drawingContext)
{
    auto transform = Transform() * drawingContext.Top();

    drawingContext.DrawString(transform, Color::White, FontWeight::Normal, FontSize::Medium, text);
}
开发者ID:Mourtz,项目名称:pomdog,代码行数:7,代码来源:TextBlock.cpp


注:本文中的DrawingContext::DrawString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。