mirror of
https://github.com/EmergeTools/Pow.git
synced 2026-03-25 08:55:50 +00:00
Compare commits
3 commits
435d6863f6
...
d0d87fed05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0d87fed05 | ||
|
|
1b4b1dda28 | ||
|
|
c17e6d986c |
14 changed files with 46 additions and 4 deletions
|
|
@ -11,7 +11,8 @@ let package = Package(
|
|||
.iOS(.v15),
|
||||
.macOS(.v12),
|
||||
.macCatalyst(.v15),
|
||||
.tvOS(.v15)
|
||||
.tvOS(.v15),
|
||||
.watchOS(.v8)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyChangeEffect {
|
||||
/// An effect that shakes the view when a change happens.
|
||||
static var shake: AnyChangeEffect {
|
||||
|
|
@ -32,7 +33,9 @@ public extension AnyChangeEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
internal struct ShakeSimulationModifier: ViewModifier, Simulative {
|
||||
// TODO: Not used, remove from protocol
|
||||
var initialVelocity: CGFloat = 0
|
||||
|
|
@ -102,6 +105,7 @@ internal struct ShakeSimulationModifier: ViewModifier, Simulative {
|
|||
shakeCount = clamp(0, shakeCount - 2 * (step / phaseLength), .infinity)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
struct ShakeSimulation_Previews: PreviewProvider {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import simd
|
|||
import SnapshotPreferences
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyConditionalEffect {
|
||||
/// An effect that emits smoke from the view.
|
||||
static var smoke: AnyConditionalEffect {
|
||||
|
|
@ -21,7 +22,9 @@ public extension AnyConditionalEffect {
|
|||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
private struct SmokeEffect: ViewModifier, Continuous {
|
||||
var isActive: Bool
|
||||
|
||||
|
|
@ -69,6 +72,7 @@ private struct SmokeEffect: ViewModifier, Continuous {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) || os(visionOS) || os(tvOS)
|
||||
private class EmitterView: UIView {
|
||||
|
|
@ -108,6 +112,7 @@ private class EmitterView: NSView {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
private struct SmokeLayerView: ViewRepresentable {
|
||||
var size: CGSize
|
||||
|
||||
|
|
@ -171,8 +176,9 @@ private struct SmokeLayerView: ViewRepresentable {
|
|||
view.emitterLayer.lifetime = isActive ? 1 : 0
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG && !os(tvOS)
|
||||
#if DEBUG && !os(tvOS) && !os(watchOS)
|
||||
struct ContinuousParticleEffect_Previews: PreviewProvider {
|
||||
private struct Preview: View {
|
||||
@State
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyChangeEffect {
|
||||
/// The rate of the spin effect.
|
||||
enum SpinRate {
|
||||
|
|
@ -52,7 +53,9 @@ public extension AnyChangeEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
internal struct SpinSimulationModifier: ViewModifier, Simulative {
|
||||
var impulseCount: Int
|
||||
|
||||
|
|
@ -150,6 +153,7 @@ internal struct SpinSimulationModifier: ViewModifier, Simulative {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
struct SpinSimulation_Previews: PreviewProvider {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyChangeEffect {
|
||||
/// An effect that wiggles the view when a change happens.
|
||||
static var wiggle: AnyChangeEffect {
|
||||
|
|
@ -30,7 +31,9 @@ public extension AnyChangeEffect {
|
|||
})
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
internal struct WiggleSimulationModifier: ViewModifier, Simulative {
|
||||
// TODO: Not used, remove from protocol
|
||||
var initialVelocity: CGFloat = 0
|
||||
|
|
@ -104,6 +107,7 @@ internal struct WiggleSimulationModifier: ViewModifier, Simulative {
|
|||
wiggleCount = clamp(0, wiggleCount - 2 * (step / phaseLength), .infinity)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import Foundation
|
|||
@available(iOS 16.0, *)
|
||||
@available(macOS 13.0, *)
|
||||
@available(tvOS 16.0, *)
|
||||
@available(watchOS 9.0, *)
|
||||
internal extension Duration {
|
||||
var timeInterval: TimeInterval {
|
||||
TimeInterval(components.seconds) + TimeInterval(components.attoseconds) / 1e18
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import simd
|
||||
import SwiftUI
|
||||
|
||||
#if !os(watchOS)
|
||||
internal extension ProjectionTransform {
|
||||
init(_ m: simd_double4x4) {
|
||||
let d = CATransform3D(
|
||||
|
|
@ -13,3 +14,4 @@ internal extension ProjectionTransform {
|
|||
self.init(d)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#if !os(tvOS)
|
||||
import SwiftUI
|
||||
|
||||
@available(watchOS 9.0, *)
|
||||
struct AngleControl<Label: View>: View {
|
||||
@Binding
|
||||
var angle: Angle
|
||||
|
|
@ -81,6 +82,7 @@ struct AngleControl<Label: View>: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(watchOS 9.0, *)
|
||||
extension AngleControl where Label == Text {
|
||||
init(_ title: some StringProtocol, angle: Binding<Angle>) {
|
||||
self._angle = angle
|
||||
|
|
@ -106,6 +108,7 @@ extension AngleControl where Label == Text {
|
|||
}
|
||||
}
|
||||
|
||||
@available(watchOS 9.0, *)
|
||||
struct AngleControl_Previews: PreviewProvider {
|
||||
struct Preview: View {
|
||||
@State var angle: Angle = .zero
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import SwiftUI
|
||||
import simd
|
||||
|
||||
#if !os(watchOS)
|
||||
internal struct Transform3DEffect: GeometryEffect, Animatable {
|
||||
var animatableData: AnimatablePair<TRS, AnimatablePair<Anchor3D, Double>> = .zero
|
||||
|
||||
|
|
@ -69,7 +70,9 @@ internal struct Transform3DEffect: GeometryEffect, Animatable {
|
|||
ShadedTransform3DEffect(animatableData: animatableData, lightSource: lightSource)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
extension Transform3DEffect {
|
||||
internal struct Anchor3D: Equatable {
|
||||
var xy: UnitPoint = .center
|
||||
|
|
@ -77,7 +80,9 @@ extension Transform3DEffect {
|
|||
var z: Double = 0
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
extension Transform3DEffect.Anchor3D: VectorArithmetic {
|
||||
mutating func scale(by rhs: Double) {
|
||||
xy.x *= rhs
|
||||
|
|
@ -111,7 +116,9 @@ extension Transform3DEffect.Anchor3D: VectorArithmetic {
|
|||
return result
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
internal struct ShadedTransform3DEffect: ViewModifier, Animatable {
|
||||
var animatableData: Transform3DEffect.AnimatableData
|
||||
|
||||
|
|
@ -147,6 +154,7 @@ internal struct ShadedTransform3DEffect: ViewModifier, Animatable {
|
|||
.modifier(Transform3DEffect(animatableData: animatableData))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
@available(iOS 16.0, *)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public struct AnyConditionalEffect {
|
|||
@available(iOS 16.0, *)
|
||||
@available(macOS 13.0, *)
|
||||
@available(tvOS 16.0, *)
|
||||
@available(watchOS 9.0, *)
|
||||
public static func `repeat`(_ effect: AnyChangeEffect, every interval: Duration) -> AnyConditionalEffect {
|
||||
AnyConditionalEffect(guts: .repeating(effect, interval.timeInterval))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ internal struct Anvil: ViewModifier, ProgressableAnimation, AnimatableModifier {
|
|||
let offsetX = maxOffsetX * (relativeX - 0.5) * 2 * .random(in: 0.8 ... 1.2, using: &rng)
|
||||
let offsetY = CGFloat.random(in: -maxOffsetY / 2 ... maxOffsetY / 2, using: &rng) + (t * t) * -50
|
||||
|
||||
var scale = 1 + 0.6 * (1 - pow(sin(relativeX * .pi), 0.4)) + .random(in: 0 ... 0.2, using: &rng)
|
||||
var scale = 1 + 0.6 * (1 - pow(sin(relativeX * CGFloat.pi), 0.4)) + .random(in: 0 ... 0.2, using: &rng)
|
||||
scale *= 0.8 + (dustT * 0.2)
|
||||
scale /= 3
|
||||
scale *= 1 - pow(2, -50 * dustT)
|
||||
|
|
@ -188,7 +188,7 @@ internal struct Anvil: ViewModifier, ProgressableAnimation, AnimatableModifier {
|
|||
ctx.translateBy(x: center.x, y: center.y)
|
||||
ctx.scaleBy(x: scale, y: scale)
|
||||
|
||||
ctx.opacity = Double(pow(sin(speckT * .pi), 0.2))
|
||||
ctx.opacity = Double(pow(sin(speckT * CGFloat.pi), 0.2))
|
||||
ctx.fill(speck, with: .color(Color(white: .random(in: 0.75 ... 0.9, using: &rng))))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import SwiftUI
|
||||
import simd
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyTransition.MovingParts {
|
||||
/// A transition that inserts by rotating the view towards the viewer, and
|
||||
/// removes by rotating the view away from the viewer.
|
||||
|
|
@ -64,6 +65,7 @@ public extension AnyTransition.MovingParts {
|
|||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
@available(iOS 15.0, *)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import SwiftUI
|
||||
import simd
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyTransition.MovingParts {
|
||||
/// A transition that moves the view from the specified edge of the on
|
||||
/// insertion and towards it on removal.
|
||||
|
|
@ -35,7 +36,9 @@ public extension AnyTransition.MovingParts {
|
|||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(watchOS)
|
||||
internal struct Move: GeometryEffect, Animatable {
|
||||
/// Translation is relative, depth is ignored, anchor is always
|
||||
/// `UnitPoint(0.5, 0.5)`.
|
||||
|
|
@ -90,6 +93,7 @@ internal struct Move: GeometryEffect, Animatable {
|
|||
return ProjectionTransform((((offset * translation) * rotation) * scale) * offset.inverse)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
@available(iOS 15.0, *)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import SwiftUI
|
||||
import simd
|
||||
|
||||
#if !os(watchOS)
|
||||
public extension AnyTransition.MovingParts {
|
||||
/// A three-dimensional transition from the back of the towards the front
|
||||
/// during insertion and from the front towards the back during removal.
|
||||
|
|
@ -21,6 +22,7 @@ public extension AnyTransition.MovingParts {
|
|||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) && DEBUG
|
||||
@available(iOS 15.0, *)
|
||||
|
|
|
|||
Loading…
Reference in a new issue