Skip to content

Commit

Permalink
Merge pull request #8 from benrutter/rect-issue
Browse files Browse the repository at this point in the history
Rect issue
  • Loading branch information
benrutter authored Apr 16, 2022
2 parents e9c4873 + 892110c commit 06c1d2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='shades',
version='1.1',
version='1.2',
author='Ben Rutter',
description='A Python module for generative 2d image creation',
long_description=long_description,
Expand Down
19 changes: 15 additions & 4 deletions shades/shades.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,21 @@ def rectangle(
"""
Draws a rectangle on the image.
"""
top_right_corner = (top_corner[0] + width, top_corner[1])
bottom_corner = (top_corner[0], top_corner[1] + height)
bottom_right_corner = (top_corner[0] + width, top_corner[1] + height)
self.shape(canvas, [top_corner, top_right_corner, bottom_corner, bottom_right_corner])
for x_coord in range(top_corner[0], top_corner[0] + width):
for y_coord in range(top_corner[1], top_corner[1] + height):
self.point(canvas, (x_coord, y_coord))

def square(
self,
canvas: Image,
top_corner: Tuple[int, int],
size: int,
) -> None:
"""
Draws a square on the canvas
"""
self.rectangle(canvas, top_corner, size, size)


def triangle(
self,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_shades.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def test_rectangle(self):
self.shade.rectangle(self.canvas, (0, 0), 10, 10)


@marks_canvas_test
def test_square(self):
self.shade.square(self.canvas, (0, 0), 10)

@marks_canvas_test
def test_triangle(self):
self.shade.triangle(self.canvas, (0, 0), (10, 10), (0, 10))
Expand Down

0 comments on commit 06c1d2e

Please sign in to comment.