mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
Add access functions for ImagingEffectMandelbrot with a test
This commit is contained in:
parent
76ef83263b
commit
8c96d38ce9
14
PIL/Image.py
14
PIL/Image.py
|
@ -2424,9 +2424,21 @@ def _showxv(image, title=None, **options):
|
|||
# --------------------------------------------------------------------
|
||||
# Effects
|
||||
|
||||
def effect_mandelbrot(size, extent, quality):
|
||||
"""
|
||||
Generate a Mandelbrot set covering the given extent.
|
||||
|
||||
:param size: The requested size in pixels, as a 2-tuple:
|
||||
(width, height).
|
||||
:param extent: The extent to cover, as a 4-tuple:
|
||||
(x0, y0, x1, y2).
|
||||
:param quality: Quality.
|
||||
"""
|
||||
return Image()._new(core.effect_mandelbrot(size, extent, quality))
|
||||
|
||||
def effect_noise(size, sigma):
|
||||
"""
|
||||
Generate Gaussian noise centered around 128
|
||||
Generate Gaussian noise centered around 128.
|
||||
|
||||
:param size: The requested size in pixels, as a 2-tuple:
|
||||
(width, height).
|
||||
|
|
BIN
Tests/images/mandelbrot.png
Normal file
BIN
Tests/images/mandelbrot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -141,6 +141,20 @@ class TestImage(PillowTestCase):
|
|||
img_colors = sorted(img.getcolors())
|
||||
self.assertEqual(img_colors, expected_colors)
|
||||
|
||||
def test_effect_mandelbrot(self):
|
||||
# Arrange
|
||||
size = (512, 512)
|
||||
extent = (-3, -2.5, 2, 2.5)
|
||||
quality = 100
|
||||
|
||||
# Act
|
||||
im = Image.effect_mandelbrot(size, extent, quality)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(im.size, (512, 512))
|
||||
im2 = Image.open('Tests/images/mandelbrot.png')
|
||||
self.assert_image_equal(im, im2)
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith('win32'),
|
||||
"Stalls on Travis CI, passes on Windows")
|
||||
def test_effect_noise(self):
|
||||
|
@ -156,7 +170,6 @@ class TestImage(PillowTestCase):
|
|||
self.assertEqual(im.getpixel((0, 0)), 60)
|
||||
self.assertEqual(im.getpixel((0, 1)), 28)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user