Created
May 10, 2018 09:24
-
-
Save jawdatls/ec96f20e9b41d1955ba97e3f1e07e253 to your computer and use it in GitHub Desktop.
Shape Grid Calculation
This file contains 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
// Base | |
let w = width; // shape width | |
let h = height; // shape height | |
let r = row; // grid row start by 0 | |
let c = column; // grid column start by 0 | |
// Square | |
let left = r * w; // transform left position | |
let top = j * h; // transform top position | |
// Diamond | |
let left = ((r%2) * (-1) * (w/2)) + (c * w); // transform left position | |
let top = (r * h/2) - (h/2); // transform top position | |
// Hexagonal | |
let left = ((r%2) * (-1) * (w/2)) + (c * w); // transform left position | |
let top = (r * 3 * h/4) - (h/2); // transform top position |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment