mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-22 22:35:18 +02:00
add doc
This commit is contained in:
BIN
docs/images/lib3x-mz_tiles-1.JPG
Normal file
BIN
docs/images/lib3x-mz_tiles-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
docs/images/lib3x-mz_tiles-2.JPG
Normal file
BIN
docs/images/lib3x-mz_tiles-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
docs/images/lib3x-mz_tiles-3.JPG
Normal file
BIN
docs/images/lib3x-mz_tiles-3.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 132 KiB |
75
docs/lib3x-mz_tiles.md
Normal file
75
docs/lib3x-mz_tiles.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# mz_tiles
|
||||
|
||||
It turns maze cells into tiles. The retured tiles have a data structure `[x, y, n]`, where `n` is a tile index 0 ~ 15 of the tileset.
|
||||
|
||||

|
||||
|
||||
Just replace the tiles with your own path designs.
|
||||
|
||||
**Since:** 3.3
|
||||
|
||||
## Parameters
|
||||
|
||||
- `cells` : Maze cells.
|
||||
- `left_border` : Default to `true`. Create the leftmost border of the maze.
|
||||
- `bottom_border` : Default to `true`. Create the bottommost border of the maze.
|
||||
|
||||
## Examples
|
||||
|
||||
use <maze/mz_square_initialize.scad>
|
||||
use <maze/mz_square.scad>
|
||||
use <maze/mz_tiles.scad>
|
||||
use <util/rand.scad>
|
||||
|
||||
rows = 10;
|
||||
columns = 10;
|
||||
|
||||
cells = mz_square(rows, columns);
|
||||
|
||||
tiles = mz_tiles(cells);
|
||||
|
||||
tile_width = 30;
|
||||
for(tile = tiles) {
|
||||
translate([tile.x, tile.y] * tile_width)
|
||||
tile(tile[2], tile_width);
|
||||
}
|
||||
|
||||
module tile(type, width) {
|
||||
// true 表示該方向有通道
|
||||
roads = [
|
||||
[false, false, false, false],
|
||||
[true, false, false, false],
|
||||
[false, true, false, false],
|
||||
[true, true, false, false],
|
||||
[false, false, true, false],
|
||||
[true, false, true, false],
|
||||
[false, true, true, false],
|
||||
[true, true, true, false],
|
||||
[false, false, false, true],
|
||||
[true, false, false, true],
|
||||
[false, true, false, true],
|
||||
[true, true, false, true],
|
||||
[false, false, true, true],
|
||||
[true, false, true, true],
|
||||
[false, true, true, true],
|
||||
[true, true, true, true]
|
||||
];
|
||||
|
||||
difference() {
|
||||
square(width, center = true);
|
||||
|
||||
for(i = [0:3]) {
|
||||
if(roads[type][i]) {
|
||||
rotate(-90 * i)
|
||||
translate([-width / 4, -width / 4])
|
||||
square([width / 2, width]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||

|
||||
|
||||
An advanced model.
|
||||
|
||||
[](https://cults3d.com/en/3d-model/art/maze-city)
|
Reference in New Issue
Block a user