trianglesGrid = {
let numTriangles = 10;
let lines = [];
var max = Math.sqrt(width * width + height * height),
cos60 = Math.cos(Math.PI / 3),
sin60 = Math.sin(Math.PI / 3),
cos120 = Math.cos((Math.PI * 2) / 3),
sin120 = Math.sin((Math.PI * 2) / 3);
let y = 0;
let x = 0;
let i = 0;
for (i = x; i <= x + width; i += numTriangles) {
lines.push([{ x: i, y: y }, { x: i + cos60 * max, y: y + sin60 * max }]);
lines.push([{ x: i, y: y }, { x: i + cos120 * max, y: y + sin120 * max }]);
}
let dy = sin60 * numTriangles,
maxX = Math.ceil(width / numTriangles) * numTriangles + x;
for (i = y; i <= y + height; i += dy) {
lines.push([{ x: x, y: i }, { x: x + width, y: i }]);
}
for (i = y + dy * 2; i <= y + height; i += dy * 2) {
if (i > 0) {
lines.push([{ x: x, y: i }, { x: x + cos60 * max, y: i + sin60 * max }]);
}
lines.push([
{ x: maxX, y: i },
{ x: maxX + cos120 * max, y: i + sin120 * max }
]);
}
return lines;
}