You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>> </span>[l+r <spanclass="hljs-keyword">for</span> l <spanclass="hljs-keyword">in</span><spanclass="hljs-string">'abc'</span><spanclass="hljs-keyword">for</span> r <spanclass="hljs-keyword">in</span><spanclass="hljs-string">'abc'</span>]
<div><h3id="anyall">Any, All</h3><pre><codeclass="python language-python hljs"><bool> = any(<collection>) <spanclass="hljs-comment"># Is `bool(<el>)` True for any element.</span>
672
671
<bool> = all(<collection>) <spanclass="hljs-comment"># Is True for all elements or empty.</span>
<pre><codeclass="bash hljs"><2d_bools> = <2d_array> ><== <el/1d/2d_array> <spanclass="hljs-comment"># 1d_array must have size of a row.</span>
2205
2204
<1d/2d_a> = <2d_array>[<2d/1d_bools>] <spanclass="hljs-comment"># 1d_bools must have size of a column.</span>
<Image> = Image.open(<path>) <spanclass="hljs-comment"># Identifies format based on file contents.</span>
2260
2259
<Image> = <Image>.convert(<spanclass="hljs-string">'<mode>'</span>) <spanclass="hljs-comment"># Converts image to the new mode.</span>
2261
2260
<Image>.save(<path>) <spanclass="hljs-comment"># Selects format based on the path extension.</span>
2262
-
<Image>.show() <spanclass="hljs-comment"># Opens image in default preview app.</span>
2261
+
<Image>.show() <spanclass="hljs-comment"># Opens image in the default preview app.</span>
2263
2262
</code></pre>
2264
2263
<pre><codeclass="python language-python hljs"><int/tuple> = <Image>.getpixel((x, y)) <spanclass="hljs-comment"># Returns a pixel.</span>
2265
2264
<Image>.putpixel((x, y), <int/tuple>) <spanclass="hljs-comment"># Writes a pixel to the image.</span>
<div><h3id="surface">Surface</h3><p><strong>Object for representing images.</strong></p><pre><codeclass="python language-python hljs"><Surf> = pg.display.set_mode((width, height)) <spanclass="hljs-comment"># Opens new window and returns its surface.</span>
2465
2464
<Surf> = pg.Surface((width, height)) <spanclass="hljs-comment"># New RGB surface. RGBA if `flags=pg.SRCALPHA`.</span>
2466
-
<Surf> = pg.image.load(<spanclass="hljs-string">'<path>'</span>) <spanclass="hljs-comment"># Loads the image. Format depends on source.</span>
2465
+
<Surf> = pg.image.load(<path/file>) <spanclass="hljs-comment"># Loads the image. Format depends on source.</span>
2466
+
<Surf> = pg.surfarray.make_surface(<np_array>) <spanclass="hljs-comment"># Also `<array> = surfarray.pixels3d(<Surf>)`.</span>
2467
2467
<Surf> = <Surf>.subsurface(<Rect>) <spanclass="hljs-comment"># Returns a subsurface.</span>
rect(<Surf>, color, <Rect>, width=<spanclass="hljs-number">0</span>) <spanclass="hljs-comment"># Also polygon(<Surf>, color, points, width=0).</span>
2484
2484
</code></pre>
2485
-
<div><h3id="font">Font</h3><pre><codeclass="python language-python hljs"><Font> = pg.font.SysFont(<spanclass="hljs-string">'<name>'</span>, size) <spanclass="hljs-comment"># Loads the system font or default if missing.</span>
2486
-
<Font> = pg.font.Font(<spanclass="hljs-string">'<path>'</span>, size) <spanclass="hljs-comment"># Loads the TTF file. Pass None for default.</span>
2485
+
<div><h3id="font">Font</h3><pre><codeclass="python language-python hljs"><Font> = pg.font.Font(<path/file>, size) <spanclass="hljs-comment"># Loads the TTF file. Pass None for default.</span>
2487
2486
<Surf> = <Font>.render(text, antialias, color) <spanclass="hljs-comment"># Background color can be specified at the end.</span>
2488
2487
</code></pre></div>
2489
2488
2490
-
<div><h3id="sound">Sound</h3><pre><codeclass="python language-python hljs"><Sound> = pg.mixer.Sound(<spanclass="hljs-string">'<path>'</span>) <spanclass="hljs-comment"># Loads the WAV file.</span>
2489
+
<div><h3id="sound">Sound</h3><pre><codeclass="python language-python hljs"><Sound> = pg.mixer.Sound(<path/file/bytes>) <spanclass="hljs-comment"># Loads the WAV file or array of signed shorts.</span>
2491
2490
<Sound>.play() <spanclass="hljs-comment"># Starts playing the sound.</span>
<pre><codeclass="python language-python hljs"><Sr> = <Sr> ><== <el/Sr> <spanclass="hljs-comment"># Returns a Series of bools.</span>
0 commit comments