1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-09-02 19:22:48 +02:00

added along_with

This commit is contained in:
Justin Lin
2017-04-23 11:16:34 +08:00
parent 87d39af9f6
commit cac51e8168
5 changed files with 69 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ Some modules may depend on other modules. For example, the `polyline2d` module d
- [function_grapher](https://openhome.cc/eGossip/OpenSCAD/lib-function_grapher.html) - [function_grapher](https://openhome.cc/eGossip/OpenSCAD/lib-function_grapher.html)
- Transformation - Transformation
- [along_with](https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html)
- [hollow_out](https://openhome.cc/eGossip/OpenSCAD/lib-hollow_out.html) - [hollow_out](https://openhome.cc/eGossip/OpenSCAD/lib-hollow_out.html)
- [bend](https://openhome.cc/eGossip/OpenSCAD/lib-bend.html) - [bend](https://openhome.cc/eGossip/OpenSCAD/lib-bend.html)

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

42
docs/lib-along_with.md Normal file
View File

@@ -0,0 +1,42 @@
# along_with
Puts children along the given path. If there's only one child, it will put the child for each point.
## Parameters
- `points` : The points along the path.
## Examples
include <along_with.scad>;
include <circle_path.scad>;
$fn = 24;
points = circle_path(radius = 50);
along_with(points)
sphere(5, center = true);
![along_with](images/lib-along_with-1.JPG)
include <along_with.scad>;
include <circle_path.scad>;
$fn = 24;
points = circle_path(radius = 50);
along_with(points) {
linear_extrude(10) text("A", valign = "center", halign = "center");
linear_extrude(5) circle(2);
sphere(1);
cube(5);
linear_extrude(10) text("A", valign = "center", halign = "center");
linear_extrude(5) circle(2);
sphere(1);
cube(5);
}
![along_with](images/lib-along_with-2.JPG)

26
src/along_with.scad Normal file
View File

@@ -0,0 +1,26 @@
/**
* along_with.scad
*
* Puts children along the given path. If there's only one child,
* it will put the child for each point.
*
* @copyright Justin Lin, 2017
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html
*
**/
module along_with(points) {
if($children == 1) {
for(i = [0:len(points) - 1]) {
translate(points[i])
children(0);
}
} else {
for(i = [0:min(len(points), $children) - 1]) {
translate(points[i])
children(i);
}
}
}