I'm building a graphics app for iOS. Here is my code.
class Group {
/// All the shapes contained in the group
public var shapes: CurrentValueSubject<[Shape], Never>
/// The frame of the group
var frame: CurrentValueSubject<CGRect, Never>
/// The path to be calculated and displayed to users from the contained shapes
var cgPath: CurrentValueSubject<CGPath, Never>
}
class Shape {
var path: CurrentValueSubject<Path, Never> = .init(Path())
}
struct Path {
public var points = [CGPoint]()
}
So, here is what I want to do but don't know how to do it with Combine.
I want Group to observe it's own frame, shapes, and the path of it's shapes (I need to merge all this), so every time each of they change, I can calculate the new CGPath to display and assign it to the cgPath property (which will be observed by the View that draws everything).
Please, let me know if this is possible or if there is a better approach to all this.
Thanks in advance.