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)
          orientation = self.get_property('orientation', source, overrides)
          pivot = self.get_property('pivot', source, overrides)
          curve = self.get_property('curve', source, overrides)
          
          # get curvature
          curvature = 2*curve if curve else 1
          
          # get coords
          if orientation == ORI_HORIZONTAL:
              cx1 = x1 + min(1, curvature*pivot)*(x2-x1)
              cy1 = y1
              cx2 = x2 - min(1, curvature*(1-pivot))*(x2-x1)
              cy2 = y2
          
          else:
              cx1 = x1
              cy1 = y1 + min(1, curvature*pivot)*(y2-y1)
              cx2 = x2
              cy2 = y2 - min(1, curvature*(1-pivot))*(y2-y1)
          
          # get angles
          if x1 == cx1 and y1 == cy1:
              start_angle = math.atan2(y1-cy2, x1-cx2)
              end_angle = math.atan2(y2-cy2, x2-cx2)
          
          elif x2 == cx2 and y2 == cy2:
              start_angle = math.atan2(y1-cy1, x1-cx1)
              end_angle = math.atan2(y2-cy1, x2-cx1)
          
          else:
              start_angle = math.atan2(y1-cy1, x1-cx1)
              end_angle = math.atan2(y2-cy2, x2-cx2)
          
          # 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 line
          if curve == 0:
              canvas.draw_lines(((x1, y1), (cx1, cy1), (cx2, cy2), (x2, y2)))
          
          # draw curve
          else:
              path = Path()
              path.move_to(x1, y1)
              path.curve_to(cx1, cy1, cx2, cy2, x2, y2)
              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 ) orientation = self . get_property ( 'orientation' , source , overrides ) pivot = self . get_property ( 'pivot' , source , overrides ) curve = self . get_property ( 'curve' , source , overrides ) curvature = 2 * curve if curve else 1 if orientation == ORI_HORIZONTAL : cx1 = x1 + min ( 1 , curvature * pivot ) * ( x2 - x1 ) cy1 = y1 cx2 = x2 - min ( 1 , curvature * ( 1 - pivot ) ) * ( x2 - x1 ) cy2 = y2 else : cx1 = x1 cy1 = y1 + min ( 1 , curvature * pivot ) * ( y2 - y1 ) cx2 = x2 cy2 = y2 - min ( 1 , curvature * ( 1 - pivot ) ) * ( y2 - y1 ) if x1 == cx1 and y1 == cy1 : start_angle = math . atan2 ( y1 - cy2 , x1 - cx2 ) end_angle = math . atan2 ( y2 - cy2 , x2 - cx2 ) elif x2 == cx2 and y2 == cy2 : start_angle = math . atan2 ( y1 - cy1 , x1 - cx1 ) end_angle = math . atan2 ( y2 - cy1 , x2 - cx1 ) else : start_angle = math . atan2 ( y1 - cy1 , x1 - cx1 ) end_angle = math . atan2 ( y2 - cy2 , x2 - cx2 ) canvas . set_pen_by ( self , source = source , overrides = overrides ) canvas . fill_color = None canvas . group ( tag , "arrow" ) if curve == 0 : canvas . draw_lines ( ( ( x1 , y1 ) , ( cx1 , cy1 ) , ( cx2 , cy2 ) , ( x2 , y2 ) ) ) else : path = Path ( ) path . move_to ( x1 , y1 ) path . curve_to ( cx1 , cy1 , cx2 , cy2 , x2 , y2 ) 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$# get curvature$SEP$# get coords$SEP$# get angles$SEP$# set pen and brush$SEP$# start drawing group$SEP$# draw line$SEP$# draw curve$SEP$# draw heads$SEP$# end drawing group