Re: How to draw a rectangle with gradient?
- From: Pontus Ekberg <herrekberg@xxxxxxxxxxxx>
- Date: Sat, 16 Sep 2006 23:01:20 +0200
Daniel Mark wrote:
Hello all:
I am using PIL to draw a rectangle filled with color blue.
Is there anyway I could set the fill pattern so that the drawn
rectangle could be filled with
gradient blue?
Thank you
-Daniel
I don't think there is a built-in gradient function, but you could do
something like this:
.... colour = (0, 0, 255 * l / 100)import Image
import ImageDraw
im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
for l in xrange(100):
.... draw.line((0, l, 100, l), fill=colour)
....
im.show()
You have to adjust for the size and colours you want of course, and change
the loop so that the gradient is in the right direction.
// Pontus
------------ And now a word from our sponsor ----------------------
For a quality mail server, try SurgeMail, easy to install,
fast, efficient and reliable. Run a million users on a standard
PC running NT or Unix without running out of power, use the best!
---- See http://netwinsite.com/sponsor/sponsor_surgemail.htm ----
.
- References:
- How to draw a rectangle with gradient?
- From: Daniel Mark
- How to draw a rectangle with gradient?
- Prev by Date: Re: Pythondocs.info : collaborative Python documentation project
- Next by Date: Re: Pythondocs.info : collaborative Python documentation project
- Previous by thread: How to draw a rectangle with gradient?
- Next by thread: Re: RegexBuddy (anyone use this?)
- Index(es):
Relevant Pages
|