Browse Source

Format, Pygame

pull/111/head
Jure Šorn 3 years ago
parent
commit
bbde7a70b5
2 changed files with 13 additions and 9 deletions
  1. 8
      README.md
  2. 14
      index.html

8
README.md

@ -412,18 +412,20 @@ Format
{<el>:.<10} # '<el>......'
{<el>:0} # '<el>'
```
* **Use `'{<el>:{<str/int/float>}[...]}'` to set options dynamically.**
* **Options can be generated dynamically: `f'{<el>:{<str/int>}[…]}'`.**
* **Adding `'!r'` before the colon converts object to string by calling its [repr()](#class) method.**
### Strings
```python
{'abcde'!r:10} # "'abcde' "
{'abcde':10} # 'abcde '
{'abcde':10.3} # 'abc '
{'abcde':.3} # 'abc'
{'abcde'!r:10} # "'abcde' "
```
### Numbers
```python
{ 123456:10} # ' 123456'
{ 123456:10,} # ' 123,456'
{ 123456:10_} # ' 123_456'
{ 123456:+10} # ' +123456'
@ -2950,7 +2952,7 @@ while all(event.type != pg.QUIT for event in pg.event.get()):
**Object for representing images.**
```python
<Surf> = pg.display.set_mode((width, height)) # Returns display surface.
<Surf> = pg.Surface((width, height), …) # New RGB surface. Add `pg.SRCALPHA` for RGBA.
<Surf> = pg.Surface((width, height) [, flags]) # New RGB surface. RGBA if `flags=pg.SRCALPHA`.
<Surf> = pg.image.load('<path>') # Loads the image. Format depends on source.
<Surf> = <Surf>.subsurface(<Rect>) # Returns a subsurface.
```

14
index.html

@ -226,7 +226,7 @@ pre.prettyprint {
<body>
<header>
<aside>October 2, 2021</aside>
<aside>October 4, 2021</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -537,15 +537,17 @@ to_exclusive = &lt;range&gt;.stop
</code></pre></div>
<ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'{&lt;el&gt;:{&lt;str/int/float&gt;}[...]}'</span></code> to set options dynamically.</strong></li>
<li><strong>Options can be generated dynamically: <code class="python hljs"><span class="hljs-string">f'<span class="hljs-subst">{&lt;el&gt;:{&lt;str/int&gt;}</span>[…]}'</span></code>.</strong></li>
<li><strong>Adding <code class="python hljs"><span class="hljs-string">'!r'</span></code> before the colon converts object to string by calling its <a href="#class">repr()</a> method.</strong></li>
</ul>
<div><h3 id="strings">Strings</h3><pre><code class="python language-python hljs">{<span class="hljs-string">'abcde'</span>!r:<span class="hljs-number">10</span>} <span class="hljs-comment"># "'abcde' "</span>
<div><h3 id="strings">Strings</h3><pre><code class="python language-python hljs">{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10</span>} <span class="hljs-comment"># 'abcde '</span>
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># 'abc '</span>
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">.3</span>} <span class="hljs-comment"># 'abc'</span>
{<span class="hljs-string">'abcde'</span>!r:<span class="hljs-number">10</span>} <span class="hljs-comment"># "'abcde' "</span>
</code></pre></div>
<div><h3 id="numbers-1">Numbers</h3><pre><code class="python language-python hljs">{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>,} <span class="hljs-comment"># ' 123,456'</span>
<div><h3 id="numbers-1">Numbers</h3><pre><code class="python language-python hljs">{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>} <span class="hljs-comment"># ' 123456'</span>
{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>,} <span class="hljs-comment"># ' 123,456'</span>
{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>_} <span class="hljs-comment"># ' 123_456'</span>
{ <span class="hljs-number">123456</span>:+<span class="hljs-number">10</span>} <span class="hljs-comment"># ' +123456'</span>
{<span class="hljs-number">-123456</span>:=<span class="hljs-number">10</span>} <span class="hljs-comment"># '- 123456'</span>
@ -2538,7 +2540,7 @@ rect = pg.Rect(<span class="hljs-number">240</span>, <span class="hljs-number">2
&lt;list&gt; = &lt;Rect&gt;.collidelistall(&lt;list_of_Rect&gt;) <span class="hljs-comment"># Returns indexes of all colliding Rects.</span>
</code></pre>
<div><h3 id="surface">Surface</h3><p><strong>Object for representing images.</strong></p><pre><code class="python language-python hljs">&lt;Surf&gt; = pg.display.set_mode((width, height)) <span class="hljs-comment"># Returns display surface.</span>
&lt;Surf&gt; = pg.Surface((width, height), …) <span class="hljs-comment"># New RGB surface. Add `pg.SRCALPHA` for RGBA.</span>
&lt;Surf&gt; = pg.Surface((width, height) [, flags]) <span class="hljs-comment"># New RGB surface. RGBA if `flags=pg.SRCALPHA`.</span>
&lt;Surf&gt; = pg.image.load(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Loads the image. Format depends on source.</span>
&lt;Surf&gt; = &lt;Surf&gt;.subsurface(&lt;Rect&gt;) <span class="hljs-comment"># Returns a subsurface.</span>
</code></pre></div>
@ -3005,7 +3007,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer>
<aside>October 2, 2021</aside>
<aside>October 4, 2021</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save