An easy way to create a grid based on a template
- No options to set up.
- To use it you need to add catnip from sidebar
Create grid with template.
- If you prefer to pure code
// Define parameters for the grid
let template = 'template1';
let startX = 100;
let startY = 50;
let rows = 5;
let columns = 5;
let batchID = 1;
let padding = 1;
// Create the grid
let gridArray = createGrid(template, startX, startY, rows, columns, batchID);
Or
let gridArray = createGridWithPadding(template, startX, startY, rows, columns, padding, batchID);
// Output the result
console.log(gridArray);
createGrid(template, startX, startY, rows, columns, batchID);
Cretes a grid of the template with the given parameters.
Returns an array of templates.
In the new added templates you can get 2 new properties gridID and gridBatchID.
- property of template: gridID: number;
Unique identifier for the template instance within the grid. - property of template: gridBatchID:number;
Identifier for the batch this instance belongs to.
For emaple in a loop of templates like
for(var temp of arrayOfTemplates){
console.log('This is my ID: ' + temp.gridID + 'I am a remplate of the grid: temp.gridBatchID' );
}
You can access this values like this.gridID or this.gridBatchID.
A mini tutorial is available here: https://www.youtube.com/watch?v=nv5JZKsFgiY and thats it...
Enjoy making grids.
By Ulises Freitas.




