(Solved) : Implement Bresenham S Integer Line Drawing Algorithm Correctly Lines Slopes Python As1py M Q43967074 . . .
implement Bresenham’s integer line drawing algorithm correctly,for lines of all slopes in python
as1.py:
from math import *from graphicsWindow import graphicsWindowwindow = graphicsWindow(512,512)t = 0.0dt = 2.0*pi/200.0color = (255,255,255)while t < 2.0*pi: x1 = 256 + int(100.0*(1.5*cos(t) – cos(13.0*t))) y1 = 256 + int(100.0*(1.5*sin(t) – sin(13.0*t))) t += dt x2 = 256 + int(100.0*(1.5*cos(t) – cos(13.0*t))) y2 = 256 + int(100.0*(1.5*sin(t) – sin(13.0*t))) window.drawLine((x1,y1),(x2,y2),color)window.saveImage(“testImage2.png”)
graphicsWindow.py
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) def drawLine(self,start,end,color): # this section will be your area to implement
result as following

Expert Answer
Answer to implement Bresenham’s integer line drawing algorithm correctly, for lines of all slopes in python as1.py: from math impo…
OR