diff options
author | crupest <crupest@outlook.com> | 2022-05-15 14:08:06 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-15 14:08:06 +0800 |
commit | 8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (patch) | |
tree | 77e41cc14264060517c0f7ed95837012afb8342e /src/platform/graphics/quartz/Brush.cpp | |
parent | 9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752 (diff) | |
download | cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.gz cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.bz2 cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.zip |
...
Diffstat (limited to 'src/platform/graphics/quartz/Brush.cpp')
-rw-r--r-- | src/platform/graphics/quartz/Brush.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/platform/graphics/quartz/Brush.cpp b/src/platform/graphics/quartz/Brush.cpp new file mode 100644 index 00000000..2aa31bd8 --- /dev/null +++ b/src/platform/graphics/quartz/Brush.cpp @@ -0,0 +1,36 @@ +#include "cru/platform/graphics/quartz/Brush.h" +#include "cru/common/String.h" +#include "cru/common/Format.h" + +namespace cru::platform::graphics::quartz { +QuartzSolidColorBrush::QuartzSolidColorBrush(IGraphicsFactory* graphics_factory, + const Color& color) + : QuartzBrush(graphics_factory), color_(color) { + cg_color_ = + CGColorCreateGenericRGB(color.GetFloatRed(), color.GetFloatGreen(), + color.GetFloatBlue(), color.GetFloatAlpha()); + Ensures(cg_color_); +} + +QuartzSolidColorBrush::~QuartzSolidColorBrush() { CGColorRelease(cg_color_); } + +void QuartzSolidColorBrush::SetColor(const Color& color) { + color_ = color; + CGColorRelease(cg_color_); + cg_color_ = + CGColorCreateGenericRGB(color.GetFloatRed(), color.GetFloatGreen(), + color.GetFloatBlue(), color.GetFloatAlpha()); + Ensures(cg_color_); +} + +void QuartzSolidColorBrush::Select(CGContextRef context) { + Expects(context); + Expects(cg_color_); + CGContextSetStrokeColorWithColor(context, cg_color_); + CGContextSetFillColorWithColor(context, cg_color_); +} + +String QuartzSolidColorBrush::GetDebugString() { + return Format(u"QuartzSolidColorBrush(Color: {})", color_); +} +} // namespace cru::platform::graphics::quartz |