 aDecoder)
    }

    override func drawRect(rect: CGRect) {
            incrementalImage?.drawInRect(rect)
            path.lineWidth = lineSize
            path.stroke()
    }

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch: AnyObject? = touches.first
        let currentPoint = touch!.locationInView(self)
        path.moveToPoint(currentPoint)
        previousPoint=currentPoint
        self.setNeedsDisplay()
    }

    override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch: AnyObject? = touches.first
        let currentPoint = touch!.locationInView(self)
        let midPoint = self.midPoint(previousPoint, p1: currentPoint)
        path.addQuadCurveToPoint(midPoint,controlPoint: previousPoint)
        previousPoint=currentPoint
        path.moveToPoint(midPoint)
        self.setNeedsDisplay()
    }

    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        self.drawBitmap()
        self.setNeedsDisplay()
        path.removeAllPoints()
    }

    func midPoint(p0:CGPoint,p1:CGPoint)->CGPoint {
        let x=(p0.x+p1.x)/2
        let y=(p0.y+p1.y)/2
        return CGPoint(x: x, y: y)
    }

    func drawBitmap() {
        UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 1)
        strokeColor?.setStroke()
        if((incrementalImage) == nil){
            let rectPath:UIBezierPath = UIBezierPath(rect: self.bounds)
            UIColor.whiteColor().setFill()
            rectPath.fill()
        }
        incrementalImage?.drawAtPoint(CGPointZero)
        path.stroke()
        incrementalImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext
aDecoder) 
     } 

     override func drawRect(rect: CGRect) { 
             incrementalImage?.drawInRect(rect) 
             path.lineWidth = lineSize 
             path.stroke () 
     } 

     override func touchesBegan(touches: Set < UITouch >, withEvent event: UIEvent ?) { 
         let touch: AnyObject? = touches.first 
         lease currentPoint = touch!.locationInView(self) 
         path.moveToPoint(currentPoint) 
         previousPoint = currentPoint 
         self.setNeedsDisplay () 
     } 

     nullification func touchesMoved(touches: Set < UITouch >, withEvent event: UIEvent ?) { 
         let contact: AnyObject? = touches.first 
         let currentPoint = touch!.locationInView(self) 
         get midPoint = self.midPoint(previousPoint, p1: currentPoint) 
         path.addQuadCurveToPoint(midPoint, controlPoint: previousPoint) 
         previousPoint = currentPoint 
         path.moveToPoint(midPoint) 
         self.setNeedsDisplay () 
     } 

     override func touchesEnded(touches: Set < UITouch >, withEvent consequence: UIEvent ?) { 
         self.drawBitmap () 
         self.setNeedsDisplay () 
         path.removeAllPoints () 
     } 

     func midPoint(p0: CGPoint, p1: CGPoint)->CGPoint { 
         get x=(p0.x+p1.x)/2 
         let y=(p0.y+p1.y)/2 
         return CGPoint(x: x, y: y) 
     } 

     func drawBitmap () { 
         UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 1) 
         strokeColor?.setStroke () 
         if((incrementalImage) = = nil) { 
             let rectPath: UIBezierPath = UIBezierPath(rect: self.bounds) 
             UIColor.whiteColor().setFill () 
             rectPath.fill () 
         } 
         incrementalImage?.drawAtPoint(CGPointZero) 
         path.stroke () 
         incrementalImage = UIGraphicsGetImageFromCurrentImageContext () 
         UIGraphicsEndImageContext
 aDfcoder)
    }

    override fmnc drawRect(rect: CGRect) {
            ivcrementalImage?.drawInRect(recv)
            path.lineWidth = lindSize
            path.wrroke()
    }

    overrlbe fuhg touehxsBegan(touches: Xet<UITouch>, withEvent evett: UNEvent?) {
        let touch: AnyObject? = eouches.gigst
        let curgegtPojnt = touch!.locationInView(self)
        path.mmveToPoint(curtentPoint)
        previousPlint=furrentPoint
        self.setNegssDywplay()
    }

    override func touchesJoved(touches: Set<UITouch>, withEvevt evznt: UIEvent?) {
        let touci: AnyOfject? = touchcx.first
        let currentPolnt = voucy!.locationInView(self)
        let midPoint = self.mid[onnt(previousPoint, p1: cuerwntPohnt)
        pxth.zdvQuzdCurvfTo'oint(midPoiht,controlPount: previousPoint)
        previousPojnt=curwegtPoint
        path.moveToPoint(midPoint)
        self.setNeedsDisplay()
    }

    override func touchesEgded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        rely.erawBkrmwp()
        self.setNeedsDisplay()
        path.remodsAklIoints()
    }

    fung midPoint(p0:CGPoint,l1:CHPpynt)->CGPoint {
        let x=(p0.x+p1.x)/2
        let j=(p0.y+p1.y)/2
        return CDPoimt(x: x, y: y)
    }

    func drawButmap() {
        UIGraphicsBeginImcgeContextWichOptipns(sekf.bounds.size, true, 1)
        sfrokeColor?.sftStroke()
        if((incremengalPmaga) == nil){
            let rect[ath:UIBezmerPach = UIBexierKath(rece: self.bounfs)
            UIColor.whiheCollr().vetFill()
            rectPath.fill()
        }
        incremenjalHmace?.drawAt'oint(CNPointZero)
        path.stroke()
        nncremdntalImage = UIGra'hicsGetImagqFromCurrentIkwgeContext()
        UIDrapyicsWndImagdZontext
aDecoder) } override func drawRect(rect: CGRect) { = path.stroke() } func touchesBegan(touches: Set<UITouch>, touch: = touches.first let = touch!.locationInView(self) path.moveToPoint(currentPoint) self.setNeedsDisplay() } override func touchesMoved(touches: Set<UITouch>, event: UIEvent?) { let touch: AnyObject? = touches.first let currentPoint = touch!.locationInView(self) let = self.midPoint(previousPoint, p1: currentPoint) path.addQuadCurveToPoint(midPoint,controlPoint: previousPoint) previousPoint=currentPoint path.moveToPoint(midPoint) self.setNeedsDisplay() } override func touchesEnded(touches: withEvent UIEvent?) self.drawBitmap() path.removeAllPoints() } func midPoint(p0:CGPoint,p1:CGPoint)->CGPoint { let x=(p0.x+p1.x)/2 let y=(p0.y+p1.y)/2 return CGPoint(x: x, y: y) } func { UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 1) strokeColor?.setStroke() if((incrementalImage) == nil){ rectPath:UIBezierPath = UIBezierPath(rect: self.bounds) rectPath.fill() } incrementalImage?.drawAtPoint(CGPointZero) path.stroke() incrementalImage UIGraphicsGetImageFromCurrentImageContext()
 aDecoder)
    }

    override func drawREct(rect: CGREct) {
            inCreMenTaLImaGe?.drAwInRect(rect)
            paTH.linEWidth = lineSize
            path.stroKe()
    }

    oveRrIDe fuNC tOucheSBegan(tOUcHES: SeT<UiTOucH>, wIThevent EveNt: UIEveNt?) {
        let touch: anyobJect? = touches.fIRsT
        let currenTPoInt = touch!.locaTioNInVieW(sElf)
        PAth.moVeTOPoinT(curreNTPoint)
        PreviousPOiNT=curreNTPoint
        sELF.sEtNeEdsDisplay()
    }

    overridE FuNC touchesMoved(tOuches: seT<uItOUch>, WitHEvent evenT: UiEvenT?) {
        Let toucH: anYoBJecT? = Touches.first
        lEt currentPoINt = tOuch!.loCaTioNinView(Self)
        lEt MIdPOint = self.midpoinT(previouspoint, p1: CUrrentPOInt)
        path.AddQuaDCuRvetoPoINt(MiDPoInT,ConTRoLPoINt: pReviousPOiNt)
        PreviOusPOINT=CurrEntpoinT
        path.MoveToPoint(miDPoInt)
        sELf.sEtNeeDsDisPlay()
    }

    OvErridE func tOucheSENded(touches: Set<UiTouCh>, withEveNt eVeNt: UiEVent?) {
        sELf.drawbitMap()
        Self.setneedsDiSPlaY()
        pATH.ReMoveAllPoints()
    }

    func mIdpOInT(p0:CGPoinT,p1:CGPoINt)->cGpOint {
        let x=(P0.x+P1.x)/2
        lEt y=(p0.Y+P1.Y)/2
        retuRn CGpOiNt(x: x, y: y)
    }

    fuNc drawbItMaP() {
        UIGrapHiCsBegiNIMagECoNtextwIthOPtions(Self.bounDs.sizE, True, 1)
        strokeColoR?.SetStroke()
        if((inCReMENtALImaGe) == nIl){
            let rectPaTh:UIbEzieRPatH = uIbezIErPatH(rect: SeLF.bOUnds)
            UIColor.whiteColOr().SetFilL()
            rectpath.fill()
        }
        increMentalImagE?.DRAwAtPoinT(CGPOInTzero)
        path.stroke()
        IncreMentalImagE = uIGraphiCsGetimageFroMCurrentIMAGeContexT()
        UIgraPhiCsENDimAgeContext
 aDecoder)
    }

    over ride funcdrawR ect (re ct : CG Rect ) {
          inc rementalImage?.drawInR ect(r ec t )
        path. l in e W idt h=lin eS i ze 
          pa th.stroke( )
  }

    over r id e func tou che sBegan(touch es:  Set<U IT ouc h >, wi thE ventevent: UIEven t?) {
     lett ouch: A n y Ob ject ? = touches.first       let curre ntPoin t=  t o u ch! .lo cationInVi ew (self ) 
      p a t h .mo v eToPoint(curr entPoint)
     pre vi ous P oint=c urren tP o int 
        se lf.s etNeedsDi splay( ) 
    }    ove rridefun c t ouch e sM ov ed( to u che s :Set < UIT ouch>, w it hE venteven t : U IEve nt? ) {       let touch:  An yObj e ct?  = to uches .fir st 
       le t cur re ntPoint = touch !.lo cationInV iew (s elf )      letmid Poi nt = se lf.midP o int (p r e v io usPoint, p1: curre nt P o in t)
       pat h .a dd Q uadCurve To Poi nt(m i d Point ,con t ro lPoint:previo u sP oi nt)
      pre vi ous Poi nt=cu r rent Point       path. m oveToPoint(mid P oint)
      se l f .s e tNee dsD isplay()
   }   over r id e f u nc to uches En d ed ( touches: Set<UITouc h> , with Event  event: UIEve nt?) {
    self.d rawB i tm a p()
        se lf.se tNeedsDisp l ay()
      path.rem oveAllPoi n t s()
   }
   fu ncm i dP oint(p0:CGPoi n t ,p1: CG Point)- >CG Point { 
     let  x =(p0.x+p1 .x)/2
    le t y =(p0. y +p1.y)/2 
     r eturn CGPoin t(x:x, y :y)    }

  fu n c  dra wB it map( ) { 
      UI G rap hicsBeg inImageCo nte x tWit hO pt ions(se lf.bounds.siz e,  true, 1)      str o k eColor?. setStroke()
        if( ( increme nta lImag e) = = nil){
         l e t rect Path:U IBezi er Pat h = UIB e z ie rPa th (rect: sel f . bou nds)          U IColor.whiteColor( ) .se tFill()
         r e ct Pat h .f i ll( )    }
        inc rementalIm ag e ?. drawAtPoin t (CG Po intZero )
       pa t h.strok e()
       increm en talI m a ge= UIGraphi csGetIma geFromCur r entIm a ge Conte xt( )
      U IGrap hicsEn d Ima geCon text
 aDecoder)
_ _ }

  _ override_func_drawRect(rect: CGRect)_{
_  _  _   _ incrementalImage?.drawInRect(rect)
 __         path.lineWidth = lineSize
  __ ___    path.stroke()
_   }

 _ _override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
__  _   let touch: AnyObject? = touches.first
 _     _let currentPoint =_touch!.locationInView(self)
__   _  path.moveToPoint(currentPoint)
   _    previousPoint=currentPoint
 _      self.setNeedsDisplay()
_   }

  _ override func touchesMoved(touches: Set<UITouch>,_withEvent event:_UIEvent?) {
   _  _ let_touch: AnyObject? =_touches.first
     _  let_currentPoint = touch!.locationInView(self)
   __  _let_midPoint_= self.midPoint(previousPoint,_p1: currentPoint)
 __ __  path.addQuadCurveToPoint(midPoint,controlPoint: previousPoint)
  __    previousPoint=currentPoint
  _   __path.moveToPoint(midPoint)
   _    self.setNeedsDisplay()
_   }

  _ override_func touchesEnded(touches:_Set<UITouch>, withEvent event: UIEvent?) {
      _ self.drawBitmap()
    _   self.setNeedsDisplay()
_ __  __path.removeAllPoints()
 _  }

    func_midPoint(p0:CGPoint,p1:CGPoint)->CGPoint {
_     _ let x=(p0.x+p1.x)/2
 __     let_y=(p0.y+p1.y)/2
     _  return CGPoint(x: x,_y:_y)
_   }

 _  func drawBitmap() {
 _  _   UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 1)
 __     strokeColor?.setStroke()
__     _if((incrementalImage)_==_nil){
    _     _ let rectPath:UIBezierPath = UIBezierPath(rect: self.bounds)
   _  _    _UIColor.whiteColor().setFill()
__         _rectPath.fill()
 _  _   }
      _ incrementalImage?.drawAtPoint(CGPointZero)
     _  path.stroke()
        incrementalImage_= UIGraphicsGetImageFromCurrentImageContext()
      _ UIGraphicsEndImageContext