Menu

Purpose Assignment Complete Python Class Graphicswindow Found File Graphicswindowpy Asked Q43858431

The purpose of this assignment is to complete the Python classgraphicsWindow found in file graphicsWindow.py. You are asked toprogram a method drawLine(p1,p2,color) that draws a line in theimage from point p1 to point p2 with color color. The points p1 andp2 are expressed as tuples (x,y). The color is also a tuple of theform (r,g,b) where r,g,b are values between 0 and 255. The methoddrawLine(p1,p2,color) must:

  • implement Bresenham’s integer line drawing algorithm correctly,for lines of all slopes
  • be properly documented (Header comments: descrpition ofparameters, what the method does, and description of output. Codecomments: description of non-obvious sections of code)
  • The class graphicsWindow is available in the Resources Sectionof OWL, under Python Code
  • Do not change file name nor the actual name of thegraphicsWindow class
  • Make sure your method drawLine(p1,p2,color) is actually calleddrawLine
  • Repsect the type and order of the parameters
  • Use the following Python program to testDrawline(p1,p2,color)
  • The output of the test program should correspond exactly tothis image
  • Use OWL to submit the file graphicsWindow.py containing yourmethod drawLine(p1,p2,color)

—————————————————————————————————————————–

graphicsWindow.py. as following

from PIL import Imageclass graphicsWindow: def __init__(self,width=640,height=480): self.__mode = ‘RGB’ self.__width = width self.__height = height self.__canvas = Image.new(self.__mode,(self.__width,self.__height)) self.__image = self.__canvas.load() def getWidth(self): return self.__width def getHeight(self): return self.__height def drawPixel(self,pixel,color): self.__image[pixel[0],pixel[1]] = color def saveImage(self,fileName): self.__canvas.save(fileName)

Expert Answer


Answer to The purpose of this assignment is to complete the Python class graphicsWindow found in file graphicsWindow.py. You are a…

OR