aboutsummaryrefslogtreecommitdiff
path: root/src/osx/graphics/quartz/Geometry.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-02 19:33:18 +0800
committercrupest <crupest@outlook.com>2022-03-02 19:33:18 +0800
commit3e11b954a73d4718750b130abd6f511e624ffce7 (patch)
tree5513f49ff345ff8a33df63371e35352efa6af864 /src/osx/graphics/quartz/Geometry.cpp
parenta310733b429a99aff14d840f6de663a685917d00 (diff)
downloadcru-3e11b954a73d4718750b130abd6f511e624ffce7.tar.gz
cru-3e11b954a73d4718750b130abd6f511e624ffce7.tar.bz2
cru-3e11b954a73d4718750b130abd6f511e624ffce7.zip
...
Diffstat (limited to 'src/osx/graphics/quartz/Geometry.cpp')
-rw-r--r--src/osx/graphics/quartz/Geometry.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/osx/graphics/quartz/Geometry.cpp b/src/osx/graphics/quartz/Geometry.cpp
index 87ddff3e..c88add87 100644
--- a/src/osx/graphics/quartz/Geometry.cpp
+++ b/src/osx/graphics/quartz/Geometry.cpp
@@ -15,6 +15,24 @@ bool QuartzGeometry::FillContains(const Point &point) {
kCGPathFill);
}
+Rect QuartzGeometry::GetBounds() {
+ auto bounds = CGPathGetPathBoundingBox(cg_path_);
+ if (CGRectIsNull(bounds)) return {};
+ return Convert(bounds);
+}
+
+std::unique_ptr<IGeometry> QuartzGeometry::Transform(const Matrix &matrix) {
+ auto cg_matrix = Convert(matrix);
+ auto cg_path = CGPathCreateCopyByTransformingPath(cg_path_, &cg_matrix);
+ return std::make_unique<QuartzGeometry>(GetGraphicsFactory(), cg_path);
+}
+
+std::unique_ptr<IGeometry> QuartzGeometry::CreateStrokeGeometry(float width) {
+ auto cg_path = CGPathCreateCopyByStrokingPath(
+ cg_path_, nullptr, width, kCGLineCapButt, kCGLineJoinMiter, 10);
+ return std::make_unique<QuartzGeometry>(GetGraphicsFactory(), cg_path);
+}
+
QuartzGeometryBuilder::QuartzGeometryBuilder(IGraphicsFactory *graphics_factory)
: OsxQuartzResource(graphics_factory) {
cg_mutable_path_ = CGPathCreateMutable();