@@ -25,11 +25,13 @@ The output bundle for basic rectangular maze is normally upto 3KBs.
2525
2626### via CDN
2727
28- ``` js
29- import Maze from ' https://cdn.jsdelivr.net/npm/[email protected] /dist/index.min.js' ;
28+ ``` html
29+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /index.umd.js" ></
script >
30+ <script >
31+ // here mazes101 is available in global scope
32+ </script >
3033```
3134
32-
3335## Usage
3436
3537As mentioned early, these are just some set of utilizes which means that they can be hacked to do anything you like.
@@ -40,11 +42,34 @@ The typical flow of generating a maze looks something as following:
4042First, chose a [ Board Type] ( boards/index.md ) you can create then create an empty board of that type. For example for a rectangular board
4143you can import it from [ ` boards/rectangular ` ] ( boards/rectangular.md ) and use it like:
4244
43- ``` js linenums="1"
44- import {newBoard } from ' mazes101/boards/rectangular' ;
45+ === "EcmaScript"
46+
47+ ```js linenums="1"
48+ import {newBoard} from 'mazes101/boards/rectangular';
49+
50+ let board = newBoard({height: 20, width: 20});
51+ ```
52+
53+ === "NodeJs"
54+
55+ ```js linenums="1"
56+ import mazes101 from 'mazes101';
57+ let {newBoard} = mazes101.Boards.rectangular;
58+ let board = newBoard({height: 20, width: 20});
59+ ```
60+
61+ === "CDN"
62+
63+ ```html
64+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /index.umd.js " ></
script >
65+ ```
66+
67+ ```js linenums="1"
68+ let {newBoard} = mazes101.Boards.rectangular;
69+
70+ let board = newBoard({height: 20, width: 20});
71+ ```
4572
46- let board = newBoard ({height: 20 , width: 20 });
47- ```
4873
4974Before generating a maze in this board, you can also do some preprocessing on this board, like
5075disabling some cells etc.
@@ -55,18 +80,35 @@ Next, step could be to generate a maze in this board, for this you need a maze g
5580some built-in [ Generation Algorithms] ( generators/index.md ) for example lets use
5681[ ` generators/kruskal ` ] ( generators/kruskal.md ) :
5782
58- ``` js linenums="4"
59- import {generate } from ' mazes101/generators/kruskal' ;
60-
61- // import required functions from the board you selected in step 1
62- import {
63- getRows ,
64- getNextRowNeighbours ,
65- removeInterWall
66- } from ' mazes101/boards/rectangular' ;
83+ === "EcmaScript"
84+
85+ ```js linenums="4"
86+ import {generate} from 'mazes101/generators/kruskal';
87+
88+ // import required functions from the board you selected in step 1
89+ import {
90+ getRows,
91+ getNextRowNeighbours,
92+ removeInterWall
93+ } from 'mazes101/boards/rectangular';
94+
95+ board = generate(board, {getRows, getNextRowNeighbours, removeInterWall});
96+ ```
6797
68- board = generate (board, {getRows, getNextRowNeighbours, removeInterWall});
69- ```
98+ === "NodeJs/CDN"
99+
100+ ```js linenums="4"
101+ let {generate} = mazes101.Generators.kruskal;
102+
103+ // import required functions from the board you selected in step 1
104+ let {
105+ getRows,
106+ getNextRowNeighbours,
107+ removeInterWall
108+ } = mazes101.Boards.rectangular;
109+
110+ board = generate(board, {getRows, getNextRowNeighbours, removeInterWall});
111+ ```
70112
71113!!! note
72114 The ` generate ` method returns a new board instead of altering the provided board so, it is important to assign that
@@ -78,10 +120,20 @@ board = generate(board, {getRows, getNextRowNeighbours, removeInterWall});
78120The last step would be to render the board, Mazes101 comes with some built-in [ Renderers] ( renderers/index.md ) too.
79121For example, [ ` renderers/rectangularSvg ` ] ( renderers/rectangularSvg.md ) this renderer renders rectangular boards to svg string.
80122
81- ``` js linenums="14"
82- import {render } from ' mazes101/renderers/rectangularSvg' ;
123+ === "EcmaScript"
83124
84- const svgString = render (board);
85- ```
125+ ```js linenums="14"
126+ import {render} from 'mazes101/renderers/rectangularSvg';
127+
128+ const svgString = render(board);
129+ ```
130+
131+ === "NodeJs/CDN"
132+
133+ ```js linenums="14"
134+ let {render} = mazes101.Renderers.rectangularSvg;
135+
136+ const svgString = render(board);
137+ ```
86138
87139Now, you can either render this svg string to DOM, save it to a file or send it to client via http.
0 commit comments