How to draw a rectangle with gradient?

D

Daniel Mark

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
 
P

Pontus Ekberg

Daniel said:
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)
.... draw.line((0, l, 100, l), fill=colour)
....
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 ----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top