Browse Source

Pygame and paths

pull/79/head
Jure Šorn 4 years ago
parent
commit
afe1fb57e3
2 changed files with 20 additions and 20 deletions
  1. 20
      README.md
  2. 20
      index.html

20
README.md

@ -1523,7 +1523,7 @@ Open
**Opens the file and returns a corresponding file object.** **Opens the file and returns a corresponding file object.**
```python ```python
<file> = open('<path>', mode='r', encoding=None, newline=None)
<file> = open(<path>, mode='r', encoding=None, newline=None)
``` ```
* **`'encoding=None'` means that the default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.** * **`'encoding=None'` means that the default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.**
* **`'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.** * **`'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
**Opens a connection to the database file. Creates a new file if path doesn't exist.** **Opens a connection to the database file. Creates a new file if path doesn't exist.**
```python ```python
import sqlite3 import sqlite3
<con> = sqlite3.connect('<path>') # Also ':memory:'.
<con> = sqlite3.connect(<path>) # Also ':memory:'.
<con>.close() # Closes the connection. <con>.close() # Closes the connection.
``` ```
@ -2347,7 +2347,7 @@ from matplotlib import pyplot
pyplot.plot(<y_data> [, label=<str>]) pyplot.plot(<y_data> [, label=<str>])
pyplot.plot(<x_data>, <y_data>) pyplot.plot(<x_data>, <y_data>)
pyplot.legend() # Adds a legend. pyplot.legend() # Adds a legend.
pyplot.savefig('<path>') # Saves the figure.
pyplot.savefig(<path>) # Saves the figure.
pyplot.show() # Displays the figure. pyplot.show() # Displays the figure.
pyplot.clf() # Clears the figure. pyplot.clf() # Clears the figure.
``` ```
@ -2697,9 +2697,9 @@ from PIL import Image
```python ```python
<Image> = Image.new('<mode>', (width, height)) <Image> = Image.new('<mode>', (width, height))
<Image> = Image.open('<path>')
<Image> = Image.open(<path>)
<Image> = <Image>.convert('<mode>') <Image> = <Image>.convert('<mode>')
<Image>.save('<path>')
<Image>.save(<path>)
<Image>.show() <Image>.show()
``` ```
@ -2961,9 +2961,9 @@ while all(event.type != pg.QUIT for event in pg.event.get()):
``` ```
```python ```python
<Surf> = pg.transform.flip(<Surf>, xbool, ybool)
<Surf> = pg.transform.rotate(<Surf>, degrees)
<Surf> = pg.transform.scale(<Surf>, (width, height)) <Surf> = pg.transform.scale(<Surf>, (width, height))
<Surf> = pg.transform.rotate(<Surf>, degrees)
<Surf> = pg.transform.flip(<Surf>, xbool, ybool)
``` ```
```python ```python
@ -2976,9 +2976,9 @@ pg.draw.ellipse(<Surf>, color, <Rect>)
### Font ### Font
```python ```python
<Font> = pg.font.SysFont('<name>', size, bold=False, italic=False)
<Font> = pg.font.Font('<path>', size)
<Surf> = <Font>.render(text, antialias, color [, background])
<Font> = pg.font.SysFont('<name>', size) # Loads the system font or default if missing.
<Font> = pg.font.Font('<path>', size) # Loads the TTF file. Pass None for default.
<Surf> = <Font>.render(text, antialias, color) # Background color can be specified at the end.
``` ```
### Sound ### Sound

20
index.html

@ -1426,7 +1426,7 @@ value = args.&lt;name&gt;
<li><strong>Use <code class="python hljs"><span class="hljs-string">'default=&lt;el&gt;'</span></code> to set the default value.</strong></li> <li><strong>Use <code class="python hljs"><span class="hljs-string">'default=&lt;el&gt;'</span></code> to set the default value.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files.</strong></li> <li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files.</strong></li>
</ul> </ul>
<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>)
<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>)
</code></pre></div> </code></pre></div>
@ -1659,7 +1659,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
</code></pre></div> </code></pre></div>
<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 <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
&lt;con&gt; = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also ':memory:'.</span>
&lt;con&gt; = sqlite3.connect(&lt;path&gt;) <span class="hljs-comment"># Also ':memory:'.</span>
&lt;con&gt;.close() <span class="hljs-comment"># Closes the connection.</span> &lt;con&gt;.close() <span class="hljs-comment"># Closes the connection.</span>
</code></pre></div></div> </code></pre></div></div>
@ -2049,7 +2049,7 @@ curses.wrapper(main)
pyplot.plot(&lt;y_data&gt; [, label=&lt;str&gt;]) pyplot.plot(&lt;y_data&gt; [, label=&lt;str&gt;])
pyplot.plot(&lt;x_data&gt;, &lt;y_data&gt;) pyplot.plot(&lt;x_data&gt;, &lt;y_data&gt;)
pyplot.legend() <span class="hljs-comment"># Adds a legend.</span> pyplot.legend() <span class="hljs-comment"># Adds a legend.</span>
pyplot.savefig(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Saves the figure.</span>
pyplot.savefig(&lt;path&gt;) <span class="hljs-comment"># Saves the figure.</span>
pyplot.show() <span class="hljs-comment"># Displays the figure.</span> pyplot.show() <span class="hljs-comment"># Displays the figure.</span>
pyplot.clf() <span class="hljs-comment"># Clears the figure.</span> pyplot.clf() <span class="hljs-comment"># Clears the figure.</span>
</code></pre></div> </code></pre></div>
@ -2318,9 +2318,9 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.6</s
</code></pre></div> </code></pre></div>
<pre><code class="python language-python hljs">&lt;Image&gt; = Image.new(<span class="hljs-string">'&lt;mode&gt;'</span>, (width, height)) <pre><code class="python language-python hljs">&lt;Image&gt; = Image.new(<span class="hljs-string">'&lt;mode&gt;'</span>, (width, height))
&lt;Image&gt; = Image.open(<span class="hljs-string">'&lt;path&gt;'</span>)
&lt;Image&gt; = Image.open(&lt;path&gt;)
&lt;Image&gt; = &lt;Image&gt;.convert(<span class="hljs-string">'&lt;mode&gt;'</span>) &lt;Image&gt; = &lt;Image&gt;.convert(<span class="hljs-string">'&lt;mode&gt;'</span>)
&lt;Image&gt;.save(<span class="hljs-string">'&lt;path&gt;'</span>)
&lt;Image&gt;.save(&lt;path&gt;)
&lt;Image&gt;.show() &lt;Image&gt;.show()
</code></pre> </code></pre>
<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> <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,9 +2531,9 @@ rect = pg.Rect(<span class="hljs-number">240</span>, <span class="hljs-number">2
&lt;Surf&gt;.set_at((x, y), color) <span class="hljs-comment"># Updates pixel.</span> &lt;Surf&gt;.set_at((x, y), color) <span class="hljs-comment"># Updates pixel.</span>
&lt;Surf&gt;.blit(&lt;Surface&gt;, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span> &lt;Surf&gt;.blit(&lt;Surface&gt;, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;Surf&gt; = pg.transform.flip(&lt;Surf&gt;, xbool, ybool)
<pre><code class="python language-python hljs">&lt;Surf&gt; = pg.transform.scale(&lt;Surf&gt;, (width, height))
&lt;Surf&gt; = pg.transform.rotate(&lt;Surf&gt;, degrees) &lt;Surf&gt; = pg.transform.rotate(&lt;Surf&gt;, degrees)
&lt;Surf&gt; = pg.transform.scale(&lt;Surf&gt;, (width, height))
&lt;Surf&gt; = pg.transform.flip(&lt;Surf&gt;, xbool, ybool)
</code></pre> </code></pre>
<pre><code class="python language-python hljs">pg.draw.line(&lt;Surf&gt;, color, (x1, y1), (x2, y2), width) <pre><code class="python language-python hljs">pg.draw.line(&lt;Surf&gt;, color, (x1, y1), (x2, y2), width)
pg.draw.arc(&lt;Surf&gt;, color, &lt;Rect&gt;, from_radians, to_radians) pg.draw.arc(&lt;Surf&gt;, color, &lt;Rect&gt;, from_radians, to_radians)
@ -2541,9 +2541,9 @@ pg.draw.rect(&lt;Surf&gt;, color, &lt;Rect&gt;)
pg.draw.polygon(&lt;Surf&gt;, color, points) pg.draw.polygon(&lt;Surf&gt;, color, points)
pg.draw.ellipse(&lt;Surf&gt;, color, &lt;Rect&gt;) pg.draw.ellipse(&lt;Surf&gt;, color, &lt;Rect&gt;)
</code></pre> </code></pre>
<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>)
&lt;Font&gt; = pg.font.Font(<span class="hljs-string">'&lt;path&gt;'</span>, size)
&lt;Surf&gt; = &lt;Font&gt;.render(text, antialias, color [, background])
<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>
&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>
&lt;Surf&gt; = &lt;Font&gt;.render(text, antialias, color) <span class="hljs-comment"># Background color can be specified at the end.</span>
</code></pre></div> </code></pre></div>
<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> <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>

Loading…
Cancel
Save