Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afe1fb5

Browse files
committed
Pygame and paths
1 parent 412bcc0 commit afe1fb5

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ Open
15231523
**Opens the file and returns a corresponding file object.**
15241524

15251525
```python
1526-
<file> = open('<path>', mode='r', encoding=None, newline=None)
1526+
<file> = open(<path>, mode='r', encoding=None, newline=None)
15271527
```
15281528
* **`'encoding=None'` means that the default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.**
15291529
* **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
@@ -1841,7 +1841,7 @@ SQLite
18411841
**Opens a connection to the database file. Creates a new file if path doesn't exist.**
18421842
```python
18431843
import sqlite3
1844-
<con> = sqlite3.connect('<path>') # Also ':memory:'.
1844+
<con> = sqlite3.connect(<path>) # Also ':memory:'.
18451845
<con>.close() # Closes the connection.
18461846
```
18471847

@@ -2347,7 +2347,7 @@ from matplotlib import pyplot
23472347
pyplot.plot(<y_data> [, label=<str>])
23482348
pyplot.plot(<x_data>, <y_data>)
23492349
pyplot.legend() # Adds a legend.
2350-
pyplot.savefig('<path>') # Saves the figure.
2350+
pyplot.savefig(<path>) # Saves the figure.
23512351
pyplot.show() # Displays the figure.
23522352
pyplot.clf() # Clears the figure.
23532353
```
@@ -2697,9 +2697,9 @@ from PIL import Image
26972697

26982698
```python
26992699
<Image> = Image.new('<mode>', (width, height))
2700-
<Image> = Image.open('<path>')
2700+
<Image> = Image.open(<path>)
27012701
<Image> = <Image>.convert('<mode>')
2702-
<Image>.save('<path>')
2702+
<Image>.save(<path>)
27032703
<Image>.show()
27042704
```
27052705

@@ -2961,9 +2961,9 @@ while all(event.type != pg.QUIT for event in pg.event.get()):
29612961
```
29622962

29632963
```python
2964-
<Surf> = pg.transform.flip(<Surf>, xbool, ybool)
2965-
<Surf> = pg.transform.rotate(<Surf>, degrees)
29662964
<Surf> = pg.transform.scale(<Surf>, (width, height))
2965+
<Surf> = pg.transform.rotate(<Surf>, degrees)
2966+
<Surf> = pg.transform.flip(<Surf>, xbool, ybool)
29672967
```
29682968

29692969
```python
@@ -2976,9 +2976,9 @@ pg.draw.ellipse(<Surf>, color, <Rect>)
29762976

29772977
### Font
29782978
```python
2979-
<Font> = pg.font.SysFont('<name>', size, bold=False, italic=False)
2980-
<Font> = pg.font.Font('<path>', size)
2981-
<Surf> = <Font>.render(text, antialias, color [, background])
2979+
<Font> = pg.font.SysFont('<name>', size) # Loads the system font or default if missing.
2980+
<Font> = pg.font.Font('<path>', size) # Loads the TTF file. Pass None for default.
2981+
<Surf> = <Font>.render(text, antialias, color) # Background color can be specified at the end.
29822982
```
29832983

29842984
### Sound

index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@
14261426
<li><strong>Use <code class="python hljs"><span class="hljs-string">'default=&lt;el&gt;'</span></code> to set the default value.</strong></li>
14271427
<li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files.</strong></li>
14281428
</ul>
1429-
<div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs">&lt;file&gt; = open(<span class="hljs-string">'&lt;path&gt;'</span>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>)
1429+
<div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs">&lt;file&gt; = open(&lt;path&gt;, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>)
14301430
</code></pre></div>
14311431

14321432

@@ -1659,7 +1659,7 @@
16591659
</code></pre></div>
16601660

16611661
<div><h2 id="sqlite"><a href="#sqlite" name="sqlite">#</a>SQLite</h2><p><strong>Server-less database engine that stores each database into a separate file.</strong></p><div><h3 id="connect">Connect</h3><p><strong>Opens a connection to the database file. Creates a new file if path doesn't exist.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> sqlite3
1662-
&lt;con&gt; = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also ':memory:'.</span>
1662+
&lt;con&gt; = sqlite3.connect(&lt;path&gt;) <span class="hljs-comment"># Also ':memory:'.</span>
16631663
&lt;con&gt;.close() <span class="hljs-comment"># Closes the connection.</span>
16641664
</code></pre></div></div>
16651665

@@ -2049,7 +2049,7 @@
20492049
pyplot.plot(&lt;y_data&gt; [, label=&lt;str&gt;])
20502050
pyplot.plot(&lt;x_data&gt;, &lt;y_data&gt;)
20512051
pyplot.legend() <span class="hljs-comment"># Adds a legend.</span>
2052-
pyplot.savefig(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Saves the figure.</span>
2052+
pyplot.savefig(&lt;path&gt;) <span class="hljs-comment"># Saves the figure.</span>
20532053
pyplot.show() <span class="hljs-comment"># Displays the figure.</span>
20542054
pyplot.clf() <span class="hljs-comment"># Clears the figure.</span>
20552055
</code></pre></div>
@@ -2318,9 +2318,9 @@
23182318
</code></pre></div>
23192319

23202320
<pre><code class="python language-python hljs">&lt;Image&gt; = Image.new(<span class="hljs-string">'&lt;mode&gt;'</span>, (width, height))
2321-
&lt;Image&gt; = Image.open(<span class="hljs-string">'&lt;path&gt;'</span>)
2321+
&lt;Image&gt; = Image.open(&lt;path&gt;)
23222322
&lt;Image&gt; = &lt;Image&gt;.convert(<span class="hljs-string">'&lt;mode&gt;'</span>)
2323-
&lt;Image&gt;.save(<span class="hljs-string">'&lt;path&gt;'</span>)
2323+
&lt;Image&gt;.save(&lt;path&gt;)
23242324
&lt;Image&gt;.show()
23252325
</code></pre>
23262326
<pre><code class="python language-python hljs">&lt;int/tuple&gt; = &lt;Image&gt;.getpixel((x, y)) <span class="hljs-comment"># Returns a pixel.</span>
@@ -2531,19 +2531,19 @@
25312531
&lt;Surf&gt;.set_at((x, y), color) <span class="hljs-comment"># Updates pixel.</span>
25322532
&lt;Surf&gt;.blit(&lt;Surface&gt;, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span>
25332533
</code></pre>
2534-
<pre><code class="python language-python hljs">&lt;Surf&gt; = pg.transform.flip(&lt;Surf&gt;, xbool, ybool)
2534+
<pre><code class="python language-python hljs">&lt;Surf&gt; = pg.transform.scale(&lt;Surf&gt;, (width, height))
25352535
&lt;Surf&gt; = pg.transform.rotate(&lt;Surf&gt;, degrees)
2536-
&lt;Surf&gt; = pg.transform.scale(&lt;Surf&gt;, (width, height))
2536+
&lt;Surf&gt; = pg.transform.flip(&lt;Surf&gt;, xbool, ybool)
25372537
</code></pre>
25382538
<pre><code class="python language-python hljs">pg.draw.line(&lt;Surf&gt;, color, (x1, y1), (x2, y2), width)
25392539
pg.draw.arc(&lt;Surf&gt;, color, &lt;Rect&gt;, from_radians, to_radians)
25402540
pg.draw.rect(&lt;Surf&gt;, color, &lt;Rect&gt;)
25412541
pg.draw.polygon(&lt;Surf&gt;, color, points)
25422542
pg.draw.ellipse(&lt;Surf&gt;, color, &lt;Rect&gt;)
25432543
</code></pre>
2544-
<div><h3 id="font">Font</h3><pre><code class="python language-python hljs">&lt;Font&gt; = pg.font.SysFont(<span class="hljs-string">'&lt;name&gt;'</span>, size, bold=<span class="hljs-keyword">False</span>, italic=<span class="hljs-keyword">False</span>)
2545-
&lt;Font&gt; = pg.font.Font(<span class="hljs-string">'&lt;path&gt;'</span>, size)
2546-
&lt;Surf&gt; = &lt;Font&gt;.render(text, antialias, color [, background])
2544+
<div><h3 id="font">Font</h3><pre><code class="python language-python hljs">&lt;Font&gt; = pg.font.SysFont(<span class="hljs-string">'&lt;name&gt;'</span>, size) <span class="hljs-comment"># Loads the system font or default if missing.</span>
2545+
&lt;Font&gt; = pg.font.Font(<span class="hljs-string">'&lt;path&gt;'</span>, size) <span class="hljs-comment"># Loads the TTF file. Pass None for default.</span>
2546+
&lt;Surf&gt; = &lt;Font&gt;.render(text, antialias, color) <span class="hljs-comment"># Background color can be specified at the end.</span>
25472547
</code></pre></div>
25482548

25492549
<div><h3 id="sound">Sound</h3><pre><code class="python language-python hljs">&lt;Sound&gt; = pg.mixer.Sound(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Loads the WAV file.</span>

0 commit comments

Comments
 (0)