src/contexts/InverseGridContext.js
function(hexDimensions, radius) {
  var positionArray = [];
  var pixelCoordinates;

  //For every hex, place an instance of the original mesh. The symbol fills in 3 of the 6 lines, the other 3 being shared with an adjacent hex

  //Make a hexagonal grid of hexagons since it is approximately circular.
  var u = 0;
  var v = 0;
  //For each radius
  positionArray.push({ y: 0, x: 0 });
  for (var i = 1; i < radius + 1; i++) {
    //Hold u constant as the radius, add an instance for each v
    for (v = -i; v <= 0; v++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(i, v);

      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold u constant as negative the radius, add an instance for each v
    for (v = 0; v <= i; v++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(-i, v);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold v constant as the radius, add an instance for each u
    for (u = -i + 1; u <= 0; u++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, i);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold v constant as negative the radius, add an instance for each u
    for (u = 0; u < i; u++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, -i);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold w constant as the radius, add an instance for each u + v = -i
    for (u = -i + 1, v = -1; v > -i; u++, v--) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, v);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold w constant as the negative radius, add an instance for each u + v = i
    for (u = i - 1, v = 1; v < i; u--, v++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, v);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }
  }

  return positionArray;
}
function(hexDimensions, radius) {
  var positionArray = [];
  var pixelCoordinates;

  //For every hex, place an instance of the original mesh. The symbol fills in 3 of the 6 lines, the other 3 being shared with an adjacent hex

  //Make a hexagonal grid of hexagons since it is approximately circular.
  var u = 0;
  var v = 0;
  //For each radius
  positionArray.push({ y: 0, x: 0 });
  for (var i = 1; i < radius + 1; i++) {
    //Hold u constant as the radius, add an instance for each v
    for (v = -i; v <= 0; v++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(i, v);

      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold u constant as negative the radius, add an instance for each v
    for (v = 0; v <= i; v++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(-i, v);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold v constant as the radius, add an instance for each u
    for (u = -i + 1; u <= 0; u++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, i);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold v constant as negative the radius, add an instance for each u
    for (u = 0; u < i; u++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, -i);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold w constant as the radius, add an instance for each u + v = -i
    for (u = -i + 1, v = -1; v > -i; u++, v--) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, v);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }

    //Hold w constant as the negative radius, add an instance for each u + v = i
    for (u = i - 1, v = 1; v < i; u--, v++) {
      pixelCoordinates = hexDimensions.getPixelCoordinates(u, v);
      positionArray.push({ y: pixelCoordinates.y, x: pixelCoordinates.x });
    }
  }

  return positionArray;
}
function ( hexDimensions , radius ) { var positionArray = [ ] ; var pixelCoordinates ; //For every hex, place an instance of the original mesh. The symbol fills in 3 of the 6 lines, the other 3 being shared with an adjacent hex //Make a hexagonal grid of hexagons since it is approximately circular. var u = 0 ; var v = 0 ; //For each radius positionArray . push ( { y : 0 , x : 0 } ) ; for ( var i = 1 ; i < radius + 1 ; i ++ ) { //Hold u constant as the radius, add an instance for each v for ( v = - i ; v <= 0 ; v ++ ) { pixelCoordinates = hexDimensions . getPixelCoordinates ( i , v ) ; positionArray . push ( { y : pixelCoordinates . y , x : pixelCoordinates . x } ) ; } //Hold u constant as negative the radius, add an instance for each v for ( v = 0 ; v <= i ; v ++ ) { pixelCoordinates = hexDimensions . getPixelCoordinates ( - i , v ) ; positionArray . push ( { y : pixelCoordinates . y , x : pixelCoordinates . x } ) ; } //Hold v constant as the radius, add an instance for each u for ( u = - i + 1 ; u <= 0 ; u ++ ) { pixelCoordinates = hexDimensions . getPixelCoordinates ( u , i ) ; positionArray . push ( { y : pixelCoordinates . y , x : pixelCoordinates . x } ) ; } //Hold v constant as negative the radius, add an instance for each u for ( u = 0 ; u < i ; u ++ ) { pixelCoordinates = hexDimensions . getPixelCoordinates ( u , - i ) ; positionArray . push ( { y : pixelCoordinates . y , x : pixelCoordinates . x } ) ; } //Hold w constant as the radius, add an instance for each u + v = -i for ( u = - i + 1 , v = - 1 ; v > - i ; u ++ , v -- ) { pixelCoordinates = hexDimensions . getPixelCoordinates ( u , v ) ; positionArray . push ( { y : pixelCoordinates . y , x : pixelCoordinates . x } ) ; } //Hold w constant as the negative radius, add an instance for each u + v = i for ( u = i - 1 , v = 1 ; v < i ; u -- , v ++ ) { pixelCoordinates = hexDimensions . getPixelCoordinates ( u , v ) ; positionArray . push ( { y : pixelCoordinates . y , x : pixelCoordinates . x } ) ; } } return positionArray ; }
Creates a full grid from the single mesh
@private
Creates a full grid from the single mesh