|
2493 | 2493 | </code></pre></div></div>
|
2494 | 2494 |
|
2495 | 2495 |
|
2496 |
| -<div><h3 id="rect">Rect</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><code class="python language-python hljs"><Rect> = pg.Rect(topleft_x, topleft_y, width, height) <span class="hljs-comment"># x, y, w/width, h/height</span> |
2497 |
| -<int> = <Rect>.x/y/centerx/centery/bottom/left/right/top |
2498 |
| -<tuple> = <Rect>.topleft/center/topright/bottomright/bottomleft |
2499 |
| -<tuple> = <Rect>.midtop/midright/midbottom/midleft |
| 2496 | +<div><h3 id="rect">Rect</h3><p><strong>Object for storing rectangular coordinates.</strong></p><pre><code class="python language-python hljs"><Rect> = pg.Rect(topleft_x, topleft_y, width, height) |
| 2497 | +<tuple> = <Rect>.topleft/topright/bottomright/bottomleft/center |
| 2498 | +<int> = <Rect>.x/y/centerx/centery |
2500 | 2499 | </code></pre></div>
|
2501 | 2500 |
|
2502 | 2501 |
|
2503 |
| -<pre><code class="python language-python hljs"><Rect> = <Rect>.move(<tuple>/<int>, <int>) |
2504 |
| -<Rect>.move_ip(<tuple>/<int>, <int>) |
2505 |
| -<Rect> = <Rect>.inflate(<tuple>/<int>, <int>) |
2506 |
| -<Rect>.inflate_ip(<tuple>/<int>, <int>) |
| 2502 | +<pre><code class="python language-python hljs"><Rect> = <Rect>.move(<tuple>) <span class="hljs-comment"># Or: <Rect>.move(<int>, <int>)</span> |
| 2503 | +<Rect>.move_ip(<tuple>) <span class="hljs-comment"># Or: <Rect>.move_ip(<int>, <int>)</span> |
2507 | 2504 | </code></pre>
|
2508 |
| -<pre><code class="python language-python hljs"><bool> = <Rect>.contains(<Rect>) |
2509 |
| -<bool> = <Rect>.collidepoint(<tuple>/<int>, <int>) |
| 2505 | +<pre><code class="python language-python hljs"><bool> = <Rect>.collidepoint(<tuple>) <span class="hljs-comment"># Or: <Rect>.collidepoint(<int>, <int>)</span> |
2510 | 2506 | <bool> = <Rect>.colliderect(<Rect>)
|
2511 | 2507 | index = <Rect>.collidelist(<list_of_Rect>) <span class="hljs-comment"># Returns index of first coliding Rect or -1.</span>
|
2512 | 2508 | indices = <Rect>.collidelistall(<list_of_Rect>) <span class="hljs-comment"># Returns indices of all colinding Rects.</span>
|
2513 |
| -(key, value) = <Rect>.collidedict(<dict_of_Rect>) |
2514 |
| -[(key, value), ...] = <Rect>.collidedictall(<dict_of_Rect>) |
2515 | 2509 | </code></pre>
|
2516 | 2510 | <div><h3 id="surface">Surface</h3><p><strong>Object for representing images.</strong></p><pre><code class="python language-python hljs"><Surface> = pg.display.set_mode((width, height)) <span class="hljs-comment"># Retruns the display surface.</span>
|
2517 | 2511 | <Surface> = pg.Surface((width, height)) <span class="hljs-comment"># Creates a new surface.</span>
|
|
2521 | 2515 |
|
2522 | 2516 | <pre><code class="python language-python hljs"><Surface>.set_at((x, y), <color>) <span class="hljs-comment"># Updates pixel.</span>
|
2523 | 2517 | <Surface>.fill(<color>) <span class="hljs-comment"># Fills the whole surface.</span>
|
2524 |
| -<Surface>.blit(<Surface>, (x, y)/<Rect>) <span class="hljs-comment"># Draws passed surface to the surface.</span> |
| 2518 | +<Surface>.blit(<Surface>, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span> |
2525 | 2519 | <Surface> = <Surface>.subsurface(<Rect>) <span class="hljs-comment"># Returns subsurface.</span>
|
2526 | 2520 | </code></pre>
|
2527 | 2521 | <pre><code class="python language-python hljs"><Surface> = pg.transform.flip(<Surface>, xbool, ybool)
|
2528 | 2522 | <Surface> = pg.transform.rotate(<Surface>, angle)
|
2529 | 2523 | <Surface> = pg.transform.scale(<Surface>, (width, height))
|
2530 | 2524 | </code></pre>
|
2531 |
| -<div><h4 id="drawing-1">Drawing:</h4><pre><code class="python language-python hljs">pg.draw.rect(<Surface>, color, <Rect>) |
| 2525 | +<pre><code class="python language-python hljs">pg.draw.rect(<Surface>, color, <Rect>) |
2532 | 2526 | pg.draw.polygon(<Surface>, color, points)
|
2533 | 2527 | pg.draw.circle(<Surface>, color, center, radius)
|
2534 | 2528 | pg.draw.ellipse(<Surface>, color, <Rect>)
|
2535 | 2529 | pg.draw.arc(<Surface>, color, <Rect>, start_angle, stop_angle)
|
2536 | 2530 | pg.draw.line(<Surface>, color, start_pos, end_pos, width)
|
2537 | 2531 | pg.draw.lines(<Surface>, color, points)
|
2538 |
| -</code></pre></div> |
2539 |
| - |
2540 |
| -<div><h4 id="fonts">Fonts:</h4><pre><code class="python language-python hljs"><Font> = pg.font.SysFont(name, size, bold=<span class="hljs-keyword">False</span>, italic=<span class="hljs-keyword">False</span>) |
| 2532 | +</code></pre> |
| 2533 | +<div><h3 id="font">Font</h3><pre><code class="python language-python hljs"><Font> = pg.font.SysFont(name, size, bold=<span class="hljs-keyword">False</span>, italic=<span class="hljs-keyword">False</span>) |
2541 | 2534 | <Font> = pg.font.Font(<span class="hljs-string">'<path>'</span>, size)
|
2542 | 2535 | <Surface> = <Font>.render(text, antialias, color, background=<span class="hljs-keyword">None</span>)
|
2543 | 2536 | </code></pre></div>
|
|
0 commit comments