var hexMeshObj;
var svgns = "http://www.w3.org/2000/svg";
var hexArray=new Array();
window.onload=function() {
console.log('main');
side=35;
hexMeshObj=new hexMesh();
hexMeshObj.drawOver();
}
function hexMesh(){
var side=25;
console.log('hexMesh');
var drawnCentroids=[]; //array of centroids of hex which are drawn on the scree
var drawnAroundCentroids=[]; //array of centroid of hex which have hex drawn ALL around them
var ii=0;
var rightEdge=screen.width;
var leftEdge=0;
var topEdge=0;
var botEdge=screen.height;
var svg=document.getElementsByTagName('svg')[0]; //draw around svg
//draw hexagons over the defined edges
function drawOver(){
var verticalBlock=1; //first vertical block of hexagons
var offSet=side*(1.73/2); //offset to the next block to align the hexagons
hexArray[0]=new Hexagon(0,0,side,0); // starting hex
for(i=hexArray[0].cx;i<rightEdge;i=i+side*1.5){
verticalBlock++;
for(j=(verticalBlock%2==0)?(hexArray[0].cy):(hexArray[0].cy+offSet);j<botEdge;j=j+side*1.73){
hexArray[verticalBlock-1]=new Hexagon(i,j,side,verticalBlock-1);
console.log(i,j);
hexArray[verticalBlock-1].makeHex(svg,svgns);
}
}
}
function drawHexAround(cent){
var rightEdgeReached=false;
var botEdgeReached=false;
//console.log(screen.width);
rightEdge=1300;
botEdge=700;
if(ii<20){
ii++;
var xRight;// y axiom from centroid of the hexs' RIGHT of current
var xLeft;// y axiom from centroid of the hexs' left of current
var yMidTop;// x axiom from centroid of the hexs' sided-top of current
var yMidBot;// x axiom from centroid of the hexs' sided-bottom of current
var yTop; // x axiom from the centroid of the top hex from current
var yBot; // x axiom from the centroid of the bot hex from current
var...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!