I have a this bonus problem for class that I don't have a clue where to start. We have been using the cImage module and the question is: Write a function called DrawTriangle that takes parameters img, x1, y1, x2, y2, x3, y3 and col, where col is a Pixel object, that draws a filled triangle with vertices (x1,y1), (x2,y2) and (x3, y3) with color onto image object img. I understand its for school so if I don't get help it's fine it's only a bonus question. It would be nice to see how it is done though!

Well, for whatever it's worth, here is a hint ...

# exploring module cImage (a Tkinter wrapper)
# from:
# http://www.cs.luther.edu/~pythonworks/PythonContext/cImage.py

import cImage

# this actually creates a canvas ready for drawing
win = cImage.ImageWin("My Canvas", 500, 400)

# let's draw a red line on the canvas object
# from coordinate points x1=10, y1=100 to x2=400, y2=50
win.create_line(10, 100, 400, 50, fill="red")

# needed
win.exitOnClick()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.