                     path.addLineToPoint(point2)
                     path.addLineToPoint(point3)
                     UIColor.whiteColor().set()
-                    //path.stroke()
+                    // path.stroke()
                     path.fill()
-                    //path2.stroke()
+                    // path2.stroke()
                     path2.fill()
                 }
-            }
-
-        }
-        
-        //处理未显示完全的长按部分
-        for i in 1...5 {
-            if positionPressed[i-1] != 0 {
-                let path = pathForLongPress(i, sec1: positionPressed[i-1], y: rect.origin.y)
-                positionPressed[i-1] = 0
-                strokeColor.colorWithAlphaComponent(0.5).set()
-                //path.stroke()
-                path.fill()
-            }
-        }
-        
-        
-        
-    }
-    
-    func initWith(beatmap:CGSSBeatmap, bpm:Int, type:Int) {
+                
+            }
+        }
+    }
+    
+    func initWith(beatmap: CGSSBeatmap, bpm: Int, type: Int) {
         self.beatmap = beatmap
         self.notes = beatmap.notes
         self.bpm = bpm


import UIKit

class BeatmapView: UIScrollView , UIScrollViewDelegate {

    static let widthInset:CGFloat = 100
    static let sectionHeight:CGFloat = 245
    static let heightInset:CGFloat = 60
    static let noteRadius:CGFloat = 7
    
    var beatmap:CGSSBeatmap!
    var notes:[CGSSBeatmap.Note]!
    var bpm:Int!
    var interval: CGFloat {
        return (CGSSTool.width - 2 * BeatmapView.widthInset ) / 4
    }
    
    var secScale: CGFloat {
        return BeatmapView.sectionHeight * (CGFloat(bpm) / 60 / 4)
    }
    
    
    var strokeColor:UIColor!
    
    private var lineWidth: CGFloat = 1
    func getPointX(position:Int) -> CGFloat {
        return BeatmapView.widthInset + interval * (CGFloat(position) - 1)
    }
    
    func getPointY(sec:Float) -> CGFloat {
        return contentSize.height - CGFloat(sec - self.beatmap.preSeconds!) * secScale - BeatmapView.heightInset
    }
    
    
    override func drawRect(rect: CGRect) {

        //画小节线
        let halfquadSectionMax = Int(((contentSize.height - rect.origin.y - BeatmapView.heightInset) / BeatmapView.sectionHeight * 8))
        let halfquadSectionMin = Int(((contentSize.height - frame.size.height - rect.origin.y - BeatmapView.heightInset) / BeatmapView.sectionHeight * 8))
        for i in halfquadSectionMin...halfquadSectionMax {
            let pointY = contentSize.height - BeatmapView.heightInset - CGFloat(i) * BeatmapView.sectionHeight / 8
            if i % 8 == 0 {
                UIColor.darkGrayColor().set()
                let sectionNumber:NSString = NSString.init(format: "%03d", i / 8)
                let attDict = [NSFontAttributeName: UIFont.systemFontOfSize(12), NSForegroundColorAttributeName: UIColor.darkGrayColor()]
                sectionNumber.drawAtPoint(CGPointMake(25, pointY-7), withAttributes: attDict )
                let comboNumber:NSString = NSString.init(format: "%d", beatmap.comboForSec(Float(i / 8) / (Float(bpm) / 60 / 4)))
                comboNumber.drawAtPoint(CGPointMake(CGSSTool.width - 46, pointY-7), withAttributes: attDict)
            }
            else if i % 2 == 0 { UIColor.lightGrayColor().set() }
            else { UIColor.lightGrayColor().colorWithAlphaComponent(0.5).set() }

        self.contentOffset = CGPointMake(0, self.contentSize.height - self.frame.size.height)
        self.delegate = self
    }
    
    private func pathForPoint(position: Int, sec: Float) -> UIBezierPath
    {
        let radius = BeatmapView.noteRadius
        let center = CGPointMake(getPointX(position), getPointY(sec))
        return pathForCircleCenteredAtPoint(center, withRadius: radius)
    }
    private func pathForPointSmall(position: Int, sec: Float) -> UIBezierPath
    {
        let radius = BeatmapView.noteRadius / 2
        let center = CGPointMake(getPointX(position), getPointY(sec))
        return pathForCircleCenteredAtPoint(center, withRadius: radius)
    }
    private func pathForSyncLine(note1: CGSSBeatmap.Note, note2: CGSSBeatmap.Note) -> UIBezierPath
    {
        let x1 = getPointX(note1.finishPos!)
        let x2 = getPointX(note2.finishPos!)
        let y = getPointY(note1.sec!)
        
        let path = UIBezierPath()
        path.moveToPoint(CGPointMake(x1, y))
        path.addLineToPoint(CGPointMake(x2, y))
        path.lineWidth = 3
        return path
        
    }
    
    private func pathForLongPress(position: Int, sec1: Float, sec2: Float) -> UIBezierPath {
        let x = getPointX(position)
        let y1 = getPointY(sec1)
        let y2 = getPointY(sec2)
        let r = BeatmapView.noteRadius
        let path = UIBezierPath.init(rect: CGRectMake(x - r, y2, r * 2, y1 - y2))
        return path
    }
    
    private func pathForSlider(note1: CGSSBeatmap.Note, note2: CGSSBeatmap.Note) -> UIBezierPath? {
        
        let x1 = getPointX(note1.finishPos!)
        let x2 = getPointX(note2.finishPos!)
        let y1 = getPointY(note1.sec!)
        let y2 = getPointY(note2.sec!)
        // 个别情况下滑条的组id会重复使用,为了避免这种情况带来的错误,当滑条的点间距大于1个section时,失效
        if y1 - y2 > BeatmapView.sectionHeight {
            return nil
        }
        
        let t = atan((y1 - y2) / (x2 - x1))
        let r = BeatmapView.noteRadius - 2
        let path = UIBezierPath()
        path.moveToPoint(CGPointMake(x1 - sin(t) * r, y1 - cos(t) * r))
        path.addLineToPoint(CGPointMake(x1 + sin(t) * r, y1 + cos(t) * r))
        path.addLineToPoint(CGPointMake(x2 + sin(t) * r, y2 + cos(t) * r))
        path.addLineToPoint(CGPointMake(x2 - sin(t) * r, y2 - cos(t) * r))
        return path
    }
    
    private func pathForLongPress(position: Int, sec1: Float, y: CGFloat) -> UIBezierPath {
        let x = getPointX(position)
        let y1 = getPointY(sec1)
        let path = UIBezierPath.init(rect: CGRectMake(x - BeatmapView.noteRadius, y, BeatmapView.noteRadius * 2, y1 - y))
        return path
    }
    
    private func pathForSectionLine(positionY: CGFloat) -> UIBezierPath
    {
        let path = UIBezierPath()
        path.moveToPoint(CGPoint(x: 50, y: positionY))
