|
|
@ -2493,25 +2493,19 @@ rect = pg.Rect(<span class="hljs-number">235</span>, <span class="hljs-number">2 |
|
|
|
</code></pre></div></div> |
|
|
|
|
|
|
|
|
|
|
|
<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> |
|
|
|
<int> = <Rect>.x/y/centerx/centery/bottom/left/right/top |
|
|
|
<tuple> = <Rect>.topleft/center/topright/bottomright/bottomleft |
|
|
|
<tuple> = <Rect>.midtop/midright/midbottom/midleft |
|
|
|
<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) |
|
|
|
<tuple> = <Rect>.topleft/topright/bottomright/bottomleft/center |
|
|
|
<int> = <Rect>.x/y/centerx/centery |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><Rect> = <Rect>.move(<tuple>/<int>, <int>) |
|
|
|
<Rect>.move_ip(<tuple>/<int>, <int>) |
|
|
|
<Rect> = <Rect>.inflate(<tuple>/<int>, <int>) |
|
|
|
<Rect>.inflate_ip(<tuple>/<int>, <int>) |
|
|
|
<pre><code class="python language-python hljs"><Rect> = <Rect>.move(<tuple>) <span class="hljs-comment"># Or: <Rect>.move(<int>, <int>)</span> |
|
|
|
<Rect>.move_ip(<tuple>) <span class="hljs-comment"># Or: <Rect>.move_ip(<int>, <int>)</span> |
|
|
|
</code></pre> |
|
|
|
<pre><code class="python language-python hljs"><bool> = <Rect>.contains(<Rect>) |
|
|
|
<bool> = <Rect>.collidepoint(<tuple>/<int>, <int>) |
|
|
|
<pre><code class="python language-python hljs"><bool> = <Rect>.collidepoint(<tuple>) <span class="hljs-comment"># Or: <Rect>.collidepoint(<int>, <int>)</span> |
|
|
|
<bool> = <Rect>.colliderect(<Rect>) |
|
|
|
index = <Rect>.collidelist(<list_of_Rect>) <span class="hljs-comment"># Returns index of first coliding Rect or -1.</span> |
|
|
|
indices = <Rect>.collidelistall(<list_of_Rect>) <span class="hljs-comment"># Returns indices of all colinding Rects.</span> |
|
|
|
(key, value) = <Rect>.collidedict(<dict_of_Rect>) |
|
|
|
[(key, value), ...] = <Rect>.collidedictall(<dict_of_Rect>) |
|
|
|
</code></pre> |
|
|
|
<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> |
|
|
|
<Surface> = pg.Surface((width, height)) <span class="hljs-comment"># Creates a new surface.</span> |
|
|
@ -2521,23 +2515,22 @@ indices = <Rect>.collidelistall(<list_of_Rect>) <span class="hljs-c |
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><Surface>.set_at((x, y), <color>) <span class="hljs-comment"># Updates pixel.</span> |
|
|
|
<Surface>.fill(<color>) <span class="hljs-comment"># Fills the whole surface.</span> |
|
|
|
<Surface>.blit(<Surface>, (x, y)/<Rect>) <span class="hljs-comment"># Draws passed surface to the surface.</span> |
|
|
|
<Surface>.blit(<Surface>, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span> |
|
|
|
<Surface> = <Surface>.subsurface(<Rect>) <span class="hljs-comment"># Returns subsurface.</span> |
|
|
|
</code></pre> |
|
|
|
<pre><code class="python language-python hljs"><Surface> = pg.transform.flip(<Surface>, xbool, ybool) |
|
|
|
<Surface> = pg.transform.rotate(<Surface>, angle) |
|
|
|
<Surface> = pg.transform.scale(<Surface>, (width, height)) |
|
|
|
</code></pre> |
|
|
|
<div><h4 id="drawing-1">Drawing:</h4><pre><code class="python language-python hljs">pg.draw.rect(<Surface>, color, <Rect>) |
|
|
|
<pre><code class="python language-python hljs">pg.draw.rect(<Surface>, color, <Rect>) |
|
|
|
pg.draw.polygon(<Surface>, color, points) |
|
|
|
pg.draw.circle(<Surface>, color, center, radius) |
|
|
|
pg.draw.ellipse(<Surface>, color, <Rect>) |
|
|
|
pg.draw.arc(<Surface>, color, <Rect>, start_angle, stop_angle) |
|
|
|
pg.draw.line(<Surface>, color, start_pos, end_pos, width) |
|
|
|
pg.draw.lines(<Surface>, color, points) |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<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>) |
|
|
|
</code></pre> |
|
|
|
<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>) |
|
|
|
<Font> = pg.font.Font(<span class="hljs-string">'<path>'</span>, size) |
|
|
|
<Surface> = <Font>.render(text, antialias, color, background=<span class="hljs-keyword">None</span>) |
|
|
|
</code></pre></div> |
|
|
|