@ -226,7 +226,7 @@ pre.prettyprint {
< body >
< body >
< header >
< header >
< aside > October 22 , 2021< / aside >
< aside > October 29 , 2021< / aside >
< a href = "https://gto76.github.io" rel = "author" > Jure Šorn< / a >
< a href = "https://gto76.github.io" rel = "author" > Jure Šorn< / a >
< / header >
< / header >
@ -2259,7 +2259,7 @@ Line # Mem usage Increment Line Contents
3 38.012 MiB 0.344 MiB a = [*range(10000)]
3 38.012 MiB 0.344 MiB a = [*range(10000)]
4 38.477 MiB 0.465 MiB b = {*range(10000)}
4 38.477 MiB 0.465 MiB b = {*range(10000)}
< / code > < / pre >
< / code > < / pre >
< div > < h3 id = "callgraph" > Call Graph< / h3 > < div > < h4 id = "generatesapngimageofa callgraphwithhighlightedbottlenecks" > Generates a PNG image of a call graph with highlighted bottlenecks:< / h4 > < pre > < code class = "python language-python hljs" > < span class = "hljs-comment" > # $ pip3 install pycallgraph2< / span >
< div > < h3 id = "callgraph" > Call Graph< / h3 > < div > < h4 id = "generatesapngimageofthe callgraphwithhighlightedbottlenecks" > Generates a PNG image of the call graph with highlighted bottlenecks:< / h4 > < pre > < code class = "python language-python hljs" > < span class = "hljs-comment" > # $ pip3 install pycallgraph2< / span >
< span class = "hljs-keyword" > from< / span > pycallgraph2 < span class = "hljs-keyword" > import< / span > output, PyCallGraph
< span class = "hljs-keyword" > from< / span > pycallgraph2 < span class = "hljs-keyword" > import< / span > output, PyCallGraph
< span class = "hljs-keyword" > from< / span > datetime < span class = "hljs-keyword" > import< / span > datetime
< span class = "hljs-keyword" > from< / span > datetime < span class = "hljs-keyword" > import< / span > datetime
filename = < span class = "hljs-string" > f'profile-< span class = "hljs-subst" > {datetime.now():%Y%m%d%H%M%S}< / span > .png'< / span >
filename = < span class = "hljs-string" > f'profile-< span class = "hljs-subst" > {datetime.now():%Y%m%d%H%M%S}< / span > .png'< / span >
@ -2368,8 +2368,8 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.6</s
< li > < strong > < code class = "python hljs" > < span class = "hljs-string" > 'RGBA'< / span > < / code > - 4x8-bit pixels, true color with transparency mask.< / strong > < / li >
< li > < strong > < code class = "python hljs" > < span class = "hljs-string" > 'RGBA'< / span > < / code > - 4x8-bit pixels, true color with transparency mask.< / strong > < / li >
< li > < strong > < code class = "python hljs" > < span class = "hljs-string" > 'HSV'< / span > < / code > - 3x8-bit pixels, Hue, Saturation, Value color space.< / strong > < / li >
< li > < strong > < code class = "python hljs" > < span class = "hljs-string" > 'HSV'< / span > < / code > - 3x8-bit pixels, Hue, Saturation, Value color space.< / strong > < / li >
< / ul > < div > < h3 id = "examples" > Examples< / h3 > < div > < h4 id = "createsapngimageofarainbowgradient" > Creates a PNG image of a rainbow gradient:< / h4 > < pre > < code class = "python language-python hljs" > WIDTH, HEIGHT = < span class = "hljs-number" > 100< / span > , < span class = "hljs-number" > 100< / span >
< / ul > < div > < h3 id = "examples" > Examples< / h3 > < div > < h4 id = "createsapngimageofarainbowgradient" > Creates a PNG image of a rainbow gradient:< / h4 > < pre > < code class = "python language-python hljs" > WIDTH, HEIGHT = < span class = "hljs-number" > 100< / span > , < span class = "hljs-number" > 100< / span >
size = WIDTH * HEIGHT
hues = (< span class = "hljs-number" > 255< / span > * i/size < span class = "hljs-keyword" > for< / span > i < span class = "hljs-keyword" > in< / span > range(size ))
n_pixels = WIDTH * HEIGHT
hues = (< span class = "hljs-number" > 255< / span > * i/n_pixels < span class = "hljs-keyword" > for< / span > i < span class = "hljs-keyword" > in< / span > range(n_pixels ))
img = Image.new(< span class = "hljs-string" > 'HSV'< / span > , (WIDTH, HEIGHT))
img = Image.new(< span class = "hljs-string" > 'HSV'< / span > , (WIDTH, HEIGHT))
img.putdata([(int(h), < span class = "hljs-number" > 255< / span > , < span class = "hljs-number" > 255< / span > ) < span class = "hljs-keyword" > for< / span > h < span class = "hljs-keyword" > in< / span > hues])
img.putdata([(int(h), < span class = "hljs-number" > 255< / span > , < span class = "hljs-number" > 255< / span > ) < span class = "hljs-keyword" > for< / span > h < span class = "hljs-keyword" > in< / span > hues])
img.convert(< span class = "hljs-string" > 'RGB'< / span > ).save(< span class = "hljs-string" > 'test.png'< / span > )
img.convert(< span class = "hljs-string" > 'RGB'< / span > ).save(< span class = "hljs-string" > 'test.png'< / span > )
@ -2639,13 +2639,13 @@ SIZE, MAX_SPEED = <span class="hljs-number">50</span>, P(<span class="hljs-numbe
y=< span class = "hljs-number" > 0< / span > < span class = "hljs-keyword" > if< / span > (D.n < span class = "hljs-keyword" > in< / span > bounds < span class = "hljs-keyword" > and< / span > spd.y < < span class = "hljs-number" > 0< / span > ) < span class = "hljs-keyword" > or< / span > (D.s < span class = "hljs-keyword" > in< / span > bounds < span class = "hljs-keyword" > and< / span > spd.y > < span class = "hljs-number" > 0< / span > ) < span class = "hljs-keyword" > else< / span > spd.y)
y=< span class = "hljs-number" > 0< / span > < span class = "hljs-keyword" > if< / span > (D.n < span class = "hljs-keyword" > in< / span > bounds < span class = "hljs-keyword" > and< / span > spd.y < < span class = "hljs-number" > 0< / span > ) < span class = "hljs-keyword" > or< / span > (D.s < span class = "hljs-keyword" > in< / span > bounds < span class = "hljs-keyword" > and< / span > spd.y > < span class = "hljs-number" > 0< / span > ) < span class = "hljs-keyword" > else< / span > spd.y)
< span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > draw< / span > < span class = "hljs-params" > (screen, images, mario, tiles, pressed)< / span > :< / span >
< span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > draw< / span > < span class = "hljs-params" > (screen, images, mario, tiles, pressed)< / span > :< / span >
< span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > get_fram e_index< / span > < span class = "hljs-params" > ()< / span > :< / span >
< span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > get_marios_imag e_index< / span > < span class = "hljs-params" > ()< / span > :< / span >
< span class = "hljs-keyword" > if< / span > D.s < span class = "hljs-keyword" > not< / span > < span class = "hljs-keyword" > in< / span > get_boundaries(mario.rect, tiles):
< span class = "hljs-keyword" > if< / span > D.s < span class = "hljs-keyword" > not< / span > < span class = "hljs-keyword" > in< / span > get_boundaries(mario.rect, tiles):
< span class = "hljs-keyword" > return< / span > < span class = "hljs-number" > 4< / span >
< span class = "hljs-keyword" > return< / span > < span class = "hljs-number" > 4< / span >
< span class = "hljs-keyword" > return< / span > next(mario.frame_cycle) < span class = "hljs-keyword" > if< / span > {D.w, D.e} & pressed < span class = "hljs-keyword" > else< / span > < span class = "hljs-number" > 6< / span >
< span class = "hljs-keyword" > return< / span > next(mario.frame_cycle) < span class = "hljs-keyword" > if< / span > {D.w, D.e} & pressed < span class = "hljs-keyword" > else< / span > < span class = "hljs-number" > 6< / span >
screen.fill((< span class = "hljs-number" > 85< / span > , < span class = "hljs-number" > 168< / span > , < span class = "hljs-number" > 255< / span > ))
screen.fill((< span class = "hljs-number" > 85< / span > , < span class = "hljs-number" > 168< / span > , < span class = "hljs-number" > 255< / span > ))
mario.facing_left = (D.w < span class = "hljs-keyword" > in< / span > pressed) < span class = "hljs-keyword" > if< / span > {D.w, D.e} & pressed < span class = "hljs-keyword" > else< / span > mario.facing_left
mario.facing_left = (D.w < span class = "hljs-keyword" > in< / span > pressed) < span class = "hljs-keyword" > if< / span > {D.w, D.e} & pressed < span class = "hljs-keyword" > else< / span > mario.facing_left
screen.blit(images[get_fram e_index() + mario.facing_left * < span class = "hljs-number" > 9< / span > ], mario.rect)
screen.blit(images[get_marios_imag e_index() + mario.facing_left * < span class = "hljs-number" > 9< / span > ], mario.rect)
< span class = "hljs-keyword" > for< / span > rect < span class = "hljs-keyword" > in< / span > tiles:
< span class = "hljs-keyword" > for< / span > rect < span class = "hljs-keyword" > in< / span > tiles:
screen.blit(images[< span class = "hljs-number" > 18< / span > < span class = "hljs-keyword" > if< / span > {*rect.topleft} & {< span class = "hljs-number" > 0< / span > , (SIZE< span class = "hljs-number" > -1< / span > )*< span class = "hljs-number" > 16< / span > } < span class = "hljs-keyword" > else< / span > < span class = "hljs-number" > 19< / span > ], rect)
screen.blit(images[< span class = "hljs-number" > 18< / span > < span class = "hljs-keyword" > if< / span > {*rect.topleft} & {< span class = "hljs-number" > 0< / span > , (SIZE< span class = "hljs-number" > -1< / span > )*< span class = "hljs-number" > 16< / span > } < span class = "hljs-keyword" > else< / span > < span class = "hljs-number" > 19< / span > ], rect)
pg.display.flip()
pg.display.flip()
@ -2894,7 +2894,7 @@ line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-string">
< div > < h4 id = "confirmedcovidcasesdowjonesgoldandbitcoinprice" > Confirmed covid cases, Dow Jones, g old, and Bitcoin price:< / h4 > < p > < / p > < div id = "e23ccacc-a456-478b-b467-7282a2165921" class = "plotly-graph-div" style = "height:315px; width:100%;" > < / div > < pre > < code class = "python language-python hljs" > < span class = "hljs-keyword" > import< / span > pandas < span class = "hljs-keyword" > as< / span > pd
< div > < h4 id = "confirmedcovidcasesdowjonesgoldandbitcoinprice" > Confirmed covid cases, Dow Jones, G old, and Bitcoin price:< / h4 > < p > < / p > < div id = "e23ccacc-a456-478b-b467-7282a2165921" class = "plotly-graph-div" style = "height:315px; width:100%;" > < / div > < pre > < code class = "python language-python hljs" > < span class = "hljs-keyword" > import< / span > pandas < span class = "hljs-keyword" > as< / span > pd
< span class = "hljs-keyword" > import< / span > plotly.graph_objects < span class = "hljs-keyword" > as< / span > go
< span class = "hljs-keyword" > import< / span > plotly.graph_objects < span class = "hljs-keyword" > as< / span > go
< span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > main< / span > < span class = "hljs-params" > ()< / span > :< / span >
< span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > main< / span > < span class = "hljs-params" > ()< / span > :< / span >
@ -3017,7 +3017,7 @@ $ pyinstaller script.py --add-data '<path>:.' <span class="hljs-comment">
< footer >
< footer >
< aside > October 22 , 2021< / aside >
< aside > October 29 , 2021< / aside >
< a href = "https://gto76.github.io" rel = "author" > Jure Šorn< / a >
< a href = "https://gto76.github.io" rel = "author" > Jure Šorn< / a >
< / footer >
< / footer >