2020-05-25 13:35:23 +08:00
|
|
|
# footprints2
|
|
|
|
|
|
|
|
Drive a turtle with `["forward", length]` or `["turn", angle]`. This function is intended to use a turtle to imitate freehand drawing.
|
|
|
|
|
|
|
|
**Since:** 2.4
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
- `cmds` : A list of `["forward", length]`s and `["turn", angle]`s.
|
2020-05-25 13:43:44 +08:00
|
|
|
- `start` : Set the start point of the turtle. Default to `[0, 0]`.
|
2020-05-25 13:35:23 +08:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2021-11-18 08:08:50 +08:00
|
|
|
use <polyline_join.scad>;
|
2020-05-25 13:35:23 +08:00
|
|
|
use <turtle/footprints2.scad>;
|
|
|
|
|
|
|
|
function arc_cmds(radius, angle, steps) =
|
|
|
|
let(
|
|
|
|
fa = angle / steps,
|
|
|
|
ta = fa / 2,
|
|
|
|
leng = sin(ta) * radius * 2
|
|
|
|
)
|
2022-02-27 22:32:57 +08:00
|
|
|
[
|
|
|
|
["turn", ta],
|
|
|
|
each [
|
2020-05-25 13:35:23 +08:00
|
|
|
for(i = [0:steps - 2])
|
|
|
|
each [["forward", leng], ["turn", fa]]
|
|
|
|
],
|
2022-02-27 22:32:57 +08:00
|
|
|
["forward", leng],
|
|
|
|
["turn", ta]
|
|
|
|
];
|
2020-05-25 13:35:23 +08:00
|
|
|
|
|
|
|
poly = footprints2(
|
2022-02-27 22:32:57 +08:00
|
|
|
[
|
|
|
|
["forward", 10],
|
|
|
|
["turn", 90],
|
|
|
|
["forward", 10],
|
|
|
|
each arc_cmds(5, 180, 12),
|
|
|
|
["turn", -90],
|
|
|
|
["forward", 10],
|
|
|
|
["turn", 90],
|
|
|
|
["forward", 10],
|
|
|
|
["turn", 90],
|
|
|
|
["forward", 10]
|
|
|
|
]
|
2020-05-25 13:35:23 +08:00
|
|
|
);
|
|
|
|
|
2021-11-18 08:08:50 +08:00
|
|
|
polyline_join(poly)
|
|
|
|
circle(.5);
|
2020-05-25 13:35:23 +08:00
|
|
|
|
2021-02-24 21:09:54 +08:00
|
|
|
![footprints2](images/lib3x-footprints2-1.JPG)
|
2020-05-25 13:35:23 +08:00
|
|
|
|