From a0c7e2205286266a2e15255c7b7b0b110ad9fd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 21 Aug 2019 16:18:22 +0200 Subject: [PATCH] TOC --- README.md | 45 +++++++++++++++++++++++---------------------- index.html | 52 ++++++++++++++++++++++++++-------------------------- parse.js | 2 +- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 23b39ae..ddb1c2f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Contents **   ** **5. Data:** **             ** **[`CSV`](#csv)**__,__ **[`JSON`](#json)**__,__ **[`Pickle`](#pickle)**__,__ **[`SQLite`](#sqlite)**__,__ **[`Bytes`](#bytes)**__,__ **[`Struct`](#struct)**__,__ **[`Array`](#array)**__,__ **[`MemoryView`](#memory-view)**__,__ **[`Deque`](#deque)**__.__ **   ** **6. Advanced:** **   ** **[`Threading`](#threading)**__,__ **[`Operator`](#operator)**__,__ **[`Introspection`](#introspection)**__,__ **[`Metaprograming`](#metaprograming)**__,__ **[`Eval`](#eval)**__,__ **[`Coroutine`](#coroutine)**__.__ **   ** **7. Libraries:** **      ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profile)**__,__ -**                                 ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__.__ +**                                 ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Animation`](#animation)**__,__ **[`Audio`](#audio)**__,__ **[`Synthesizer `](#synthesizer)**__.__ Main @@ -2573,11 +2573,11 @@ from PIL import Image ``` ```python - = img.getpixel((x, y)) # Returns a pixel. -.putpixel((x, y), ) # Writes tuple/int to image. - = .getdata() # Returns a sequence of tuples/ints. -.putdata() # Writes a sequence of tuples/ints. -.paste(, (x, y)) # Writes an image to image. + = img.getpixel((x, y)) # Returns a pixel. +.putpixel((x, y), ) # Writes a pixel to image. + = .getdata() # Returns a sequence of pixels. +.putdata() # Writes a sequence of pixels. +.paste(, (x, y)) # Writes an image to image. ``` ### Modes @@ -2587,21 +2587,6 @@ from PIL import Image * **`'RGBA'` - 4x8-bit pixels, true color with transparency mask.** * **`'HSV'` - 3x8-bit pixels, Hue, Saturation, Value color space.** -### ImageDraw -```python -from PIL import ImageDraw - = ImageDraw.Draw() -.point((x, y), fill=None) -.line((x1, y1, x2, y2 [, ...]), fill=None, width=0, joint=None) -.arc((x1, y1, x2, y2), from_deg, to_deg, fill=None, width=0) -.rectangle((x1, y1, x2, y2), fill=None, outline=None, width=0) -.polygon((x1, y1, x2, y2 [, ...]), fill=None, outline=None) -.ellipse((x1, y1, x2, y2), fill=None, outline=None, width=0) -``` -* **Use `'fill='` to set the primary color.** -* **Use `'outline='` to set the secondary color.** -* **Colors can be specified as tuple, int, `'#rrggbb'` string or a color name.** - ### Examples #### Creates a PNG image of a rainbow gradient: ```python @@ -2622,11 +2607,27 @@ img.putdata([(add_noise(h), s, v) for h, s, v in img.getdata()]) img.convert(mode='RGB').save('test.png') ``` +### ImageDraw +```python +from PIL import ImageDraw + = ImageDraw.Draw() +.point((x, y), fill=None) +.line((x1, y1, x2, y2 [, ...]), fill=None, width=0, joint=None) +.arc((x1, y1, x2, y2), from_deg, to_deg, fill=None, width=0) +.rectangle((x1, y1, x2, y2), fill=None, outline=None, width=0) +.polygon((x1, y1, x2, y2 [, ...]), fill=None, outline=None) +.ellipse((x1, y1, x2, y2), fill=None, outline=None, width=0) +``` +* **Use `'fill='` to set the primary color.** +* **Use `'outline='` to set the secondary color.** +* **Colors can be specified as tuple, int, `'#rrggbb'` string or a color name.** + + Animation --------- #### Creates a GIF of a bouncing ball: ```python -# $ pip3 install imageio +# $ pip3 install pillow imageio from PIL import Image, ImageDraw import imageio WIDTH, R = 126, 10 diff --git a/index.html b/index.html index e7bf275..de6d5c1 100644 --- a/index.html +++ b/index.html @@ -217,7 +217,7 @@ pre.prettyprint { '5. Data': [CSV, JSON, Pickle, SQLite, Bytes, Struct, Array, MemoryView, Deque], '6. Advanced': [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine], '7. Libraries': [Progress_Bar, Plot, Table, Curses, Logging, Scraping, Web, Profile, - NumPy, Image, Audio] + NumPy, Image, Animation, Audio, Synthesizer] } @@ -2189,11 +2189,11 @@ right = [[0.1, 0.6'<path>') <Image>.show() -
<tuple/int> = img.getpixel((x, y))        # Returns a pixel.
-<Image>.putpixel((x, y), <tuple/int>)     # Writes tuple/int to image.
-<ImagingCore> = <Image>.getdata()         # Returns a sequence of tuples/ints.
-<Image>.putdata(<list/tuple>)             # Writes a sequence of tuples/ints.
-<Image>.paste(<Image>, (x, y))            # Writes an image to image.
+
<tuple/int> = img.getpixel((x, y))              # Returns a pixel.
+<Image>.putpixel((x, y), <tuple/int>)           # Writes a pixel to image.
+<ImagingCore> = <Image>.getdata()               # Returns a sequence of pixels.
+<Image>.putdata(<list/tuple>)                   # Writes a sequence of pixels.
+<Image>.paste(<Image>, (x, y))                  # Writes an image to image.
 

Modes

  • '1' - 1-bit pixels, black and white, stored with one pixel per byte.
  • @@ -2201,30 +2201,15 @@ right = [[0.1, 0.6'RGB' - 3x8-bit pixels, true color.
  • 'RGBA' - 4x8-bit pixels, true color with transparency mask.
  • 'HSV' - 3x8-bit pixels, Hue, Saturation, Value color space.
  • -

ImageDraw

from PIL import ImageDraw
-<ImageDraw> = ImageDraw.Draw(<Image>)
-<ImageDraw>.point((x, y), fill=None)
-<ImageDraw>.line((x1, y1, x2, y2 [, ...]), fill=None, width=0, joint=None) 
-<ImageDraw>.arc((x1, y1, x2, y2), from_deg, to_deg, fill=None, width=0)
-<ImageDraw>.rectangle((x1, y1, x2, y2), fill=None, outline=None, width=0)
-<ImageDraw>.polygon((x1, y1, x2, y2 [, ...]), fill=None, outline=None)
-<ImageDraw>.ellipse((x1, y1, x2, y2), fill=None, outline=None, width=0)
-
- - - -
    -
  • Use 'fill=<color>' to set the primary color.
  • -
  • Use 'outline=<color>' to set the secondary color.
  • -
  • Colors can be specified as tuple, int, '#rrggbb' string or a color name.
  • -
-

Examples

Creates a PNG image of a rainbow gradient:

WIDTH, HEIGHT = 100, 100
+

Examples

Creates a PNG image of a rainbow gradient:

WIDTH, HEIGHT = 100, 100
 size = WIDTH * HEIGHT
 hue = [255 * i/size for i in range(size)]
 img = Image.new('HSV', (WIDTH, HEIGHT))
 img.putdata([(int(h), 255, 255) for h in hue])
 img.convert(mode='RGB').save('test.png')
-
+
+ +

Adds noise to a PNG image:

from random import randint
@@ -2234,7 +2219,22 @@ img.putdata([(add_noise(h), s, v) for h, s, v
 img.convert(mode='RGB').save('test.png')
 
-

#Animation

Creates a GIF of a bouncing ball:

# $ pip3 install imageio
+

ImageDraw

from PIL import ImageDraw
+<ImageDraw> = ImageDraw.Draw(<Image>)
+<ImageDraw>.point((x, y), fill=None)
+<ImageDraw>.line((x1, y1, x2, y2 [, ...]), fill=None, width=0, joint=None) 
+<ImageDraw>.arc((x1, y1, x2, y2), from_deg, to_deg, fill=None, width=0)
+<ImageDraw>.rectangle((x1, y1, x2, y2), fill=None, outline=None, width=0)
+<ImageDraw>.polygon((x1, y1, x2, y2 [, ...]), fill=None, outline=None)
+<ImageDraw>.ellipse((x1, y1, x2, y2), fill=None, outline=None, width=0)
+
+ +
    +
  • Use 'fill=<color>' to set the primary color.
  • +
  • Use 'outline=<color>' to set the secondary color.
  • +
  • Colors can be specified as tuple, int, '#rrggbb' string or a color name.
  • +
+

#Animation

Creates a GIF of a bouncing ball:

# $ pip3 install pillow imageio
 from PIL import Image, ImageDraw
 import imageio
 WIDTH, R = 126, 10
diff --git a/parse.js b/parse.js
index 209c7b8..8b546b1 100755
--- a/parse.js
+++ b/parse.js
@@ -26,7 +26,7 @@ const TOC =
   '    \'5. Data\':        [CSV, JSON, Pickle, SQLite, Bytes, Struct, Array, MemoryView, Deque],\n' +
   '    \'6. Advanced\':    [Threading, Operator, Introspection, Metaprograming, Eval, Coroutine],\n' +
   '    \'7. Libraries\':   [Progress_Bar, Plot, Table, Curses, Logging, Scraping, Web, Profile,\n' +
-  '                       NumPy, Image, Audio]\n' +
+  '                       NumPy, Image, Animation, Audio, Synthesizer]\n' +
   '}\n' +
   '
\n';