mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +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;
|
Imaging im;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
if (strlen(mode) != 1)
|
if (strlen(mode) != 1) {
|
||||||
return (Imaging) ImagingError_ModeError();
|
return (Imaging) ImagingError_ModeError();
|
||||||
|
}
|
||||||
|
|
||||||
im = ImagingNew(mode, 256, 256);
|
im = ImagingNew(mode, 256, 256);
|
||||||
if (!im)
|
if (!im) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (y = 0; y < 256; y++)
|
for (y = 0; y < 256; y++) {
|
||||||
memset(im->image8[y], (unsigned char) y, 256);
|
memset(im->image8[y], (unsigned char) y, 256);
|
||||||
|
}
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
@ -84,21 +87,25 @@ ImagingFillRadialGradient(const char *mode)
|
||||||
int x, y;
|
int x, y;
|
||||||
int d;
|
int d;
|
||||||
|
|
||||||
if (strlen(mode) != 1)
|
if (strlen(mode) != 1) {
|
||||||
return (Imaging) ImagingError_ModeError();
|
return (Imaging) ImagingError_ModeError();
|
||||||
|
}
|
||||||
|
|
||||||
im = ImagingNew(mode, 256, 256);
|
im = ImagingNew(mode, 256, 256);
|
||||||
if (!im)
|
if (!im) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (y = 0; y < 256; y++)
|
for (y = 0; y < 256; y++) {
|
||||||
for (x = 0; x < 256; x++) {
|
for (x = 0; x < 256; x++) {
|
||||||
d = (int) sqrt((double) ((x-128)*(x-128) + (y-128)*(y-128)) * 2.0);
|
d = (int) sqrt((double) ((x-128)*(x-128) + (y-128)*(y-128)) * 2.0);
|
||||||
if (d >= 255)
|
if (d >= 255) {
|
||||||
im->image8[y][x] = 255;
|
im->image8[y][x] = 255;
|
||||||
else
|
} else {
|
||||||
im->image8[y][x] = d;
|
im->image8[y][x] = d;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user