Last active
August 29, 2015 14:12
-
-
Save joshuakfarrar/9107f3b6bf44ed208ab3 to your computer and use it in GitHub Desktop.
simple shapes for tic-tac-toe
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
define(function() { | |
var Board = Class.extend({ | |
paint: function(context) { | |
var width = context.canvas.width, | |
height = context.canvas.height; | |
var padding = 5; | |
for (var i = 0; i < 4; i++) { | |
var line; | |
switch (i) { | |
case 0: | |
line = [ | |
{x: width / 3, y: padding }, | |
{x: width / 3, y: height - padding } | |
]; | |
break; | |
case 1: | |
line = [ | |
{x: width / 3 * 2, y: padding }, | |
{x: width / 3 * 2, y: height - padding } | |
]; | |
break; | |
case 2: | |
line = [ | |
{x: padding, y: height / 3 }, | |
{x: width - padding, y: height / 3 } | |
]; | |
break; | |
case 3: | |
line = [ | |
{x: padding, y: height / 3 * 2 }, | |
{x: width - padding, y: height / 3 * 2 } | |
]; | |
} | |
context.beginPath(); | |
context.moveTo(line[0]['x'], line[0]['y']); | |
context.lineTo(line[1]['x'], line[1]['y']); | |
context.stroke(); | |
} | |
} | |
}); | |
return Board; | |
}); |
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
define(function() { | |
var paint = function(context, bounds) { | |
var width = context.canvas.width, | |
height = context.canvas.height; | |
var padding = 5; | |
context.lineWidth = 2; | |
context.beginPath(); | |
context.arc(width / 2, height / 2, (width - padding) / 2, 0, 2 * Math.PI, false); | |
context.stroke(); | |
} | |
return paint; | |
}); |
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
define(function() { | |
var paint = function(context, bounds) { | |
var width = context.canvas.width, | |
height = context.canvas.height; | |
var padding = 5; | |
context.lineWidth = 2; | |
context.beginPath(); | |
context.moveTo(padding, padding); | |
context.lineTo(width - padding, height - padding); | |
context.stroke(); | |
context.beginPath(); | |
context.moveTo(width - padding, padding); | |
context.lineTo(padding, height - padding); | |
context.stroke(); | |
} | |
return paint; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment