@@ -65,33 +65,65 @@ def rect(self, x, y, width, height):
6565
6666 # Paths methods
6767 def begin_path (self ):
68+ """Call this method when you want to create a new path."""
6869 self ._send_canvas_command ('beginPath' )
6970
7071 def close_path (self ):
72+ """Add a straight line from the current point to the start of the current path.
73+
74+ If the shape has already been closed or has only one point, this function does nothing.
75+ This method doesn't draw anything to the canvas directly. You can render the path using the stroke() or fill() methods.
76+ """
7177 self ._send_canvas_command ('closePath' )
7278
7379 def stroke (self ):
80+ """Stroke (outlines) the current path with the current stroke style."""
7481 self ._send_canvas_command ('stroke' )
7582
7683 def fill (self ):
84+ """Fill the current or given path with the current fillStyle."""
7785 self ._send_canvas_command ('fill' )
7886
7987 def move_to (self , x , y ):
88+ """Move the "pen" to the given (x, y) coordinates."""
8089 self ._send_canvas_command ('moveTo' , x , y )
8190
8291 def line_to (self , x , y ):
92+ """Add a straight line to the current path by connecting the path's last point to the specified (x, y) coordinates.
93+
94+ Like other methods that modify the current path, this method does not directly render anything. To
95+ draw the path onto the canvas, you can use the fill() or stroke() methods.
96+ """
8397 self ._send_canvas_command ('lineTo' , x , y )
8498
85- def arc (self , x , y , radius , start_angle , end_angle , anticlockwise ):
99+ def arc (self , x , y , radius , start_angle , end_angle , anticlockwise = False ):
100+ """Create a circular arc centered at (x, y) with a radius of radius.
101+
102+ The path starts at startAngle and ends at endAngle, and travels in the direction given by
103+ anticlockwise (defaulting to clockwise).
104+ """
86105 self ._send_canvas_command ('arc' , x , y , radius , start_angle , end_angle , anticlockwise )
87106
88107 def arc_to (self , x1 , y1 , x2 , y2 , radius ):
108+ """Add a circular arc to the current path, using the given control points and radius."""
89109 self ._send_canvas_command ('arcTo' , x1 , y1 , x2 , y2 , radius )
90110
91111 def quadratic_curve_to (self , cp1x , cp1y , x , y ):
112+ """Add a quadratic Bezier curve to the current path.
113+
114+ It requires two points: the first one is a control point and the second one is the end point.
115+ The starting point is the latest point in the current path, which can be changed using move_to()
116+ before creating the quadratic Bezier curve.
117+ """
92118 self ._send_canvas_command ('quadraticCurveTo' , cp1x , cp1y , x , y )
93119
94120 def bezier_curve_to (self , cp1x , cp1y , cp2x , cp2y , x , y ):
121+ """Add a cubic Bezier curve to the current path.
122+
123+ It requires three points: the first two are control points and the third one is the end point.
124+ The starting point is the latest point in the current path, which can be changed using move_to()
125+ before creating the Bezier curve.
126+ """
95127 self ._send_canvas_command ('bezierCurveTo' , cp1x , cp1y , cp2x , cp2y , x , y )
96128
97129 # Text methods
0 commit comments