Python Challenge level 9: “connect the dots”
Level 9 needs some more drawing.
Hint 1: first+second=?
import Image,ImageDraw
im = Image.new('RGB', (500,500))
draw = ImageDraw.Draw(im)
first=[146,399,163,403, ...] # chunked
second=[156,141,165,135, ...] # chunked
for i in range(0, len(first), 2):
draw.line(first[i:i + 4], fill='white')
for i in range(0, len(second), 2):
draw.line(second[i:i + 4], fill='white')
im.save('09.jpg')
Is it a cow? Nope, it’s Level 10.
EDIT: Thanks to Meng Tan for the comment below. I didn’t know that PIL could (also) do that ;)
The script would be as follows:
import Image,ImageDraw
im = Image.new('RGB', (500,500))
draw = ImageDraw.Draw(im)
first=[146,399,163,403, ...] # chunked
second=[156,141,165,135, ...] # chunked
draw.polygon(first,fill='white')
draw.polygon(second,fill='white')
im.save('09.jpg')
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
draw.polygon() will accept the lists as arguments.
draw.line() works as well.
The problem i have with this is that cow.html says “hmm. it’s a male. “, which prompts you to try bull.html, however the result of the bull.html url seems to be the full colour picture of the said animal – and its NOT a bull! Its definitely a cow, so am i missing something? or is just oblique humour?
I could not get draw.line() to work, even when I split the coords into pairs and tried drawing from one to the next. I didn’t get anything. I guess I need to play around with it in ipython. draw.polygon() worked like a charm.