ios - Arrow drawing in swift - missing one triangle -


i drawing arrow on view, 1 part of triangle missing. don't know missing in code. more detail , added 1 image here. enter image description here

import uikit  class annotationarrow: uiview {        //mark: global variables      var startingpoint : cgpoint = cgpoint()     var endingpoint : cgpoint = cgpoint()     var arrowlength : cgfloat = cgfloat()     var arrowpath : uibezierpath = uibezierpath()     var selectedinbox_activated_anchor_points = false      //mark: resizing      var kuserresizableviewdefaultminwidth = 40.0     var kuserresizableviewdefaultminheight  = 40.0     var kuserresizableviewinteractivebordersize = 10.0      //mark: initframe      override init(frame: cgrect)     {         super.init(frame: frame)     }      //mark: initcoder      required init(coder adecoder: nscoder)     {         super.init(coder: adecoder)     }      func passingvalues(startingpointvalue : cgpoint, endingpointvalue : cgpoint)     {         self.startingpoint = startingpointvalue         self.endingpoint = endingpointvalue          var xdistance : cgfloat = self.endingpoint.x - self.startingpoint.x         var ydistance : cgfloat = self.endingpoint.y - self.startingpoint.y          self.arrowlength = sqrt((xdistance * xdistance) + (ydistance * ydistance))     }        //mark: drawrect      override func drawrect(rect: cgrect)     {         var tailwidth : cgfloat = max(4.0, self.arrowlength * 0.07)         var headlength : cgfloat = max(self.arrowlength / 3.0, 10.0)         var headwidth : cgfloat = headlength * 0.9         var strokewidth : cgfloat = max(1.0, tailwidth * 0.25)          self.layer.shadowradius = max(4.0, tailwidth)          self.arrowpath = self.bezierpathwitharrowfrompoint(self.startingpoint, endpoint: self.endingpoint, tailwidth: tailwidth, headwidth: headwidth, headlength: headlength)          self.arrowpath.fill()         self.arrowpath.stroke()         self.arrowpath.linewidth = strokewidth         self.layer.shadowpath  = self.arrowpath.cgpath     }  //mark: creating path      func bezierpathwitharrowfrompoint(startingpoint : cgpoint, endpoint : cgpoint, tailwidth : cgfloat, headwidth : cgfloat, headlength : cgfloat) -> uibezierpath     {          var length = hypotf( float(endpoint.x) - float(startingpoint.x) , float(endpoint.y) - float(startingpoint.y))          var taillength : cgfloat = cgfloat(length) - headlength          var points = [cgpointmake(0, tailwidth / 2), cgpointmake(taillength, tailwidth / 2), cgpointmake(taillength, headwidth / 2), cgpointmake(cgfloat(length), 0), cgpointmake(taillength, (-headwidth) / 2), cgpointmake(taillength, (-tailwidth) / 2 ), cgpointmake(0, (-tailwidth) / 2)]           var cosine : cgfloat = (endpoint.x - startingpoint.x) / cgfloat(length)         var sine : cgfloat = (endpoint.y - startingpoint.y) / cgfloat(length)         var transform : cgaffinetransform = cgaffinetransform(a: cosine, b: sine, c: -sine, d: cosine, tx: startingpoint.x, ty: startingpoint.y)          var cgpath : cgmutablepathref = cgpathcreatemutable()         cgpathaddlines(cgpath, &transform, points, uint(sizeofvalue(points)) / 1)         cgpathclosesubpath(cgpath)          var bezierpath : uibezierpath = uibezierpath(cgpath: cgpath)         bezierpath.linecapstyle = kcglinecapround         bezierpath.linejoinstyle = kcglinejoinround          return bezierpath     } 

if out there knows missing, please me out here.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -