Browse Source

Audio, Pygame, Pandas

pull/115/head
Jure Šorn 2 years ago
parent
commit
2cbeb5d2e7
3 changed files with 11 additions and 11 deletions
  1. 8
      README.md
  2. 12
      index.html
  3. 2
      parse.js

8
README.md

@ -2825,7 +2825,7 @@ nframes = <Wave_read>.getnframes() # Number of frames.
* **Bytes object contains a sequence of frames, each consisting of one or more samples.** * **Bytes object contains a sequence of frames, each consisting of one or more samples.**
* **In a stereo signal, the first sample of a frame belongs to the left channel.** * **In a stereo signal, the first sample of a frame belongs to the left channel.**
* **Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.** * **Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.**
* **If sample width is one, then the integer should be encoded unsigned.**
* **If sample width is one byte, then the integer should be encoded unsigned.**
* **For all other sizes, the integer should be encoded signed with little-endian byte order.** * **For all other sizes, the integer should be encoded signed with little-endian byte order.**
### Sample Values ### Sample Values
@ -2949,7 +2949,7 @@ while all(event.type != pg.QUIT for event in pg.event.get()):
```python ```python
<Rect> = pg.Rect(x, y, width, height) # Floats get truncated into ints. <Rect> = pg.Rect(x, y, width, height) # Floats get truncated into ints.
<int> = <Rect>.x/y/centerx/centery/… # Top, right, bottom, left. Allows assignments. <int> = <Rect>.x/y/centerx/centery/… # Top, right, bottom, left. Allows assignments.
<tup.> = <Rect>.topleft/center/… # Topright, bottomright, bottomleft.
<tup.> = <Rect>.topleft/center/… # Topright, bottomright, bottomleft. Same.
<Rect> = <Rect>.move((x, y)) # Use move_ip() to move in place. <Rect> = <Rect>.move((x, y)) # Use move_ip() to move in place.
``` ```
@ -3014,7 +3014,7 @@ SIZE, MAX_SPEED = 50, P(5, 10) # Screen size, Speed limit
def main(): def main():
def get_screen(): def get_screen():
pg.init() pg.init()
return pg.display.set_mode(2 * [SIZE*16])
return pg.display.set_mode((SIZE*16, SIZE*16))
def get_images(): def get_images():
url = 'https://gto76.github.io/python-cheatsheet/web/mario_bros.png' url = 'https://gto76.github.io/python-cheatsheet/web/mario_bros.png'
img = pg.image.load(io.BytesIO(urllib.request.urlopen(url).read())) img = pg.image.load(io.BytesIO(urllib.request.urlopen(url).read()))
@ -3230,7 +3230,7 @@ c 6 7
| pd.concat([l, r], | x y z | y | | Adds rows at the bottom. | | pd.concat([l, r], | x y z | y | | Adds rows at the bottom. |
| axis=0, | a 1 2 . | 2 | | Uses 'outer' by default. | | axis=0, | a 1 2 . | 2 | | Uses 'outer' by default. |
| join=…) | b 3 4 . | 4 | | A series is treated as a | | join=…) | b 3 4 . | 4 | | A series is treated as a |
| | b . 4 5 | 4 | | column. Use l.append(r) |
| | b . 4 5 | 4 | | column. Use l.append(sr) |
| | c . 6 7 | 6 | | to add a row instead. | | | c . 6 7 | 6 | | to add a row instead. |
+------------------------+---------------+------------+------------+--------------------------+ +------------------------+---------------+------------+------------+--------------------------+
| pd.concat([l, r], | x y y z | | | Adds columns at the | | pd.concat([l, r], | x y y z | | | Adds columns at the |

12
index.html

@ -226,7 +226,7 @@ pre.prettyprint {
<body> <body>
<header> <header>
<aside>October 20, 2021</aside>
<aside>October 21, 2021</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header> </header>
@ -2440,7 +2440,7 @@ nframes = &lt;Wave_read&gt;.getnframes() <span class="hljs-comment"
<li><strong>Bytes object contains a sequence of frames, each consisting of one or more samples.</strong></li> <li><strong>Bytes object contains a sequence of frames, each consisting of one or more samples.</strong></li>
<li><strong>In a stereo signal, the first sample of a frame belongs to the left channel.</strong></li> <li><strong>In a stereo signal, the first sample of a frame belongs to the left channel.</strong></li>
<li><strong>Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.</strong></li> <li><strong>Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.</strong></li>
<li><strong>If sample width is one, then the integer should be encoded unsigned.</strong></li>
<li><strong>If sample width is one byte, then the integer should be encoded unsigned.</strong></li>
<li><strong>For all other sizes, the integer should be encoded signed with little-endian byte order.</strong></li> <li><strong>For all other sizes, the integer should be encoded signed with little-endian byte order.</strong></li>
</ul> </ul>
<div><h3 id="samplevalues">Sample Values</h3><pre><code class="python hljs">┏━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━━━━┓ <div><h3 id="samplevalues">Sample Values</h3><pre><code class="python hljs">┏━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━━━━┓
@ -2539,7 +2539,7 @@ rect = pg.Rect(<span class="hljs-number">240</span>, <span class="hljs-number">2
<div><h3 id="rectangle">Rectangle</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><code class="python language-python hljs">&lt;Rect&gt; = pg.Rect(x, y, width, height) <span class="hljs-comment"># Floats get truncated into ints.</span> <div><h3 id="rectangle">Rectangle</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><code class="python language-python hljs">&lt;Rect&gt; = pg.Rect(x, y, width, height) <span class="hljs-comment"># Floats get truncated into ints.</span>
&lt;int&gt; = &lt;Rect&gt;.x/y/centerx/centery/… <span class="hljs-comment"># Top, right, bottom, left. Allows assignments.</span> &lt;int&gt; = &lt;Rect&gt;.x/y/centerx/centery/… <span class="hljs-comment"># Top, right, bottom, left. Allows assignments.</span>
&lt;tup.&gt; = &lt;Rect&gt;.topleft/center/… <span class="hljs-comment"># Topright, bottomright, bottomleft.</span>
&lt;tup.&gt; = &lt;Rect&gt;.topleft/center/… <span class="hljs-comment"># Topright, bottomright, bottomleft. Same.</span>
&lt;Rect&gt; = &lt;Rect&gt;.move((x, y)) <span class="hljs-comment"># Use move_ip() to move in place.</span> &lt;Rect&gt; = &lt;Rect&gt;.move((x, y)) <span class="hljs-comment"># Use move_ip() to move in place.</span>
</code></pre></div> </code></pre></div>
@ -2589,7 +2589,7 @@ SIZE, MAX_SPEED = <span class="hljs-number">50</span>, P(<span class="hljs-numbe
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_screen</span><span class="hljs-params">()</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_screen</span><span class="hljs-params">()</span>:</span>
pg.init() pg.init()
<span class="hljs-keyword">return</span> pg.display.set_mode(<span class="hljs-number">2</span> * [SIZE*<span class="hljs-number">16</span>])
<span class="hljs-keyword">return</span> pg.display.set_mode((SIZE*<span class="hljs-number">16</span>, SIZE*<span class="hljs-number">16</span>))
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_images</span><span class="hljs-params">()</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_images</span><span class="hljs-params">()</span>:</span>
url = <span class="hljs-string">'https://gto76.github.io/python-cheatsheet/web/mario_bros.png'</span> url = <span class="hljs-string">'https://gto76.github.io/python-cheatsheet/web/mario_bros.png'</span>
img = pg.image.load(io.BytesIO(urllib.request.urlopen(url).read())) img = pg.image.load(io.BytesIO(urllib.request.urlopen(url).read()))
@ -2768,7 +2768,7 @@ c <span class="hljs-number">6</span> <span class="hljs-number">7</span>
┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃ ┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃
┃ axis=<span class="hljs-number">0</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ <span class="hljs-number">2</span> │ │ Uses <span class="hljs-string">'outer'</span> by default. ┃ ┃ axis=<span class="hljs-number">0</span>, │ a <span class="hljs-number">1</span> <span class="hljs-number">2</span> . │ <span class="hljs-number">2</span> │ │ Uses <span class="hljs-string">'outer'</span> by default. ┃
┃ join=…) │ b <span class="hljs-number">3</span> <span class="hljs-number">4</span> . │ <span class="hljs-number">4</span> │ │ A series is treated as a ┃ ┃ join=…) │ b <span class="hljs-number">3</span> <span class="hljs-number">4</span> . │ <span class="hljs-number">4</span> │ │ A series is treated as a ┃
┃ │ b . <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">4</span> │ │ column. Use l.append(r)
┃ │ b . <span class="hljs-number">4</span> <span class="hljs-number">5</span><span class="hljs-number">4</span> │ │ column. Use l.append(sr) ┃
┃ │ c . <span class="hljs-number">6</span> <span class="hljs-number">7</span><span class="hljs-number">6</span> │ │ to add a row instead. ┃ ┃ │ c . <span class="hljs-number">6</span> <span class="hljs-number">7</span><span class="hljs-number">6</span> │ │ to add a row instead. ┃
┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨ ┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨
┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃ ┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃
@ -3017,7 +3017,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer> <footer>
<aside>October 20, 2021</aside>
<aside>October 21, 2021</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer> </footer>

2
parse.js

@ -350,7 +350,7 @@ const DIAGRAM_15_B =
"┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃\n" + "┃ pd.concat([l, r], │ x y z │ y │ │ Adds rows at the bottom. ┃\n" +
"┃ axis=0, │ a 1 2 . │ 2 │ │ Uses 'outer' by default. ┃\n" + "┃ axis=0, │ a 1 2 . │ 2 │ │ Uses 'outer' by default. ┃\n" +
"┃ join=…) │ b 3 4 . │ 4 │ │ A series is treated as a ┃\n" + "┃ join=…) │ b 3 4 . │ 4 │ │ A series is treated as a ┃\n" +
"┃ │ b . 4 5 │ 4 │ │ column. Use l.append(r) ┃\n" +
"┃ │ b . 4 5 │ 4 │ │ column. Use l.append(sr) ┃\n" +
"┃ │ c . 6 7 │ 6 │ │ to add a row instead. ┃\n" + "┃ │ c . 6 7 │ 6 │ │ to add a row instead. ┃\n" +
"┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" + "┠────────────────────────┼───────────────┼────────────┼────────────┼──────────────────────────┨\n" +
"┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃\n" + "┃ pd.concat([l, r], │ x y y z │ │ │ Adds columns at the ┃\n" +

Loading…
Cancel
Save