diff --git a/README.md b/README.md index 0e28b76..0afd119 100644 --- a/README.md +++ b/README.md @@ -1683,107 +1683,6 @@ def get_border(screen): ``` -Image ------ -```python -# $ pip3 install pillow -from PIL import Image -``` - -#### Creates PNG image of rainbow gradient: -```python -width = 100 -height = 100 -size = width * height -pixels = [255 * i/size for i in range(size)] - -img = Image.new('HSV', (width, height)) -img.putdata([(int(a), 255, 255) for a in pixels]) -img.convert(mode='RGB').save('test.png') -``` - -#### Adds noise to PNG image: -```python -from random import randint -add_noise = lambda value: max(0, min(255, value + randint(-20, 20))) -img = Image.open('test.png').convert(mode='HSV') -img.putdata([(add_noise(h), s, v) for h, s, v in img.getdata()]) -img.convert(mode='RGB').save('test.png') -``` - -### Modes -* **`'1'` - 1-bit pixels, black and white, stored with one pixel per byte.** -* **`'L'` - 8-bit pixels, greyscale.** -* **`'RGB'` - 3x8-bit pixels, true color.** -* **`'RGBA'` - 4x8-bit pixels, true color with transparency mask.** -* **`'HSV'` - 3x8-bit pixels, Hue, Saturation, Value color space.** - - -Audio ------ -```python -import wave -from struct import pack, iter_unpack -``` - -### Read Frames from WAV File -```python -def read_wav_file(filename): - with wave.open(filename, 'rb') as wf: - frames = wf.readframes(wf.getnframes()) - return [a[0] for a in iter_unpack(' 2 else 0.125) -get_note = lambda note: get_wave(*parse_n(note)) if note else get_pause(0.125) -frames_i = chain.from_iterable(get_note(n) for n in f'{P1}{P1}{P2}'.split(',')) -frames_b = b''.join(struct.pack(' 2 else 0.125) +get_note = lambda note: get_wave(*parse_n(note)) if note else get_pause(0.125) +frames_i = chain.from_iterable(get_note(n) for n in f'{P1}{P1}{P2}'.split(',')) +frames_b = b''.join(struct.pack('