Skip to content

Instantly share code, notes, and snippets.

@leegao
Created July 13, 2013 13:54
Show Gist options
  • Select an option

  • Save leegao/5990795 to your computer and use it in GitHub Desktop.

Select an option

Save leegao/5990795 to your computer and use it in GitHub Desktop.
sendStrokes();
// find bounding box on strokes
var minx = strokes[0][0].x, miny = strokes[0][0].y, maxx = strokes[0][1].x, maxy = strokes[0][1].y;
for (var i = 0; i < strokes.length; i++) {
var stroke = strokes[i];
for (var j = 0; j < stroke.length; j++) {
var x = stroke[j].x;
var y = stroke[j].y;
if (x < minx) {
minx = x;
}
if (x > maxx) {
maxx = x;
}
if (y < miny) {
miny = y;
}
if (Y > maxy) {
maxy = y;
}
}
}
console.log(minx,miny,maxx,maxy);
var a = maxx + 30;
var b = (maxy + miny)/2;
// draw equal sign
ctx.beginPath();
ctx.moveTo(a,b);
ctx.lineTo(a+20,b);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(a,b+10);
ctx.lineTo(a+20,b+10);
ctx.stroke();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment