Skip to content

Instantly share code, notes, and snippets.

@sbrl
Last active January 30, 2018 22:58
Show Gist options
  • Select an option

  • Save sbrl/60f51f080a86bf8a4e5e to your computer and use it in GitHub Desktop.

Select an option

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
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