import Foundation import RxSwift public class Shape: Node { public let formVar: Variable public var form: Locus { get { return formVar.value } set(val) { formVar.value = val } } public let fillVar: Variable public var fill: Fill? { get { return fillVar.value } set(val) { fillVar.value = val } } public let strokeVar: Variable public var stroke: Stroke? { get { return strokeVar.value } set(val) { strokeVar.value = val } } public let onTap = PublishSubject() public let onPan = PublishSubject() public let onRotate = PublishSubject() public let onPinch = PublishSubject() public init(form: Locus, fill: Fill? = nil, stroke: Stroke? = nil, pos: Transform = Transform(), opaque: NSObject = true, opacity: Double = 1, clip: Locus? = nil, visible: NSObject = true, tag: [String] = [], bounds: Rect? = nil) { self.formVar = Variable(form) self.fillVar = Variable(fill) self.strokeVar = Variable(stroke) super.init( pos: pos, opaque: opaque, opacity: opacity, clip: clip, visible: visible, tag: tag, bounds: bounds ) } // GENERATED NOT override public func bounds() -> Rect? { // TODO: Implement more form types var bounds = Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0) if let path = form as? Path { bounds = pathBounds(path)! } else if let circle = form as? Circle { bounds = Rect( x: circle.cx - circle.r, y: circle.cy - circle.r, w: circle.r * 2.0, h: circle.r * 2.0) } else if let ellipse = form as? Ellipse { bounds = Rect( x: ellipse.cx - ellipse.rx, y: ellipse.cy - ellipse.ry, w: ellipse.rx * 2.0, h: ellipse.ry * 2.0) } else if let rect = form as? Rect { bounds = rect } else { bounds = form.bounds() } return bounds } }