Skip to content

Commit 4c56578

Browse files
committed
fix last column in striped rendering not rendering as proper bar
it was only a thin line before
1 parent c345203 commit 4c56578

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Sources/DSWaveformImage/Renderers/LinearWaveformRenderer.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public struct LinearWaveformRenderer: WaveformRenderer {
4949
let positionAdjustedGraphCenter = position.offset() * graphRect.size.height
5050
let drawMappingFactor = graphRect.size.height * configuration.verticalScalingFactor
5151
let minimumGraphAmplitude: CGFloat = 1 / configuration.scale // we want to see at least a 1px line for silence
52+
var lastXPos: CGFloat = 0
5253

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

7880
switch sides {
7981
case .up:
@@ -88,6 +90,10 @@ public struct LinearWaveformRenderer: WaveformRenderer {
8890
}
8991
}
9092

93+
if case .striped = configuration.style {
94+
path.move(to: CGPoint(x: lastXPos, y: positionAdjustedGraphCenter))
95+
}
96+
9197
return path
9298
}
9399
}

0 commit comments

Comments
 (0)