diff --git a/README.md b/README.md index bcfe2b02..4f909e58 100644 --- a/README.md +++ b/README.md @@ -421,5 +421,6 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp [**maze/mz_squarewalls**(cells, cell_width[, left_border, bottom_border])](https://openhome.cc/eGossip/OpenSCAD/lib3x-mz_squarewalls.html) | a helper for creating square wall data from maze cells. [**maze/mz_hexwalls**(cells, cell_radius[, left_border, bottom_border])](https://openhome.cc/eGossip/OpenSCAD/lib3x-mz_hexwalls.html) | a helper for creating hex wall data from maze cells. [**maze/mz_theta**(rings, beginning_number[, start, seed])](https://openhome.cc/eGossip/OpenSCAD/lib3x-mz_theta.html) | return cell data of a theta maze. +[**maze/mz_tiles**(cells[, left_border, bottom_border])](https://openhome.cc/eGossip/OpenSCAD/lib3x-mz_tiles.html) | return cell data of a theta maze. ---- \ No newline at end of file diff --git a/docs/images/lib3x-mz_tiles-1.JPG b/docs/images/lib3x-mz_tiles-1.JPG new file mode 100644 index 00000000..a5a0c9ee Binary files /dev/null and b/docs/images/lib3x-mz_tiles-1.JPG differ diff --git a/docs/images/lib3x-mz_tiles-2.JPG b/docs/images/lib3x-mz_tiles-2.JPG new file mode 100644 index 00000000..a6febf0e Binary files /dev/null and b/docs/images/lib3x-mz_tiles-2.JPG differ diff --git a/docs/images/lib3x-mz_tiles-3.JPG b/docs/images/lib3x-mz_tiles-3.JPG new file mode 100644 index 00000000..d437c0b8 Binary files /dev/null and b/docs/images/lib3x-mz_tiles-3.JPG differ diff --git a/docs/lib3x-mz_tiles.md b/docs/lib3x-mz_tiles.md new file mode 100644 index 00000000..dc90818a --- /dev/null +++ b/docs/lib3x-mz_tiles.md @@ -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. + +![mz_tiles](images/lib3x-mz_tiles-1.JPG) + +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 + use + use + use + + 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]); + } + } + } + } + +![mz_tiles](images/lib3x-mz_tiles-2.JPG) + +An advanced model. + +[![mz_tiles](images/lib3x-mz_tiles-3.JPG)](https://cults3d.com/en/3d-model/art/maze-city) diff --git a/src/experimental/note.md b/src/experimental/note.md index 25421a07..882ccab4 100644 --- a/src/experimental/note.md +++ b/src/experimental/note.md @@ -6,8 +6,6 @@ new: - triangle/tri_subdivide -- maze/mz_tiles? - - mz_hamiltonian supports init_cells update doc mz_square_initialize @@ -33,6 +31,6 @@ doc-ed new: - util/sorted, util/binary_search, util/contains - - maze/mz_square, maze/mz_theta, maze/mz_squarewalls, maze/mz_hexwalls + - maze/mz_square, maze/mz_theta, maze/mz_squarewalls, maze/mz_hexwalls, maze/mz_tiles - matrix/m_replace