54
54
55
55
< body >
56
56
< header >
57
- < aside > April 2 , 2023</ aside >
57
+ < aside > April 3 , 2023</ aside >
58
58
< a href ="https://gto76.github.io " rel ="author "> Jure Šorn</ a >
59
59
</ header >
60
60
1143
1143
</ code > </ pre > </ div >
1144
1144
1145
1145
< 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 >
1146
- <member_name_1 > = <value_1>
1147
- <member_name_2 > = <value_2_a>, <value_2_b >
1148
- <member_name_3 > = auto()
1146
+ <member_name > = auto()
1147
+ <member_name > = <value >
1148
+ <member_name > = <value>, <value>
1149
1149
</ code > </ pre >
1150
1150
< ul >
1151
- < li > < strong > If there are no numeric values before auto(), it returns 1.</ strong > </ li >
1152
- < li > < strong > Otherwise it returns an increment of the last numeric value.</ strong > </ li >
1151
+ < li > < strong > Function auto() returns an increment of the last numeric value or 1.</ strong > </ li >
1153
1152
< li > < strong > Accessing a member named after a reserved keyword causes SyntaxError.</ strong > </ li >
1153
+ < li > < strong > Methods receive the member they were called on as the 'self' argument.</ strong > </ li >
1154
1154
</ ul >
1155
1155
< pre > < code class ="python language-python hljs "> <member> = <enum>.<member_name> < span class ="hljs-comment "> # Returns a member.</ span >
1156
1156
<member> = <enum>[< span class ="hljs-string "> '<member_name>'</ span > ] < span class ="hljs-comment "> # Returns a member. Raises KeyError.</ span >
1164
1164
<member> = random.choice(list(<enum>)) < span class ="hljs-comment "> # Returns a random member.</ span >
1165
1165
</ code > </ pre >
1166
1166
< 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 >
1167
- members = list(member.__class__ )
1167
+ members = list(type( member) )
1168
1168
index = members.index(member) + < span class ="hljs-number "> 1</ span >
1169
1169
< span class ="hljs-keyword "> return</ span > members[index % len(members)]
1170
1170
</ code > </ pre >
@@ -2252,7 +2252,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
2252
2252
2253
2253
2254
2254
< 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 >
2255
- < span class ="hljs-keyword "> from</ span > PIL < span class ="hljs-keyword "> import</ span > Image, ImageFilter, ImageEnhance, ImageDraw
2255
+ < span class ="hljs-keyword "> from</ span > PIL < span class ="hljs-keyword "> import</ span > Image, ImageDraw
2256
2256
</ code > </ pre > </ div >
2257
2257
2258
2258
< 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 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
2267
2267
<Image>.putdata(<list/ImagingCore>) < span class ="hljs-comment "> # Writes a flattened sequence of pixels.</ span >
2268
2268
<Image>.paste(<Image>, (x, y)) < span class ="hljs-comment "> # Writes passed image to the image.</ span >
2269
2269
</ code > </ pre >
2270
- < pre > < code class ="python language-python hljs "> <Image> = <Image>.resize((width, height)) < span class ="hljs-comment "> # Use <Image>.width/height for original sizes.</ span >
2271
- <Image> = <Image>.filter(<Filter>) < span class ="hljs-comment "> # `<Filter> = ImageFilter.<name>([<args>])`</ span >
2270
+ < pre > < code class ="python language-python hljs "> <Image> = <Image>.filter(<Filter>) < span class ="hljs-comment "> # `<Filter> = ImageFilter.<name>([<args>])`</ span >
2272
2271
<Image> = <Enhance>.enhance(<float>) < span class ="hljs-comment "> # `<Enhance> = ImageEnhance.<name>(<Image>)`</ span >
2273
2272
</ code > </ pre >
2274
2273
< 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 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
2305
2304
<ImageDraw>.rectangle((x1, y1, x2, y2)) < span class ="hljs-comment "> # To rotate use Image's rotate() and paste().</ span >
2306
2305
<ImageDraw>.polygon((x1, y1, x2, y2, ...)) < span class ="hljs-comment "> # Last point gets connected to the first.</ span >
2307
2306
<ImageDraw>.ellipse((x1, y1, x2, y2)) < span class ="hljs-comment "> # To rotate use Image's rotate() and paste().</ span >
2307
+ <ImageDraw>.text((x, y), text, font=<Font>) < span class ="hljs-comment "> # `<Font> = ImageFont.truetype(<path>, size)`</ span >
2308
2308
</ code > </ pre > </ div >
2309
2309
2310
2310
< ul >
@@ -2935,7 +2935,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
2935
2935
2936
2936
2937
2937
< footer >
2938
- < aside > April 2 , 2023</ aside >
2938
+ < aside > April 3 , 2023</ aside >
2939
2939
< a href ="https://gto76.github.io " rel ="author "> Jure Šorn</ a >
2940
2940
</ footer >
2941
2941
0 commit comments