@ -54,7 +54,7 @@
< body >
< header >
< aside > April 2 , 2023< / aside >
< aside > April 3 , 2023< / aside >
< a href = "https://gto76.github.io" rel = "author" > Jure Šorn< / a >
< / header >
@ -1143,14 +1143,14 @@ Hello World!
< / code > < / pre > < / div >
< pre > < code class = "python language-python hljs" > < span class = "hljs-class" > < span class = "hljs-keyword" > class< / span > < < span class = "hljs-title" > enum_name< / span > > < span class = "hljs-params" > (Enum)< / span > :< / span >
< member_name_1> = < value_1>
< member_name_2 > = < value_2_a> , < value_2_b >
< member_name_3> = auto()
< member_name> = auto()
< member_name> = < value>
< member_name> = < value> , < value>
< / code > < / pre >
< ul >
< li > < strong > If there are no numeric values before auto(), it returns 1.< / strong > < / li >
< li > < strong > Otherwise it returns an increment of the last numeric value.< / strong > < / li >
< li > < strong > Function auto() returns an increment of the last numeric value or 1.< / strong > < / li >
< li > < strong > Accessing a member named after a reserved keyword causes SyntaxError.< / strong > < / li >
< li > < strong > Methods receive the member they were called on as the 'self' argument.< / strong > < / li >
< / ul >
< pre > < code class = "python language-python hljs" > < member> = < enum> .< member_name> < span class = "hljs-comment" > # Returns a member.< / span >
< member> = < enum> [< span class = "hljs-string" > '< member_name> '< / span > ] < span class = "hljs-comment" > # Returns a member. Raises KeyError.< / span >
@ -1164,7 +1164,7 @@ Hello World!
< member> = random.choice(list(< enum> )) < span class = "hljs-comment" > # Returns a random member.< / span >
< / code > < / pre >
< pre > < code class = "python language-python hljs" > < span class = "hljs-function" > < span class = "hljs-keyword" > def< / span > < span class = "hljs-title" > get_next_member< / span > < span class = "hljs-params" > (member)< / span > :< / span >
members = list(member.__class__ )
members = list(type(member) )
index = members.index(member) + < span class = "hljs-number" > 1< / span >
< span class = "hljs-keyword" > return< / span > members[index % len(members)]
< / code > < / pre >
@ -2252,7 +2252,7 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.6</
< div > < h2 id = "image" > < a href = "#image" name = "image" > #< / a > Image< / h2 > < pre > < code class = "python language-python hljs" > < span class = "hljs-comment" > # $ pip3 install pillow< / span >
< span class = "hljs-keyword" > from< / span > PIL < span class = "hljs-keyword" > import< / span > Image, ImageFilter, ImageEnhance, Image Draw
< span class = "hljs-keyword" > from< / span > PIL < span class = "hljs-keyword" > import< / span > Image, ImageDraw
< / code > < / pre > < / div >
< pre > < code class = "python language-python hljs" > < Image> = Image.new(< span class = "hljs-string" > '< mode> '< / span > , (width, height)) < span class = "hljs-comment" > # Also `color=< int/tuple/str> `.< / span >
@ -2267,8 +2267,7 @@ right = [[<span class="hljs-number">0.1</span>, <span class="hljs-number">0.6</
< Image> .putdata(< list/ImagingCore> ) < span class = "hljs-comment" > # Writes a flattened sequence of pixels.< / span >
< Image> .paste(< Image> , (x, y)) < span class = "hljs-comment" > # Writes passed image to the image.< / span >
< / code > < / pre >
< pre > < code class = "python language-python hljs" > < Image> = < Image> .resize((width, height)) < span class = "hljs-comment" > # Use < Image> .width/height for original sizes.< / span >
< Image> = < Image> .filter(< Filter> ) < span class = "hljs-comment" > # `< Filter> = ImageFilter.< name> ([< args> ])`< / span >
< pre > < code class = "python language-python hljs" > < Image> = < Image> .filter(< Filter> ) < span class = "hljs-comment" > # `< Filter> = ImageFilter.< name> ([< args> ])`< / span >
< Image> = < Enhance> .enhance(< float> ) < span class = "hljs-comment" > # `< Enhance> = ImageEnhance.< name> (< Image> )`< / span >
< / code > < / pre >
< pre > < code class = "python language-python hljs" > < array> = np.array(< Image> ) < span class = "hljs-comment" > # Creates NumPy array from the image.< / span >
@ -2305,6 +2304,7 @@ img.show()
< ImageDraw> .rectangle((x1, y1, x2, y2)) < span class = "hljs-comment" > # To rotate use Image's rotate() and paste().< / span >
< ImageDraw> .polygon((x1, y1, x2, y2, ...)) < span class = "hljs-comment" > # Last point gets connected to the first.< / span >
< ImageDraw> .ellipse((x1, y1, x2, y2)) < span class = "hljs-comment" > # To rotate use Image's rotate() and paste().< / span >
< ImageDraw> .text((x, y), text, font=< Font> ) < span class = "hljs-comment" > # `< Font> = ImageFont.truetype(< path> , size)`< / span >
< / code > < / pre > < / div >
< ul >
@ -2935,7 +2935,7 @@ $ pyinstaller script.py --add-data '<path>:.' <span class="hljs-comment">
< footer >
< aside > April 2 , 2023< / aside >
< aside > April 3 , 2023< / aside >
< a href = "https://gto76.github.io" rel = "author" > Jure Šorn< / a >
< / footer >