original_docstring: Uses given canvas to draw arrow.
docstring: Uses given canvas to draw arrow.
docstring_tokens: Uses given canvas to draw arrow .
code: def draw(self, canvas, source=UNDEF, **overrides):
          """Uses given canvas to draw arrow."""
          
          # check if visible
          if not self.is_visible(source, overrides):
              return
          
          # get properties
          tag = self.get_property('tag', source, overrides)
          x1 = self.get_property('x1', source, overrides)
          y1 = self.get_property('y1', source, overrides)
          x2 = self.get_property('x2', source, overrides)
          y2 = self.get_property('y2', source, overrides)
          path = self.get_property('path', source, overrides)
          
          # check data
          if not path:
              return
          
          # get path endpoints
          p1x, p1y = path.start()
          p2x, p2y = path.end()
          path_length = math.sqrt((p2x-p1x)**2 + (p2y-p1y)**2)
          
          # init matrix
          matrix = Matrix()
          
          # strait path
          angle = math.atan2(p2y-p1y, p2x-p1x)
          matrix.translate(-p1x, -p1y)
          matrix.rotate(-angle)
          
          # scale to final arrow
          length = math.sqrt((x2-x1)**2 + (y2-y1)**2)
          scale = length/path_length
          matrix.scale(scale, scale)
          
          # rotate to final arrow
          angle = math.atan2(y2-y1, x2-x1)
          matrix.rotate(angle)
          
          # move to final position
          matrix.translate(x1, y1)
          
          # apply to path
          path = path.transformed(matrix)
          
          # get angles
          start_angle = path.start_angle() + math.pi
          end_angle = path.end_angle()
          
          # set pen and brush
          canvas.set_pen_by(self, source=source, overrides=overrides)
          canvas.fill_color = None
          
          # start drawing group
          canvas.group(tag, "arrow")
          
          # draw path
          canvas.draw_path(path)
          
          # draw heads
          self.draw_heads(canvas,
              source = source,
              start_head_x = x1,
              start_head_y = y1,
              start_head_angle = start_angle,
              start_head_angle_units = ANGLE_RAD,
              end_head_x = x2,
              end_head_y = y2,
              end_head_angle = end_angle,
              end_head_angle_units = ANGLE_RAD,
              **overrides)
          
          # end drawing group
          canvas.ungroup()
code_tokens: def draw ( self , canvas , source = UNDEF , ** overrides ) : if not self . is_visible ( source , overrides ) : return tag = self . get_property ( 'tag' , source , overrides ) x1 = self . get_property ( 'x1' , source , overrides ) y1 = self . get_property ( 'y1' , source , overrides ) x2 = self . get_property ( 'x2' , source , overrides ) y2 = self . get_property ( 'y2' , source , overrides ) path = self . get_property ( 'path' , source , overrides ) if not path : return p1x , p1y = path . start ( ) p2x , p2y = path . end ( ) path_length = math . sqrt ( ( p2x - p1x ) ** 2 + ( p2y - p1y ) ** 2 ) matrix = Matrix ( ) angle = math . atan2 ( p2y - p1y , p2x - p1x ) matrix . translate ( - p1x , - p1y ) matrix . rotate ( - angle ) length = math . sqrt ( ( x2 - x1 ) ** 2 + ( y2 - y1 ) ** 2 ) scale = length / path_length matrix . scale ( scale , scale ) angle = math . atan2 ( y2 - y1 , x2 - x1 ) matrix . rotate ( angle ) matrix . translate ( x1 , y1 ) path = path . transformed ( matrix ) start_angle = path . start_angle ( ) + math . pi end_angle = path . end_angle ( ) canvas . set_pen_by ( self , source = source , overrides = overrides ) canvas . fill_color = None canvas . group ( tag , "arrow" ) canvas . draw_path ( path ) self . draw_heads ( canvas , source = source , start_head_x = x1 , start_head_y = y1 , start_head_angle = start_angle , start_head_angle_units = ANGLE_RAD , end_head_x = x2 , end_head_y = y2 , end_head_angle = end_angle , end_head_angle_units = ANGLE_RAD , ** overrides ) canvas . ungroup ( )
short_docstring: Uses given canvas to draw arrow.
short_docstring_tokens: Uses given canvas to draw arrow .
comment: """Uses given canvas to draw arrow."""$SEP$# check if visible$SEP$# get properties$SEP$# check data$SEP$# get path endpoints$SEP$# init matrix$SEP$# strait path$SEP$# scale to final arrow$SEP$# rotate to final arrow$SEP$# move to final position$SEP$# apply to path$SEP$# get angles$SEP$# set pen and brush$SEP$# start drawing group$SEP$# draw path$SEP$# draw heads$SEP$# end drawing group