def test_draw_line_steep(self): img = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) line = Line(0, 0, 1, 4) img.draw(line, White) self.assertImage(img, [ [White, Black, Black, Black, Black], [White, Black, Black, Black, Black], [Black, White, Black, Black, Black], [Black, White, Black, Black, Black], [Black, White, Black, Black, Black], ])
def test_draw_line_topright_bottomleft(self): img = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) line = Line(4, 0, 0, 4) img.draw(line, White) self.assertImage(img, [ [Black, Black, Black, Black, White], [Black, Black, Black, White, Black], [Black, Black, White, Black, Black], [Black, White, Black, Black, Black], [White, Black, Black, Black, Black], ])
def drawrect(self, row, col): (x, y), (x2, y2) = self.pixel_box(row, col) for r in range(self.box_size): line_y = y + r line = Line(x, line_y, x2, line_y) self._img.draw(line, Black)
def draw_lines(img): topleft_bottomright = Line(0, 0, 999, 999) bottomright_topleft = Line(999, 999, 0, 0) bottomleft_topright = Line(0, 999, 999, 0) topright_bottomleft = Line(999, 0, 0, 999) img.draw(topleft_bottomright, White) img.draw(bottomright_topleft, White) img.draw(bottomleft_topright, White) img.draw(topright_bottomleft, White) slop1 = Line(100, 0, 899, 999) slop2 = Line(899, 999, 100, 0) slop3 = Line(0, 899, 899, 0) slop4 = Line(899, 0, 0, 899) img.draw(slop1, Yellow) img.draw(slop2, Yellow) img.draw(slop3, Yellow) img.draw(slop4, Yellow) blue1 = Line(10, 30, 500, 600) blue2 = Line(700, 900, 100, 20) blue3 = Line(0, 300, 666, 33) blue4 = Line(876, 0, 20, 717) img.draw(blue1, SlateBlue) img.draw(blue2, SlateBlue) img.draw(blue3, SlateBlue) img.draw(blue4, SlateBlue) return img