Skip to content

Commit 7abe979

Browse files
committed
Add basic path support
1 parent 45abd02 commit 7abe979

File tree

9 files changed

+533
-61
lines changed

9 files changed

+533
-61
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// __CGPathParseString.m
3+
// COpenSwiftUI
4+
5+
#include "__CGPathParseString.h"
6+
7+
#if OPENSWIFTUI_TARGET_OS_DARWIN
8+
BOOL __CGPathParseString(CGMutablePathRef path, const char *utf8CString) {
9+
// TODO
10+
return NO;
11+
}
12+
#endif

Sources/COpenSwiftUI/dyld_Private.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//
22
// dyld_Private.c
3-
//
4-
//
5-
//
3+
// COpenSwiftUI
64

75
#include "dyld_Private.h"
86

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// __CGPathParseString.m
3+
// COpenSwiftUI
4+
5+
#ifndef __CGPathParseString_h
6+
#define __CGPathParseString_h
7+
8+
#include "OpenSwiftUIBase.h"
9+
10+
#if OPENSWIFTUI_TARGET_OS_DARWIN
11+
12+
#include <Foundation/Foundation.h>
13+
#include <CoreGraphics/CoreGraphics.h>
14+
15+
OPENSWIFTUI_ASSUME_NONNULL_BEGIN
16+
17+
OPENSWIFTUI_EXPORT
18+
BOOL __CGPathParseString(CGMutablePathRef path, const char *utf8CString);
19+
20+
OPENSWIFTUI_ASSUME_NONNULL_END
21+
22+
#endif
23+
24+
#endif /* __CGPathParseString_h */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// UnsafeAtomicLazy.swift
3+
// OpenSwiftUI
4+
//
5+
// Audited for RELEASE_2021
6+
// Status: WIP
7+
8+
struct UnsafeAtomicLazy<Data>: Destroyable {
9+
@UnsafeLockedPointer
10+
var cache: Data?
11+
12+
func read(_ block: () -> Data) -> Data {
13+
fatalError("TODO") // StrokedPath.boundingRect
14+
}
15+
16+
func destroy() {
17+
_cache.destroy()
18+
}
19+
}

Sources/OpenSwiftUI/View/Shape/Path.swift

-58
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// FixedRoundedRect.swift
2+
// OpenSwiftUI
3+
//
4+
// Audited for RELEASE_2021
5+
// Status: WIP
6+
7+
import Foundation
8+
import CoreGraphics
9+
10+
@usableFromInline
11+
struct FixedRoundedRect: Equatable {
12+
var rect: CGRect
13+
var cornerSize: CGSize
14+
var style: RoundedCornerStyle
15+
16+
func contains(_ roundedRect: FixedRoundedRect) -> Bool {
17+
guard rect.insetBy(dx: -0.001, dy: -0.001).contains(roundedRect.rect) else {
18+
return false
19+
}
20+
guard !(cornerSize.width <= roundedRect.cornerSize.width && cornerSize.height <= roundedRect.cornerSize.height) else {
21+
return true
22+
}
23+
let minCornerWidth = min(abs(rect.size.width) / 2, cornerSize.width)
24+
let minCornerHeight = min(abs(rect.size.height) / 2, cornerSize.height)
25+
let factor = 1 - cos(45 * Double.pi / 180) // const value 0.292893
26+
return rect.insetBy(dx: minCornerWidth * factor, dy: minCornerHeight * factor).contains(roundedRect.rect)
27+
}
28+
29+
func distance(to point: CGPoint) -> CGFloat {
30+
fatalError("TODO")
31+
}
32+
}

0 commit comments

Comments
 (0)