-
Notifications
You must be signed in to change notification settings - Fork 10
Polygon as_segments()
#168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
61a8423
211621c
13c3756
044d89c
5c6781c
684e6fb
2fa387a
27066d5
7d86bc5
5ab8139
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,3 +400,4 @@ MODINIT_DEFINE(geometry) | |
| } | ||
| return module; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| from pygame import Vector2, Vector3, Rect | ||
|
|
||
| import geometry | ||
| from geometry import Polygon | ||
| from geometry import Polygon, Line | ||
|
|
||
| import math | ||
|
|
||
|
|
@@ -582,6 +582,33 @@ def test__repr__(self): | |
| self.assertEqual(repr(polygon), p_repr) | ||
| self.assertEqual(polygon.__repr__(), p_repr) | ||
|
|
||
| def test_as_segments(self): | ||
| """Checks whether polygon segments are correct""" | ||
| poly = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]) | ||
| self.assertEqual( | ||
| poly.as_segments(), | ||
| [ | ||
| Line((0, 0), (1, 0)), | ||
| Line((1, 0), (1, 1)), | ||
| Line((1, 1), (0, 1)), | ||
| Line((0, 1), (0, 0)), | ||
| ], | ||
| ) | ||
| poly = Polygon([(123.23, 35.6), (56.4, 87.45), (43.1, 12.3)]) | ||
| self.assertEqual( | ||
| poly.as_segments(), | ||
| [ | ||
| Line((123.23, 35.6), (56.4, 87.45)), | ||
| Line((56.4, 87.45), (43.1, 12.3)), | ||
| Line((43.1, 12.3), (123.23, 35.6)), | ||
| ], | ||
| ) | ||
| poly = Polygon([[1, 2], [3, 4], [5, 6]]) | ||
| self.assertEqual( | ||
| poly.as_segments(), | ||
| [Line((1, 2), (3, 4)), Line((3, 4), (5, 6)), Line((5, 6), (1, 2))], | ||
| ) | ||
|
Comment on lines
+585
to
+610
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should add more tests for invalid argument types and argument number.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically you should make sure that this is actually a no arguments method now and in the future |
||
|
|
||
| def test_move_xy(self): | ||
| """Checks whether polygon move function works correctly with an x-y pair.""" | ||
| poly = Polygon(_some_vertices.copy()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need
@overloadhere, there's just one way to call this function