mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-30 01:43:17 +03:00
flake8
This commit is contained in:
parent
6b5871a484
commit
08499d3547
|
@ -24,6 +24,7 @@ from PIL._binary import o8
|
|||
|
||||
EPSILON = 1e-10
|
||||
|
||||
|
||||
def linear(middle, pos):
|
||||
if pos <= middle:
|
||||
if middle < EPSILON:
|
||||
|
@ -38,20 +39,25 @@ def linear(middle, pos):
|
|||
else:
|
||||
return 0.5 + 0.5 * pos / middle
|
||||
|
||||
|
||||
def curved(middle, pos):
|
||||
return pos ** (log(0.5) / log(max(middle, EPSILON)))
|
||||
|
||||
|
||||
def sine(middle, pos):
|
||||
return (sin((-pi / 2.0) + pi * linear(middle, pos)) + 1.0) / 2.0
|
||||
|
||||
|
||||
def sphere_increasing(middle, pos):
|
||||
return sqrt(1.0 - (linear(middle, pos) - 1.0) ** 2)
|
||||
|
||||
|
||||
def sphere_decreasing(middle, pos):
|
||||
return 1.0 - sqrt(1.0 - linear(middle, pos) ** 2)
|
||||
|
||||
SEGMENTS = [linear, curved, sine, sphere_increasing, sphere_decreasing]
|
||||
|
||||
|
||||
class GradientFile:
|
||||
|
||||
gradient = None
|
||||
|
@ -89,6 +95,7 @@ class GradientFile:
|
|||
|
||||
return b"".join(palette), "RGBA"
|
||||
|
||||
|
||||
##
|
||||
# File handler for GIMP's gradient format.
|
||||
|
||||
|
|
|
@ -95,7 +95,6 @@ class TestImage(PillowTestCase):
|
|||
self.assertEqual(len(palette[0]), 1024)
|
||||
self.assertEqual(palette[1], "RGBA")
|
||||
|
||||
|
||||
def test_load_1_3_via_imagepalette(self):
|
||||
# Arrange
|
||||
from PIL import ImagePalette
|
||||
|
|
Loading…
Reference in New Issue
Block a user