def gradient(self, style=LINEAR, w=<NUM_LIT:1.0>, h=<NUM_LIT:1.0>, name="<STR_LIT>"):
from types import FloatType<EOL>w0 = self.w <EOL>h0 = self.h<EOL>if type(w) == FloatType: w *= w0<EOL>if type(h) == FloatType: h *= h0<EOL>img = Image.new("<STR_LIT:L>", (int(w),int(h)), <NUM_LIT:255>)<EOL>draw = ImageDraw.Draw(img)<EOL>if style == LINEAR:<EOL><INDENT>for i in range(int(w)):<EOL><INDENT>k = <NUM_LIT> * i/w<EOL>draw.rectangle((i, <NUM_LIT:0>, i, h), fill=int(k))<EOL><DEDENT><DEDENT>if style == RADIAL:<EOL><INDENT>r = min(w,h)/<NUM_LIT:2><EOL>for i in range(int(r)):<EOL><INDENT>k = <NUM_LIT:255> - <NUM_LIT> * i/r<EOL>draw.ellipse((w/<NUM_LIT:2>-r+i, h/<NUM_LIT:2>-r+i, w/<NUM_LIT:2>+r-i, h/<NUM_LIT:2>+r-i), fill=int(k))<EOL><DEDENT><DEDENT>if style == DIAMOND:<EOL><INDENT>r = max(w,h)<EOL>for i in range(int(r)):<EOL><INDENT>x = int(i*w/r*<NUM_LIT:0.5>)<EOL>y = int(i*h/r*<NUM_LIT:0.5>)<EOL>k = <NUM_LIT> * i/r<EOL>draw.rectangle((x, y, w-x, h-y), outline=int(k))<EOL><DEDENT><DEDENT>img = img.convert("<STR_LIT>")<EOL>self.layer(img, <NUM_LIT:0>, <NUM_LIT:0>, name="<STR_LIT>")<EOL>
Creates a gradient layer.

        Creates a gradient layer, that is usually used
        together with the mask() function.

        All the image functions work on gradients,
        so they can easily be flipped, rotated, scaled, inverted,
        made brighter or darker, ...

        Styles for gradients are LINEAR, RADIAL and DIAMOND.