Created
October 9, 2020 20:21
-
-
Save rudrankriyam/c68d1bd27308c8a84a171e7a521e1203 to your computer and use it in GitHub Desktop.
Protocols of Gradient Game
This file contains hidden or 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
| import SwiftUI | |
| protocol ColorProtocol { | |
| var red: Double { get set } | |
| var green: Double { get set } | |
| var blue: Double { get set } | |
| func newColor() -> Color | |
| } | |
| extension ColorProtocol { | |
| func newColor() -> Color { | |
| Color(red: red, green: green, blue: blue, opacity: 1.0) | |
| } | |
| } |
This file contains hidden or 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
| import SwiftUI | |
| protocol GradientProtocol { | |
| var leftColor: ColorProtocol { get set } | |
| var rightColor: ColorProtocol { get set } | |
| func newGradient() -> Gradient | |
| } | |
| extension GradientProtocol { | |
| func newGradient() -> Gradient { | |
| Gradient(colors: [leftColor.newColor(), rightColor.newColor()]) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment