Skip to content

Commit

Permalink
fix last column in striped rendering not rendering as proper bar
Browse files Browse the repository at this point in the history
it was only a thin line before
  • Loading branch information
dmrschmidt committed Jan 16, 2024
1 parent c345203 commit 4c56578
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public struct LinearWaveformRenderer: WaveformRenderer {
let positionAdjustedGraphCenter = position.offset() * graphRect.size.height
let drawMappingFactor = graphRect.size.height * configuration.verticalScalingFactor
let minimumGraphAmplitude: CGFloat = 1 / configuration.scale // we want to see at least a 1px line for silence
var lastXPos: CGFloat = 0

for (index, sample) in samples.enumerated() {
let adjustedIndex: Int
Expand All @@ -74,6 +75,7 @@ public struct LinearWaveformRenderer: WaveformRenderer {
let drawingAmplitude = max(minimumGraphAmplitude, invertedDbSample * drawMappingFactor)
let drawingAmplitudeUp = positionAdjustedGraphCenter - drawingAmplitude
let drawingAmplitudeDown = positionAdjustedGraphCenter + drawingAmplitude
lastXPos = xPos

switch sides {
case .up:
Expand All @@ -88,6 +90,10 @@ public struct LinearWaveformRenderer: WaveformRenderer {
}
}

if case .striped = configuration.style {
path.move(to: CGPoint(x: lastXPos, y: positionAdjustedGraphCenter))
}

return path
}
}

0 comments on commit 4c56578

Please sign in to comment.