Created
July 11, 2020 18:00
-
-
Save EduardoJM/3b98bf27e852c3e323ab9dbaeb972d67 to your computer and use it in GitHub Desktop.
Separating Axis Theorem Polygon Render Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
polygon.render = function(context, color) { | |
context.strokeStyle = color; | |
context.beginPath(); | |
context.moveTo( | |
polygon.vertices[0].x, | |
polygon.vertices[0].y | |
); | |
for (let i = 1; i < polygon.vertices.length; i++) { | |
context.lineTo( | |
polygon.vertices[i].x, | |
polygon.vertices[i].y | |
); | |
} | |
context.closePath(); | |
context.stroke(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment