-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2adaf1a
commit 6fec818
Showing
17 changed files
with
192 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+15.4 KB
(140%)
Download/ShaderNodeEditor.playgroundbook/Contents/PrivateResources/AudioShader.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions
34
Download/ShaderNodeEditor.playgroundbook/Contents/PrivateResources/NodeList.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
FloatTimeNodeData | ||
FloatAudioDBNodeData | ||
FloatAtanNodeData | ||
Vec2RulerGeneratorNodeData | ||
FloatGeneratorNodeData | ||
FloatSliderGeneratorNodeData | ||
Vec2RulerGeneratorNodeData | ||
Vec2GeneratorNodeData | ||
FloatRayDiscNodeData | ||
FloatCircleOutlineNodeData | ||
FloatCircleNodeData | ||
Vec2ChannelCombineNodeData | ||
FloatAddNodeData | ||
FloatAddWithValueNodeData | ||
FloatMinusNodeData | ||
FloatMultiplyNodeData | ||
FloatMultiplyWithValueNodeData | ||
FloatAtanNodeData | ||
Vec2AddNodeData | ||
FloatSmoothStepNodeData | ||
Vec2MinusNodeData | ||
Vec2TexCoordNodeData | ||
FloatAddNodeData | ||
Vec2ChannelSplitNodeData | ||
FloatSinNodeData | ||
Vec2GeneratorNodeData | ||
Vec2LengthNodeData | ||
FloatMinusNodeData | ||
Vec2ChannelCombineNodeData | ||
Vec2ChannelSplitNodeData | ||
Vec4ChannelCombineNodeData | ||
FloatSmoothStepWithRangeNodeData | ||
FloatMultiplyWithValueNodeData | ||
FloatAddWithValueNodeData | ||
FloatStepNodeData | ||
FloatMultiplyNodeData | ||
FloatRayDiscNodeData | ||
FloatCircleOutlineNodeData | ||
Vec2MinusNodeData | ||
FloatSmoothStepNodeData | ||
FloatSmoothStepWithRangeNodeData | ||
FloatSinNodeData | ||
FloatUVCenterAtanNodeData | ||
FloatSliderGeneratorNodeData |
61 changes: 61 additions & 0 deletions
61
...tor.playgroundbook/Contents/UserModules/UserModule.playgroundmodule/Sources/Binding.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// Binding.swift | ||
// UserModule | ||
// | ||
// Created by fincher on 5/13/20. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import UIKit | ||
/// A custom subscription to capture UIControl target events. | ||
final class UIControlSubscription<SubscriberType: Subscriber, Control: UIControl>: Subscription where SubscriberType.Input == Control { | ||
private var subscriber: SubscriberType? | ||
private let control: Control | ||
|
||
init(subscriber: SubscriberType, control: Control, event: UIControl.Event) { | ||
self.subscriber = subscriber | ||
self.control = control | ||
control.addTarget(self, action: #selector(eventHandler), for: event) | ||
} | ||
|
||
func request(_ demand: Subscribers.Demand) { | ||
// We do nothing here as we only want to send events when they occur. | ||
// See, for more info: https://developer.apple.com/documentation/combine/subscribers/demand | ||
} | ||
|
||
func cancel() { | ||
subscriber = nil | ||
} | ||
|
||
@objc private func eventHandler() { | ||
_ = subscriber?.receive(control) | ||
} | ||
} | ||
|
||
struct UIControlPublisher<Control: UIControl>: Publisher { | ||
|
||
typealias Output = Control | ||
typealias Failure = Never | ||
|
||
let control: Control | ||
let controlEvents: UIControl.Event | ||
|
||
init(control: Control, events: UIControl.Event) { | ||
self.control = control | ||
self.controlEvents = events | ||
} | ||
|
||
func receive<S>(subscriber: S) where S : Subscriber, S.Failure == UIControlPublisher.Failure, S.Input == UIControlPublisher.Output { | ||
let subscription = UIControlSubscription(subscriber: subscriber, control: control, event: controlEvents) | ||
subscriber.receive(subscription: subscription) | ||
} | ||
} | ||
|
||
protocol CombineCompatible { } | ||
extension UIControl: CombineCompatible { } | ||
extension CombineCompatible where Self: UIControl { | ||
func publisher(for events: UIControl.Event) -> UIControlPublisher<UIControl> { | ||
return UIControlPublisher(control: self, events: events) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
FloatTimeNodeData | ||
FloatAudioDBNodeData | ||
FloatAtanNodeData | ||
Vec2RulerGeneratorNodeData | ||
FloatGeneratorNodeData | ||
FloatSliderGeneratorNodeData | ||
Vec2RulerGeneratorNodeData | ||
Vec2GeneratorNodeData | ||
FloatRayDiscNodeData | ||
FloatCircleOutlineNodeData | ||
FloatCircleNodeData | ||
Vec2ChannelCombineNodeData | ||
FloatAddNodeData | ||
FloatAddWithValueNodeData | ||
FloatMinusNodeData | ||
FloatMultiplyNodeData | ||
FloatMultiplyWithValueNodeData | ||
FloatAtanNodeData | ||
Vec2AddNodeData | ||
FloatSmoothStepNodeData | ||
Vec2MinusNodeData | ||
Vec2TexCoordNodeData | ||
FloatAddNodeData | ||
Vec2ChannelSplitNodeData | ||
FloatSinNodeData | ||
Vec2GeneratorNodeData | ||
Vec2LengthNodeData | ||
FloatMinusNodeData | ||
Vec2ChannelCombineNodeData | ||
Vec2ChannelSplitNodeData | ||
Vec4ChannelCombineNodeData | ||
FloatSmoothStepWithRangeNodeData | ||
FloatMultiplyWithValueNodeData | ||
FloatAddWithValueNodeData | ||
FloatStepNodeData | ||
FloatMultiplyNodeData | ||
FloatRayDiscNodeData | ||
FloatCircleOutlineNodeData | ||
Vec2MinusNodeData | ||
FloatSmoothStepNodeData | ||
FloatSmoothStepWithRangeNodeData | ||
FloatSinNodeData | ||
FloatUVCenterAtanNodeData | ||
FloatSliderGeneratorNodeData |
61 changes: 61 additions & 0 deletions
61
PlaygroundBook/UserModules/UserModule.playgroundmodule/Sources/Binding.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// Binding.swift | ||
// UserModule | ||
// | ||
// Created by fincher on 5/13/20. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import UIKit | ||
/// A custom subscription to capture UIControl target events. | ||
final class UIControlSubscription<SubscriberType: Subscriber, Control: UIControl>: Subscription where SubscriberType.Input == Control { | ||
private var subscriber: SubscriberType? | ||
private let control: Control | ||
|
||
init(subscriber: SubscriberType, control: Control, event: UIControl.Event) { | ||
self.subscriber = subscriber | ||
self.control = control | ||
control.addTarget(self, action: #selector(eventHandler), for: event) | ||
} | ||
|
||
func request(_ demand: Subscribers.Demand) { | ||
// We do nothing here as we only want to send events when they occur. | ||
// See, for more info: https://developer.apple.com/documentation/combine/subscribers/demand | ||
} | ||
|
||
func cancel() { | ||
subscriber = nil | ||
} | ||
|
||
@objc private func eventHandler() { | ||
_ = subscriber?.receive(control) | ||
} | ||
} | ||
|
||
struct UIControlPublisher<Control: UIControl>: Publisher { | ||
|
||
typealias Output = Control | ||
typealias Failure = Never | ||
|
||
let control: Control | ||
let controlEvents: UIControl.Event | ||
|
||
init(control: Control, events: UIControl.Event) { | ||
self.control = control | ||
self.controlEvents = events | ||
} | ||
|
||
func receive<S>(subscriber: S) where S : Subscriber, S.Failure == UIControlPublisher.Failure, S.Input == UIControlPublisher.Output { | ||
let subscription = UIControlSubscription(subscriber: subscriber, control: control, event: controlEvents) | ||
subscriber.receive(subscription: subscription) | ||
} | ||
} | ||
|
||
protocol CombineCompatible { } | ||
extension UIControl: CombineCompatible { } | ||
extension CombineCompatible where Self: UIControl { | ||
func publisher(for events: UIControl.Event) -> UIControlPublisher<UIControl> { | ||
return UIControlPublisher(control: self, events: events) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters