mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-29 17:30:11 +02:00
add doc
This commit is contained in:
@@ -248,10 +248,10 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp
|
||||
### Maze
|
||||
|
||||
- [mz_square_cells](https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_square_cells.html)
|
||||
- mz_square_get
|
||||
- mz_square_initialize
|
||||
- [mz_square_get](https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_square_get.html)
|
||||
- mz_square_walls
|
||||
- mz_hex_walls
|
||||
- mz_square_initialize
|
||||
- mz_hamiltonian
|
||||
|
||||
----
|
||||
|
BIN
docs/images/lib2x-mz_square_get-1.JPG
Normal file
BIN
docs/images/lib2x-mz_square_get-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
44
docs/lib2x-mz_square_get.md
Normal file
44
docs/lib2x-mz_square_get.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# mz_square_get
|
||||
|
||||
It's a helper for getting data from a maze cell.
|
||||
|
||||
**Since:** 2.5
|
||||
|
||||
## Parameters
|
||||
|
||||
- `cell` : A maze cell.
|
||||
- `query` : Accepts `"x"`, `"y"` or `"t"`. `"x"` for the cell's x coordinate. `"y"` for the cell's y coordinate. `"t"` for the cell's type. The returned type will be `"NO_WALL"`, `"TOP_WALL"`, `"RIGHT_WALL"`, `"TOP_RIGHT_WALL"` or `"MASK"`.
|
||||
|
||||
## Examples
|
||||
|
||||
use <maze/mz_square_cells.scad>;
|
||||
use <maze/mz_square_get.scad>;
|
||||
use <line2d.scad>;
|
||||
|
||||
rows = 10;
|
||||
columns = 10;
|
||||
cell_width = 5;
|
||||
wall_thickness = 2;
|
||||
|
||||
cells = mz_square_cells(rows, columns);
|
||||
|
||||
for(cell = cells) {
|
||||
x = mz_square_get(cell, "x");
|
||||
y = mz_square_get(cell, "y");
|
||||
type = mz_square_get(cell, "t");;
|
||||
|
||||
translate([x, y] * cell_width) {
|
||||
if(type == "TOP_WALL" || type == "TOP_RIGHT_WALL") {
|
||||
line2d([0, cell_width], [cell_width, cell_width], wall_thickness);
|
||||
}
|
||||
|
||||
if(type == "RIGHT_WALL" || type == "TOP_RIGHT_WALL") {
|
||||
line2d([cell_width, cell_width], [cell_width, 0], wall_thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line2d([0, 0], [cell_width * rows, 0], wall_thickness);
|
||||
line2d([0, 0], [0, cell_width * columns], wall_thickness);
|
||||
|
||||

|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* mz_square_get.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2020
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-mz_square_get.html
|
||||
*
|
||||
**/
|
||||
|
||||
function mz_square_get(cell, query) =
|
||||
let(
|
||||
i = search(query, [
|
||||
|
Reference in New Issue
Block a user