Skip to content

Commit

Permalink
Remove UIGraphicsGetCurrentContext from loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jyunderwood committed Sep 5, 2016
1 parent 18ea31a commit 442cc68
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions WaveformView/WaveformView/WaveformView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,15 @@ public class WaveformView: UIView {
}

override public func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
context?.clear(bounds)
let context = UIGraphicsGetCurrentContext()!
context.clear(bounds)

backgroundColor?.set()
context?.fill(rect)
context.fill(rect)

// Draw multiple sinus waves, with equal phases but altered
// amplitudes, multiplied by a parable function.
for waveNumber in 0...numberOfWaves {
let context = UIGraphicsGetCurrentContext()!

context.setLineWidth((waveNumber == 0 ? primaryWaveLineWidth : secondaryWaveLineWidth))

let halfHeight = bounds.height / 2.0
Expand Down

0 comments on commit 442cc68

Please sign in to comment.