* **Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).**
* **Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).**
* **Axis is an index of the dimension that gets aggregated. Leftmost/outermost dimension has index 0. Summing a 100x50 RGB image along the axis 2 will return a greyscale image with shape (50, 100).**
* **Axis is an index of the dimension that gets aggregated. Leftmost dimension has index 0. Summing the RGB image along axis 2 will return a greyscale image with shape (50, 100).**
* **Passing a tuple of axes will chain the operations like this: `'<array>.<method>(axis_1, keepdims=True).<method>(axis_2).squeeze()'`.**
* **Passing a tuple of axes will chain the operations like this: `'<array>.<method>(axis_1, keepdims=True).<method>(axis_2).squeeze()'`.**
### Indexing
### Indexing
@ -2744,7 +2744,7 @@ from PIL import Image
<Image>.putpixel((x, y), <int/tuple>) # Writes a pixel to the image.
<Image>.putpixel((x, y), <int/tuple>) # Writes a pixel to the image.
<ImagingCore> = <Image>.getdata() # Returns a flattened sequence of pixels.
<ImagingCore> = <Image>.getdata() # Returns a flattened sequence of pixels.
<Image>.putdata(<list/ImagingCore>) # Writes a flattened sequence of pixels.
<Image>.putdata(<list/ImagingCore>) # Writes a flattened sequence of pixels.
<Image>.paste(<Image>, (x, y)) # Writes an image to the image.
<Image>.paste(<Image>, (x, y)) # Writes passed image to the image.
```
```
```bash
```bash
@ -2797,7 +2797,7 @@ from PIL import ImageDraw
* **Use `'fill=<color>'` to set the primary color.**
* **Use `'fill=<color>'` to set the primary color.**
* **Use `'width=<int>'` to set the width of lines or contours.**
* **Use `'width=<int>'` to set the width of lines or contours.**
* **Use `'outline=<color>'` to set the color of the contours.**
* **Use `'outline=<color>'` to set the color of the contours.**
* **Colors can be specified as an int, tuple, `'#rrggbb[aa]'` string or a color name.**
* **Color can be specified as an int, tuple, `'#rrggbb[aa]'` string or a color name.**
Animation
Animation
@ -2807,6 +2807,7 @@ Animation
# $ pip3 install imageio
# $ pip3 install imageio
from PIL import Image, ImageDraw
from PIL import Image, ImageDraw
import imageio
import imageio
WIDTH, HEIGHT, R = 126, 126, 10
WIDTH, HEIGHT, R = 126, 126, 10
frames = []
frames = []
for velocity in range(1, 16):
for velocity in range(1, 16):
@ -2852,14 +2853,13 @@ nframes = <Wave_read>.getnframes() # Number of frames.
<li><strong>Default values are evaluated when function is first encountered in the scope.</strong></li>
<li><strong>Default values are evaluated when function is first encountered in the scope.</strong></li>
<li><strong>Any mutations of mutable default values will persist between invocations.</strong></li>
<li><strong>Any mutation of a mutable default value will persist between invocations.</strong></li>
</ul>
</ul>
<div><h2id="splatoperator"><ahref="#splatoperator"name="splatoperator">#</a>Splat Operator</h2><div><h3id="insidefunctioncall-1">Inside Function Call</h3><p><strong>Splat expands a collection into positional arguments, while splatty-splat expands a dictionary into keyword arguments.</strong></p><pre><codeclass="python language-python hljs">args = (<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>)
<div><h2id="splatoperator"><ahref="#splatoperator"name="splatoperator">#</a>Splat Operator</h2><div><h3id="insidefunctioncall-1">Inside Function Call</h3><p><strong>Splat expands a collection into positional arguments, while splatty-splat expands a dictionary into keyword arguments.</strong></p><pre><codeclass="python language-python hljs">args = (<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>)
<div><h2id="bytes"><ahref="#bytes"name="bytes">#</a>Bytes</h2><p><strong>Bytes object is an immutable sequence of single bytes. Mutable version is called bytearray.</strong></p><pre><codeclass="python language-python hljs"><bytes> = <spanclass="hljs-string">b'<str>'</span><spanclass="hljs-comment"># Only accepts ASCII characters and \x00-\xff.</span>
<int> = <bytes>[<index>] <spanclass="hljs-comment"># Returns an int in range from 0 to 255.</span>
<bytes> = <bytes>[<slice>] <spanclass="hljs-comment"># Returns bytes even if it has only one element.</span>
<bytes> = <bytes>.join(<coll_of_bytes>) <spanclass="hljs-comment"># Joins elements using bytes as a separator.</span>
<div><h2id="bytes"><ahref="#bytes"name="bytes">#</a>Bytes</h2><p><strong>Bytes object is an immutable sequence of single bytes. Mutable version is called bytearray.</strong></p><pre><codeclass="python language-python hljs"><bytes> = <spanclass="hljs-string">b'<str>'</span><spanclass="hljs-comment"># Only accepts ASCII characters and \x00-\xff.</span>
<int> = <bytes>[<index>] <spanclass="hljs-comment"># Returns an int in range from 0 to 255.</span>
<bytes> = <bytes>[<slice>] <spanclass="hljs-comment"># Returns bytes even if it has only one element.</span>
<bytes> = <bytes>.join(<coll_of_bytes>) <spanclass="hljs-comment"># Joins elements using bytes as a separator.</span>
</code></pre></div>
</code></pre></div>
<div><h3id="encode-1">Encode</h3><pre><codeclass="python language-python hljs"><bytes> = bytes(<coll_of_ints>) <spanclass="hljs-comment"># Ints must be in range from 0 to 255.</span>
<bytes> = bytes.fromhex(<spanclass="hljs-string">'<hex>'</span>) <spanclass="hljs-comment"># Hex pairs can be separated by whitespaces.</span>
<div><h3id="encode-1">Encode</h3><pre><codeclass="python language-python hljs"><bytes> = bytes(<coll_of_ints>) <spanclass="hljs-comment"># Ints must be in range from 0 to 255.</span>
<bytes> = bytes.fromhex(<spanclass="hljs-string">'<hex>'</span>) <spanclass="hljs-comment"># Hex pairs can be separated by whitespaces.</span>
</code></pre></div>
</code></pre></div>
<div><h3id="decode-1">Decode</h3><pre><codeclass="python language-python hljs"><list> = list(<bytes>) <spanclass="hljs-comment"># Returns ints in range from 0 to 255.</span>
<div><h3id="decode-1">Decode</h3><pre><codeclass="python language-python hljs"><list> = list(<bytes>) <spanclass="hljs-comment"># Returns ints in range from 0 to 255.</span>
<li><strong>Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).</strong></li>
<li><strong>Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).</strong></li>
<li><strong>Axis is an index of the dimension that gets aggregated. Leftmost/outermost dimension has index 0. Summing a 100x50 RGB image along the axis 2 will return a greyscale image with shape (50, 100).</strong></li>
<li><strong>Axis is an index of the dimension that gets aggregated. Leftmost dimension has index 0. Summing the RGB image along axis 2 will return a greyscale image with shape (50, 100).</strong></li>
<li><strong>Passing a tuple of axes will chain the operations like this: <codeclass="python hljs"><spanclass="hljs-string">'<array>.<method>(axis_1, keepdims=True).<method>(axis_2).squeeze()'</span></code>.</strong></li>
<li><strong>Passing a tuple of axes will chain the operations like this: <codeclass="python hljs"><spanclass="hljs-string">'<array>.<method>(axis_1, keepdims=True).<method>(axis_2).squeeze()'</span></code>.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'fill=<color>'</span></code> to set the primary color.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'fill=<color>'</span></code> to set the primary color.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'width=<int>'</span></code> to set the width of lines or contours.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'width=<int>'</span></code> to set the width of lines or contours.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'outline=<color>'</span></code> to set the color of the contours.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'outline=<color>'</span></code> to set the color of the contours.</strong></li>
<li><strong>Colors can be specified as an int, tuple, <codeclass="python hljs"><spanclass="hljs-string">'#rrggbb[aa]'</span></code> string or a color name.</strong></li>
<li><strong>Color can be specified as an int, tuple, <codeclass="python hljs"><spanclass="hljs-string">'#rrggbb[aa]'</span></code> string or a color name.</strong></li>
</ul>
</ul>
<div><h2id="animation"><ahref="#animation"name="animation">#</a>Animation</h2><div><h4id="createsagifofabouncingball">Creates a GIF of a bouncing ball:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-comment"># $ pip3 install imageio</span>
<div><h2id="animation"><ahref="#animation"name="animation">#</a>Animation</h2><div><h4id="createsagifofabouncingball">Creates a GIF of a bouncing ball:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-comment"># $ pip3 install imageio</span>
<div><h3id="rectangle">Rectangle</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><codeclass="python language-python hljs"><Rect> = pg.Rect(x, y, width, height) <spanclass="hljs-comment"># Floats get truncated into ints.</span>
<div><h3id="rectangle">Rectangle</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><codeclass="python language-python hljs"><Rect> = pg.Rect(x, y, width, height) <spanclass="hljs-comment"># Floats get truncated into ints.</span>