Python program to use cImage library to draw a given picture.

Write a program that uses cImage library and draws the below image. Use color blue to draw the diagonal lines. Use red to draw a vertical line in the lower half.

Sample output


from cImage import *

p1 = Pixel(0,0,255)
p2 = Pixel(255,0,0)
im = EmptyImage(300,300)
x = 299
w = ImageWin(“My Image”, 300, 300)
for i in range (300):
     im.setPixel(i, i, p1)
for i in range (300):
     im.setPixel(x, i, p1)
     x = x – 1
for i in range (150):
     im.setPixel(150, i+150, p2)