From 4fb38542e327311fa91de6a8789d99328ba78ef7 Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:05:52 -0700 Subject: [PATCH 01/11] Cleanup curves.rst --- docs/tutorials/curves.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tutorials/curves.rst b/docs/tutorials/curves.rst index 1a260aa7..d5e4d45f 100644 --- a/docs/tutorials/curves.rst +++ b/docs/tutorials/curves.rst @@ -60,7 +60,7 @@ Arcs are fine, but they’re plain. The next function, ``curve()``, lets you dra curve((cpx1, cpy1), (x1, y1), (x2, y2), (cpx2, cpy2)) -.. code:: python +.. code:: none cpx1, cpy1 Coordinates of the first control point x1, y1 Coordinates of the curve’s starting point @@ -153,7 +153,7 @@ Bézier Curves Though better than arcs, spline curves don’t seem to have those graceful, swooping curves that say “art.” For those, you need to draw Bézier curves with the ``bezier()`` function. As with spline curves, the ``bezier()`` function has eight parameters, but the order is different: -.. code:: python +.. code:: none bezier((x1, y1), (cpx1, cpy1), (cpx2, cpy2), (x2, y2)) x1, y1 Coordinates of the curve’s starting point @@ -289,5 +289,5 @@ Summary * Use ``arc()`` when you need a segment of a circle or an ellipse. You can’t make continuous arcs or use them as part of a shape. * Use ``curve()`` when you need a small curve between two points. Use curveVertex() to make a continuous series of curves as part of a shape. -* Use ``bezier()`` when you need long, smooth curves. Use ``bezier_vertex()` to make a continuous series of Bézier curves as part of a shape. +* Use ``bezier()`` when you need long, smooth curves. Use ``bezier_vertex()`` to make a continuous series of Bézier curves as part of a shape. From 4dfea008c6b6513295f830a583998799133aa7df Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:08:46 -0700 Subject: [PATCH 02/11] Remove extra python code block --- docs/examples/image/create image.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/examples/image/create image.rst b/docs/examples/image/create image.rst index 0d830980..c1b3afdf 100644 --- a/docs/examples/image/create image.rst +++ b/docs/examples/image/create image.rst @@ -31,7 +31,3 @@ Create Image The ``create_image()`` function provides a fresh buffer of pixels to play with. This example creates an image gradient. - - -.. code:: python - From 36f2480a104aa18266207c48ce2b8b9cb318e304 Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:14:06 -0700 Subject: [PATCH 03/11] Make title underlines longer --- docs/reference/transform.rst | 2 +- docs/reference/typography.rst | 10 +++++----- docs/tutorials/2D transformations.rst | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/reference/transform.rst b/docs/reference/transform.rst index 549bb092..43f14d45 100644 --- a/docs/reference/transform.rst +++ b/docs/reference/transform.rst @@ -69,7 +69,7 @@ camera() .. autofunction:: camera() perspective() ---------- +------------- .. autofunction:: perspective() diff --git a/docs/reference/typography.rst b/docs/reference/typography.rst index 1955c829..4e4c3c68 100644 --- a/docs/reference/typography.rst +++ b/docs/reference/typography.rst @@ -35,13 +35,13 @@ Text Attributes text_align() ------------ +------------ .. autofunction:: text_align text_leading() ------------ +-------------- .. autofunction:: text_leading @@ -56,18 +56,18 @@ Metrics ======= text_ascent() ------------ +------------- .. autofunction:: text_ascent text_descent() ------------ +--------------- .. autofunction:: text_descent text_width() ------------ +------------ .. autofunction:: text_width \ No newline at end of file diff --git a/docs/tutorials/2D transformations.rst b/docs/tutorials/2D transformations.rst index a189ccff..22413b52 100644 --- a/docs/tutorials/2D transformations.rst +++ b/docs/tutorials/2D transformations.rst @@ -296,7 +296,7 @@ The Transformation Matrix Every time you do a rotation, translation, or scaling, the information required to do the transformation is accumulated into a table of numbers. This table, or matrix has only a few rows and columns, yet, through the miracle of mathematics, it contains all the information needed to do any series of transformations. And that’s why ``push_matrix()`` has that word in their name. Push (and Pop) -============ +============== What about the push part of the name? It comes from a computer concept known as a stack, which works like a spring-loaded tray dispenser in a cafeteria. When someone returns a tray to the stack, its weight pushes the platform down. When someone needs a tray, he takes it from the top of the stack, and the remaining trays pop up a little bit. From 4bd3643898d93b719223a793501afc20e6d2466f Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:20:29 -0700 Subject: [PATCH 04/11] Close quotes --- docs/tutorials/2D transformations.rst | 2 +- docs/tutorials/coordinate system and shapes.rst | 2 +- docs/tutorials/interactivity.rst | 2 +- docs/tutorials/strings and drawing text.rst | 2 +- p5/core/primitives.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/2D transformations.rst b/docs/tutorials/2D transformations.rst index 22413b52..d838e950 100644 --- a/docs/tutorials/2D transformations.rst +++ b/docs/tutorials/2D transformations.rst @@ -497,7 +497,7 @@ Because this is a new concept, rather than integrate it into the robot program, if __name__ == '__main__': run() -That works great. What happens if we draw the rectangle so it is taller than it is wide? Change the preceding code to read ``rect((0, 0), 10, 50)`. How come it doesn’t seem to follow the mouse any more? The answer is that the rectangle really is still following the mouse, but it’s the short side of the rectangle that does the following. Our eyes are trained to want the long side to be tracked. Because the long side is at a 90 degree angle to the short side, you have to subtract 90° (or π/2 radians) to get the desired effect. Change the preceding code to read rotate(angle - HALF_PI) and try it again. Since Processing deals almost exclusively in radians, the language has defined the constants PI (180°), HALF_PI (90°), QUARTER_PI (45°) and TWO_PI (360°) for your convenience. +That works great. What happens if we draw the rectangle so it is taller than it is wide? Change the preceding code to read ``rect((0, 0), 10, 50)``. How come it doesn’t seem to follow the mouse any more? The answer is that the rectangle really is still following the mouse, but it’s the short side of the rectangle that does the following. Our eyes are trained to want the long side to be tracked. Because the long side is at a 90 degree angle to the short side, you have to subtract 90° (or π/2 radians) to get the desired effect. Change the preceding code to read rotate(angle - HALF_PI) and try it again. Since Processing deals almost exclusively in radians, the language has defined the constants PI (180°), HALF_PI (90°), QUARTER_PI (45°) and TWO_PI (360°) for your convenience. At this point, we can write the final version of the arm-tracking program. We start off with definitions of constants and variables. The number 39 in the definition of MIDPOINT_X comes from the fact that the body of the robot starts at x-coordinate 14 and is 50 pixels wide, so 39 (14 + 25) is the horizontal midpoint of the robot’s body. diff --git a/docs/tutorials/coordinate system and shapes.rst b/docs/tutorials/coordinate system and shapes.rst index d9684a4f..57c8f429 100644 --- a/docs/tutorials/coordinate system and shapes.rst +++ b/docs/tutorials/coordinate system and shapes.rst @@ -56,7 +56,7 @@ A ``point()`` is the easiest of the shapes and a good place to start. To draw a :align: center :width: 50% -A ``line()``isn't terribly difficult either and simply requires two points: (x1,y1) and (x2,y2): +A ``line()`` isn't terribly difficult either and simply requires two points: (x1,y1) and (x2,y2): .. image:: ./coordinate_system_and_shapes-res/drawing-06.svg :align: center diff --git a/docs/tutorials/interactivity.rst b/docs/tutorials/interactivity.rst index 16f6ca2d..5ba5484b 100644 --- a/docs/tutorials/interactivity.rst +++ b/docs/tutorials/interactivity.rst @@ -140,7 +140,7 @@ To invert the value of the mouse, subtract the mouse_x value from the width of t if __name__ == '__main__': run() -The Processing variables ``pmouse_x`` and ``pmouse_y` store the mouse values from the previous frame. If the mouse does not move, the values will be the same, but if the mouse is moving quickly there can be large differences between the values. To see the difference, run the following program and alternate moving the mouse slowly and quickly. Watch the values print to the console. +The Processing variables ``pmouse_x`` and ``pmouse_y`` store the mouse values from the previous frame. If the mouse does not move, the values will be the same, but if the mouse is moving quickly there can be large differences between the values. To see the difference, run the following program and alternate moving the mouse slowly and quickly. Watch the values print to the console. .. code:: python diff --git a/docs/tutorials/strings and drawing text.rst b/docs/tutorials/strings and drawing text.rst index 3ef9e123..220cf749 100644 --- a/docs/tutorials/strings and drawing text.rst +++ b/docs/tutorials/strings and drawing text.rst @@ -60,7 +60,7 @@ Another useful method is ``len()``. This is easy to confuse with the length prop message = "This String is 34 characters long." print(len(message)) -We can also change a String to all uppercase using the ``upper()` method: +We can also change a String to all uppercase using the ``upper()`` method: .. code:: python diff --git a/p5/core/primitives.py b/p5/core/primitives.py index 8591c438..d1447c67 100644 --- a/p5/core/primitives.py +++ b/p5/core/primitives.py @@ -378,7 +378,7 @@ def square(coordinate, side_length, mode=None): 'CENTER' and 'RADIUS' the coordinate represents the center of the square. - :type coordinate: tuple | list |p5.Vector + :type coordinate: tuple | list | p5.Vector :param side_length: The side_length of the square (for modes 'CORNER' and 'CENTER') or hald of the side length (for the From 907391cb94db836fa41ce43a785307830621aff0 Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:29:24 -0700 Subject: [PATCH 05/11] Add :noindex: to p5 module references --- docs/reference/attributes.rst | 2 +- docs/reference/color.rst | 2 +- docs/reference/environment.rst | 1 + docs/reference/image.rst | 1 + docs/reference/math.rst | 1 + docs/reference/output.rst | 1 + docs/reference/shape.rst | 1 + docs/reference/structure.rst | 1 + docs/reference/svg.rst | 2 +- docs/reference/typography.rst | 2 +- 10 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/reference/attributes.rst b/docs/reference/attributes.rst index 83c4cdc6..8638dec6 100644 --- a/docs/reference/attributes.rst +++ b/docs/reference/attributes.rst @@ -3,7 +3,7 @@ Attributes ========== .. automodule:: p5 - + :noindex: fill() ------- diff --git a/docs/reference/color.rst b/docs/reference/color.rst index ec843b88..60d505b2 100644 --- a/docs/reference/color.rst +++ b/docs/reference/color.rst @@ -2,7 +2,7 @@ Color ===== .. automodule:: p5 - + :noindex: Color ----- diff --git a/docs/reference/environment.rst b/docs/reference/environment.rst index 684d02ac..2668031b 100644 --- a/docs/reference/environment.rst +++ b/docs/reference/environment.rst @@ -3,6 +3,7 @@ Environment =========== .. automodule:: p5 + :noindex: size() ====== diff --git a/docs/reference/image.rst b/docs/reference/image.rst index f832e5c7..ac4c58c1 100644 --- a/docs/reference/image.rst +++ b/docs/reference/image.rst @@ -3,6 +3,7 @@ Image ===== .. module:: p5 + :noindex: PImage ====== diff --git a/docs/reference/math.rst b/docs/reference/math.rst index a2610948..3c5818c2 100644 --- a/docs/reference/math.rst +++ b/docs/reference/math.rst @@ -3,6 +3,7 @@ Math ==== .. automodule:: p5 + :noindex: .. note:: diff --git a/docs/reference/output.rst b/docs/reference/output.rst index 11bf8e3c..23f08793 100644 --- a/docs/reference/output.rst +++ b/docs/reference/output.rst @@ -3,6 +3,7 @@ Output ====== .. module:: p5 + :noindex: Image ===== diff --git a/docs/reference/shape.rst b/docs/reference/shape.rst index e4a6a1a3..3f831224 100644 --- a/docs/reference/shape.rst +++ b/docs/reference/shape.rst @@ -3,6 +3,7 @@ Shape ===== .. automodule:: p5 + :noindex: PShape ====== diff --git a/docs/reference/structure.rst b/docs/reference/structure.rst index 3a7d49d6..10d83094 100644 --- a/docs/reference/structure.rst +++ b/docs/reference/structure.rst @@ -3,6 +3,7 @@ Structure ========= .. module:: p5 + :noindex: setup() ======= diff --git a/docs/reference/svg.rst b/docs/reference/svg.rst index c7bab1e0..afd0a2dc 100644 --- a/docs/reference/svg.rst +++ b/docs/reference/svg.rst @@ -2,7 +2,7 @@ SVG === .. module:: p5 - + :noindex: load_shape() ------------ diff --git a/docs/reference/typography.rst b/docs/reference/typography.rst index 4e4c3c68..255ca75d 100644 --- a/docs/reference/typography.rst +++ b/docs/reference/typography.rst @@ -3,7 +3,7 @@ Typography ========== .. automodule:: p5 - + :noindex: Loading and displaying ====================== From 0472b17290af83fe74b60200e68cb2bff891b19a Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:38:15 -0700 Subject: [PATCH 06/11] Fix indentation for camera docstring --- p5/core/transforms.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/p5/core/transforms.py b/p5/core/transforms.py index fd9dd2a0..e7365a05 100644 --- a/p5/core/transforms.py +++ b/p5/core/transforms.py @@ -205,12 +205,11 @@ def camera(position, target_position, up_vector): orientation of the camera). When called with no arguments, this function - creates a default camera equivalent to - camera( - (0, 0, (height/2.0) / tan(PI*30.0 / 180.0)), - (0, 0, 0), - (0, 1, 0) - ) + creates a default camera equivalent to:: + + camera((0, 0, (height/2.0) / tan(PI*30.0 / 180.0)), + (0, 0, 0), + (0, 1, 0)) :param position: camera position coordinates :type position: tuple From 2882508e46158daa51e891a4480bfadc1ce16284 Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:46:03 -0700 Subject: [PATCH 07/11] Cleanup vector.rst --- docs/tutorials/vector.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/tutorials/vector.rst b/docs/tutorials/vector.rst index 0a9f00d1..135639b6 100644 --- a/docs/tutorials/vector.rst +++ b/docs/tutorials/vector.rst @@ -272,7 +272,6 @@ Let's say I have the following two vectors: .. figure:: ./vector-res/v.svg :align: right - :scale: 50% .. math:: @@ -1554,12 +1553,12 @@ then have: direction = mouse - self.location - We now have a Vector that points from the mover's location all the - way to the mouse. If the object were to actually accelerate using - that vector, it would instantaneously appear at the mouse location. - This does not make for good animation, of course, and what we want to - do is now decide how fast that object should accelerate towards the - mouse. +We now have a Vector that points from the mover's location all the +way to the mouse. If the object were to actually accelerate using +that vector, it would instantaneously appear at the mouse location. +This does not make for good animation, of course, and what we want to +do is now decide how fast that object should accelerate towards the +mouse. In order to set the magnitude (whatever it may be) of our acceleration @@ -1571,7 +1570,7 @@ anything equals anything. .. code:: python - anything = ??? + anything = some_number direction.normalize() direction = direction * anything From c7189554120fac4e3aeb7ca7fbb07874d79ea5fa Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 16:53:43 -0700 Subject: [PATCH 08/11] Fix indentation in svg.py --- p5/core/svg.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/p5/core/svg.py b/p5/core/svg.py index 774a6cb3..622ba098 100644 --- a/p5/core/svg.py +++ b/p5/core/svg.py @@ -150,7 +150,7 @@ def load_shape(filename): PShape object. :param filename: link to .svg file - :type filename: str + :type filename: str """ tree = etree.parse(filename) @@ -209,13 +209,13 @@ def shape(shape, x=0, y=0): Draws shapes to the display window :param shape: shape object - :type shape: PShape + :type shape: PShape :param x: x-coordinate of the shape - :type x: float + :type x: float - :param y: y-coordinate of the shape - :type y: float + :param y: y-coordinate of the shape + :type y: float """ with transforms.push_matrix(): transforms.translate(x, y) From 9d414ac11e3224fa22cac4d52ce5ff58cb44405d Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 17:04:31 -0700 Subject: [PATCH 09/11] Make attributes file as canonical index location --- docs/reference/color.rst | 7 ++++--- docs/reference/image.rst | 3 ++- docs/reference/transform.rst | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/reference/color.rst b/docs/reference/color.rst index 60d505b2..5f1d5e4c 100644 --- a/docs/reference/color.rst +++ b/docs/reference/color.rst @@ -26,21 +26,22 @@ fill() ------ .. autofunction:: fill - + :noindex: no_fill() --------- .. autofunction:: no_fill - + :noindex: stroke() -------- .. autofunction:: stroke - + :noindex: no_stroke() ----------- .. autofunction:: no_stroke + :noindex: diff --git a/docs/reference/image.rst b/docs/reference/image.rst index ac4c58c1..4e612dab 100644 --- a/docs/reference/image.rst +++ b/docs/reference/image.rst @@ -35,12 +35,13 @@ tint() ------ .. autofunction:: tint + :noindex: no_tint() --------- .. autofunction:: no_tint - + :noindex: Pixels ====== diff --git a/docs/reference/transform.rst b/docs/reference/transform.rst index 43f14d45..79db3e5c 100644 --- a/docs/reference/transform.rst +++ b/docs/reference/transform.rst @@ -2,6 +2,7 @@ Transform ========= .. automodule:: p5 + :noindex: push_matrix() ------------- From 1f00fc20e43d08f04ecb3adfed27bf0660f1d1dc Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 17:08:10 -0700 Subject: [PATCH 10/11] Prevent sphinx from parsing c_ --- docs/tutorials/objects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/objects.rst b/docs/tutorials/objects.rst index f579d8b7..fe43a3e1 100644 --- a/docs/tutorials/objects.rst +++ b/docs/tutorials/objects.rst @@ -281,7 +281,7 @@ Nevertheless, this is quite an important skill to learn, and, ultimately, is one Arguments are local variables used inside the body of a function that get filled with values when the function is called. In the examples, they have one purpose only: to initialize the variables inside of an object. These are the variables that count—the car's actual color, the car's actual x location, and so on. The constructor's arguments are just temporary, and exist solely to pass a value from where the object is made into the object itself. -This allows us to make a variety of objects using the same constructor. You might also just write the word temp in your argument names to remind you of what is going on (c vs. tempC). You will also see programmers use an underscore (c vs. c_) in many examples. You can name these whatever you want, of course. However, it is advisable to choose a name that makes sense to you, and also to stay consistent. +This allows us to make a variety of objects using the same constructor. You might also just write the word temp in your argument names to remind you of what is going on (``c`` vs. ``tempC``). You will also see programmers use an underscore (``c`` vs. ``c_``) in many examples. You can name these whatever you want, of course. However, it is advisable to choose a name that makes sense to you, and also to stay consistent. We can now take a look at the same sketch with multiple object instances, each with unique properties. From 1211ce0310ade66ebf90a5f6796d11bad1b3ff6e Mon Sep 17 00:00:00 2001 From: Ziyao Zhang Date: Sat, 23 May 2020 17:09:16 -0700 Subject: [PATCH 11/11] Use add_js_file --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index c5cbd586..99c4c2d3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -178,4 +178,4 @@ def __getattr__(cls, name): ] def setup(app): - app.add_javascript('p5.min.js') + app.add_js_file('p5.min.js')