diff options
Diffstat (limited to 'demos/platform')
-rw-r--r-- | demos/platform/graphics/CMakeLists.txt | 3 | ||||
-rw-r--r-- | demos/platform/graphics/DrawText.cpp | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/demos/platform/graphics/CMakeLists.txt b/demos/platform/graphics/CMakeLists.txt index ff5f64a5..07758ee6 100644 --- a/demos/platform/graphics/CMakeLists.txt +++ b/demos/platform/graphics/CMakeLists.txt @@ -5,5 +5,8 @@ target_sources(CruDemoPlatformGraphicsBase INTERFACE Base.cpp) add_executable(CruDemoPlatformGraphicsDrawCircle DrawCircle.cpp) target_link_libraries(CruDemoPlatformGraphicsDrawCircle PRIVATE CruDemoPlatformGraphicsBase) +add_executable(CruDemoPlatformGraphicsDrawText DrawText.cpp) +target_link_libraries(CruDemoPlatformGraphicsDrawText PRIVATE CruDemoPlatformGraphicsBase) + add_executable(CruDemoPlatformGraphicsSvgPath SvgPath.cpp) target_link_libraries(CruDemoPlatformGraphicsSvgPath PRIVATE CruDemoPlatformGraphicsBase) diff --git a/demos/platform/graphics/DrawText.cpp b/demos/platform/graphics/DrawText.cpp new file mode 100644 index 00000000..5de5e127 --- /dev/null +++ b/demos/platform/graphics/DrawText.cpp @@ -0,0 +1,21 @@ +#include "Base.h" +#include "cru/platform/Color.h" +#include "cru/platform/graphics/Factory.h" +#include "cru/platform/graphics/Font.h" +#include "cru/platform/graphics/Painter.h" + +#include <memory> + +int main() { + CruPlatformGraphicsDemo demo("draw-text-demo.png", 500, 200); + + auto brush = + demo.GetFactory()->CreateSolidColorBrush(cru::platform::colors::skyblue); + + std::shared_ptr<cru::platform::graphics::IFont> font( + demo.GetFactory()->CreateFont(u"", 24)); + auto text_layout = demo.GetFactory()->CreateTextLayout(font, u"Hello world!"); + demo.GetPainter()->DrawText({0, 0}, text_layout.get(), brush.get()); + + return 0; +} |