Last active
January 30, 2018 22:58
-
-
Save sbrl/60f51f080a86bf8a4e5e to your computer and use it in GitHub Desktop.
A simple function for rendering crosses on a HTML5 canvas. Depends on my earlier Vector class. #debugging #function
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
| function renderCross(context, pos, size) | |
| { | |
| var radius = size / 2; | |
| context.beginPath(); | |
| context.moveTo(pos.x - radius, pos.y - radius); | |
| context.lineTo(pos.x + radius, pos.y + radius); | |
| context.moveTo(pos.x + radius, pos.y - radius); | |
| context.lineTo(pos.x - radius, pos.y + radius); | |
| context.lineWidth = 3; | |
| context.strokeStyle = "red"; | |
| context.stroke(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment