Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to complete the Python class graphicsWindow found in file graphicsWindow.py. You are asked to program a method drawLine(p1,p2,color) that

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

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

-----------------------------------------------------------------------------------------------------------------------------

graphicsWindow.py. as following

from PIL import Image class 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)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions

Question

The Functions of Language Problems with Language

Answered: 1 week ago

Question

The Nature of Language

Answered: 1 week ago