mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Tabs to spaces and add defensive brackets
This commit is contained in:
parent
07af06bf8c
commit
05aa252f9f
|
@ -64,15 +64,18 @@ ImagingFillLinearGradient(const char *mode)
|
|||
Imaging im;
|
||||
int y;
|
||||
|
||||
if (strlen(mode) != 1)
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
if (strlen(mode) != 1) {
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
}
|
||||
|
||||
im = ImagingNew(mode, 256, 256);
|
||||
if (!im)
|
||||
return NULL;
|
||||
if (!im) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (y = 0; y < 256; y++)
|
||||
memset(im->image8[y], (unsigned char) y, 256);
|
||||
for (y = 0; y < 256; y++) {
|
||||
memset(im->image8[y], (unsigned char) y, 256);
|
||||
}
|
||||
|
||||
return im;
|
||||
}
|
||||
|
@ -84,21 +87,25 @@ ImagingFillRadialGradient(const char *mode)
|
|||
int x, y;
|
||||
int d;
|
||||
|
||||
if (strlen(mode) != 1)
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
if (strlen(mode) != 1) {
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
}
|
||||
|
||||
im = ImagingNew(mode, 256, 256);
|
||||
if (!im)
|
||||
return NULL;
|
||||
if (!im) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (y = 0; y < 256; y++)
|
||||
for (x = 0; x < 256; x++) {
|
||||
d = (int) sqrt((double) ((x-128)*(x-128) + (y-128)*(y-128)) * 2.0);
|
||||
if (d >= 255)
|
||||
im->image8[y][x] = 255;
|
||||
else
|
||||
im->image8[y][x] = d;
|
||||
}
|
||||
for (y = 0; y < 256; y++) {
|
||||
for (x = 0; x < 256; x++) {
|
||||
d = (int) sqrt((double) ((x-128)*(x-128) + (y-128)*(y-128)) * 2.0);
|
||||
if (d >= 255) {
|
||||
im->image8[y][x] = 255;
|
||||
} else {
|
||||
im->image8[y][x] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return im;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user