Skip to content

Commit

Permalink
remove rescaling during resize again
Browse files Browse the repository at this point in the history
was only meant for illustration purposes for #104
  • Loading branch information
dmrschmidt committed Oct 10, 2024
1 parent c2e5261 commit 5f1ce68
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions Sources/DSWaveformImageViews/SwiftUI/WaveformView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public struct WaveformView<Content: View>: View {
public var body: some View {
GeometryReader { geometry in
content(WaveformShape(samples: samples, configuration: configuration, renderer: renderer))
.scaleEffect(x: scaleDuringResize(for: geometry), y: 1, anchor: .trailing)
.onAppear {
guard samples.isEmpty else { return }
update(size: geometry.size, url: audioURL, configuration: configuration)
Expand Down Expand Up @@ -78,18 +77,6 @@ public struct WaveformView<Content: View>: View {
updateTask(nil)
}
}

/*
* During resizing, we only visually scale the shape to make it look more seamless,
* before we re-calculate the pixel-perfect re-sampled waveform, which is costly.
* Due to the complex way we need to render the actual waveform based on samples
* available and size to occupy, the re-scaling currently only supports enlarging.
* If we resize to a smaller size, the waveform simply overflows.
*/
private func scaleDuringResize(for geometry: GeometryProxy) -> CGFloat {
guard currentSize != .zero else { return 1 }
return max(geometry.size.width / currentSize.width, 1)
}
}

public extension WaveformView {
Expand Down

0 comments on commit 5f1ce68

Please sign in to comment.