Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>TransformGesture.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>2</integer>
</dict>
</dict>
</dict>
Expand Down
Binary file modified Example/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -373,6 +374,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Binary file not shown.

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Example/Example/BuildingBlocks/RenderParticles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ struct RenderParticles<T: RenderableParticle>: MetalBuildingBlock {
let particlesBuffer: MTLBufferContainer<T>
let toTexture: MTLTextureContainer? = nil

@ObservedObject var transform: TouchTransform
let transform: TouchTransform

var metalContent: MetalContent{
var transform = Bindable(transform)
Render(type: .point, count: particlesCount)
.toTexture(toTexture)
.vertexBuf(particlesBuffer, name: "particles")
.vertexBytes($transform.matrix, type: "float3x3", name: "transform")
.vertexBytes(transform.matrix, type: "float3x3", name: "transform")
.vertexBytes(context.$viewportToDeviceTransform)
.vertexBytes($transform.floatScale, type: "float", name: "scale")
.vertexBytes(transform.floatScale, type: "float", name: "scale")
.vertexBytes(context.$scaleFactor)
.pipelineColorAttachment(pipColorDesc)
.colorAttachement(
Expand Down
6 changes: 3 additions & 3 deletions Example/Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct ContentView: View {
@MetalState var particlesCountState = particlesCount
@MetalState var canvasSizeState = canvasSize

@StateObject var transform = TouchTransform(
@State var transform = TouchTransform(
translation: CGSize(width: 0,
height:0),
scale: 1,
Expand Down Expand Up @@ -97,7 +97,7 @@ struct ContentView: View {
Rectangle()
.fill(Color.gray)
.frame(width: CGFloat(canvasSize.x), height: CGFloat(canvasSize.y))
.transformEffect(transform)
.transformEffect($transform)
MetalBuilderView(viewSettings: viewSettings) { context in
EncodeGroup(active: $justStarted){
ClearRender()
Expand Down Expand Up @@ -242,7 +242,7 @@ struct ContentView: View {
.fill(Color.clear)
.border(Color.white, width: transform.scaleSnapped ? 2 : 1)
.frame(width: CGFloat(canvasSize.x), height: CGFloat(canvasSize.y))
.transformEffect(transform)
.transformEffect($transform)
let offset = CGSize(width: transform.centerPoint.x,
height: transform.centerPoint.y)
ZStack{
Expand Down
14 changes: 7 additions & 7 deletions Example/Example/HapticsEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@ import TransformGesture

struct HapticsEffects: ViewModifier {

@ObservedObject var transform: TouchTransform
let transform: TouchTransform

@Environment(\.scenePhase) var scenePhase
@State var hapticsEngine = HapticsEngine()

func body(content: Content) -> some View {
content
.onChange(of: transform.offset) { newValue in
.onChange(of: transform.offset) { newValue, oldValue in
hapticsEngine.onDraw()
}
.onChange(of: transform.translationXSnapped) { newValue in
.onChange(of: transform.translationXSnapped) { newValue, oldValue in
if newValue{
hapticsEngine.onSnap()
}else{
hapticsEngine.offSnap()
}
}
.onChange(of: transform.translationYSnapped) { newValue in
.onChange(of: transform.translationYSnapped) { newValue, oldValue in
if newValue{
hapticsEngine.onSnap()
}else{
hapticsEngine.offSnap()
}
}
.onChange(of: transform.rotationSnapped) { newValue in
.onChange(of: transform.rotationSnapped) { newValue, oldValue in
if newValue{
hapticsEngine.onSnap()
}else{
hapticsEngine.offSnap()
}
}
.onChange(of: transform.scaleSnapped) { newValue in
.onChange(of: transform.scaleSnapped) { newValue, oldValue in
if newValue{
hapticsEngine.onSnap()
}else{
hapticsEngine.offSnap()
}
}
.onChange(of: scenePhase) { newValue in
.onChange(of: scenePhase) { newValue, oldValue in
if newValue == .active{
hapticsEngine.start()
}
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// swift-tools-version: 5.6
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "TransformGesture",
platforms: [.iOS(.v15)],
platforms: [.iOS(.v17)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
Loading
Loading