doc tweaks

This commit is contained in:
Adrian Mariano 2023-02-03 23:37:24 -05:00
parent 6d46c2ce5b
commit bf7218d56f

View file

@ -29,15 +29,15 @@
// Two workarounds exist, neither of which are needed in newer versions of OpenSCAD. The workarounds solve the problem because // Two workarounds exist, neither of which are needed in newer versions of OpenSCAD. The workarounds solve the problem because
// **modules** execute after their parent, so the `$` variables **are** available in modules. You can put your assignments // **modules** execute after their parent, so the `$` variables **are** available in modules. You can put your assignments
// in a `let()` module, or you can wrap your child in a `union()`. Both methods appear below. // in a `let()` module, or you can wrap your child in a `union()`. Both methods appear below.
// ``` // Figure(2D,NoScales): This example shows how we can use `$idx` to produce **different** geometry at each index.
// xcopies(n=10, spacing=10)
// text(str($idx));
// ```
// Figure(2D): This example shows how we can use `$idx` to produce **different** geometry at each index.
// xcopies(n=10, spacing=10) // xcopies(n=10, spacing=10)
// text(str($idx)); // text(str($idx));
// Continues: // Continues:
// Figure(2D): Here the children are sometimes squares and sometimes circles as determined by the conditional `if` module. This use of `if` is OK because no variables are assigned. // ```
// xcopies(n=10, spacing=10)
// text(str($idx));
// ```
// Figure(2D,NoScales): Here the children are sometimes squares and sometimes circles as determined by the conditional `if` module. This use of `if` is OK because no variables are assigned.
// xcopies(n=4, spacing=10) // xcopies(n=4, spacing=10)
// if($idx%2==0) circle(r=3,$fn=16); // if($idx%2==0) circle(r=3,$fn=16);
// else rect(6); // else rect(6);
@ -47,7 +47,7 @@
// if($idx%2==0) circle(r=3,$fn=16); // if($idx%2==0) circle(r=3,$fn=16);
// else rect(6); // else rect(6);
// ``` // ```
// Figure(2D): Suppose we would like to color odd and even index copies differently. In this example we compute the color for a given child from `$idx` using the ternary operator. The `let()` module is a module that sets variables and makes them available to its children. Note that multiple assignments in `let()` are separated by commas, not semicolons. // Figure(2D,NoScales): Suppose we would like to color odd and even index copies differently. In this example we compute the color for a given child from `$idx` using the ternary operator. The `let()` module is a module that sets variables and makes them available to its children. Note that multiple assignments in `let()` are separated by commas, not semicolons.
// xcopies(n=6, spacing=10){ // xcopies(n=6, spacing=10){
// let(c = $idx % 2 == 0 ? "red" : "green") // let(c = $idx % 2 == 0 ? "red" : "green")
// color(c) rect(6); // color(c) rect(6);
@ -59,7 +59,7 @@
// color(c) rect(6); // color(c) rect(6);
// } // }
// ``` // ```
// Figure(2D): This example shows how you can change the position of children adaptively. If you want to avoid repeating your code for each case, this requires storing a transformation matrix in a variable and then applying it using `multmatrix()`. We wrap our code in `union()` to ensure that it works in OpenSCAD 2021.01. // Figure(2D,NoScales): This example shows how you can change the position of children adaptively. If you want to avoid repeating your code for each case, this requires storing a transformation matrix in a variable and then applying it using `multmatrix()`. We wrap our code in `union()` to ensure that it works in OpenSCAD 2021.01.
// xcopies(n=5,spacing=10) // xcopies(n=5,spacing=10)
// union() // union()
// { // {
@ -72,9 +72,9 @@
// xcopies(n=5,spacing=10) // xcopies(n=5,spacing=10)
// union() // union()
// { // {
// shiftback = $idx%2==0 ? back(5) : IDENT; // shiftback = $idx%2==0 ? back(10) : IDENT;
// spin = zrot(180*$idx/4); // spin = zrot(180*$idx/4);
// multmatrix(shiftback*spin) stroke([[-4,0],[4,0]],endcap2="arrow2",width=1/2); // multmatrix(shiftback*spin) stroke([[-4,0],[4,0]],endcap2="arrow2",width=3/4,color="red");
// } // }
// ``` // ```
@ -473,20 +473,20 @@ function zcopies(spacing, n, l, sp, p=_NO_ARG) =
// See Also: move_copies(), xcopies(), ycopies(), zcopies(), line_copies(), rot_copies(), xrot_copies(), yrot_copies(), zrot_copies(), arc_copies(), sphere_copies() // See Also: move_copies(), xcopies(), ycopies(), zcopies(), line_copies(), rot_copies(), xrot_copies(), yrot_copies(), zrot_copies(), arc_copies(), sphere_copies()
// //
// Examples: // Examples:
// line_copies(10) sphere(d=1); // line_copies(10) sphere(d=1.5);
// line_copies(10, n=5) sphere(d=1); // line_copies(10, n=5) sphere(d=3);
// line_copies([10,5], n=5) sphere(d=1); // line_copies([10,5], n=5) sphere(d=3);
// line_copies(spacing=10, n=6) sphere(d=1); // line_copies(spacing=10, n=6) sphere(d=3);
// line_copies(spacing=[10,5], n=6) sphere(d=1); // line_copies(spacing=[10,5], n=6) sphere(d=3);
// line_copies(spacing=10, l=50) sphere(d=1); // line_copies(spacing=10, l=50) sphere(d=3);
// line_copies(spacing=10, l=[50,30]) sphere(d=1); // line_copies(spacing=10, l=[50,30]) sphere(d=3);
// line_copies(spacing=[10,5], l=50) sphere(d=1); // line_copies(spacing=[10,5], l=50) sphere(d=3);
// line_copies(l=50, n=4) sphere(d=1); // line_copies(l=50, n=4) sphere(d=3);
// line_copies(l=[50,-30], n=4) sphere(d=1); // line_copies(l=[50,-30], n=4) sphere(d=3);
// Example(FlatSpin,VPD=133): // Example(FlatSpin,VPD=133):
// line_copies(p1=[0,0,0], p2=[5,5,20], n=6) cube(size=[3,2,1],center=true); // line_copies(p1=[0,0,0], p2=[5,5,20], n=6) cuboid([3,2,1]);
// Example(FlatSpin,VPD=133): // Example(FlatSpin,VPD=133):
// line_copies(p1=[0,0,0], p2=[5,5,20], spacing=6) cube(size=[3,2,1],center=true); // line_copies(p1=[0,0,0], p2=[5,5,20], spacing=6) cuboid([3,2,1]);
// Example: All children are copied to each position // Example: All children are copied to each position
// line_copies(l=20, n=3) { // line_copies(l=20, n=3) {
// cube(size=[1,3,1],center=true); // cube(size=[1,3,1],center=true);
@ -494,10 +494,10 @@ function zcopies(spacing, n, l, sp, p=_NO_ARG) =
// } // }
// Example(2D): The functional form of line_copies() returns a list of transform matrices. // Example(2D): The functional form of line_copies() returns a list of transform matrices.
// mats = line_copies([10,5],n=5); // mats = line_copies([10,5],n=5);
// for (m = mats) multmatrix(m) circle(d=2); // for (m = mats) multmatrix(m) circle(d=3);
// Example(2D): The functional form of line_copies() returns a list of points if given a point. // Example(2D): The functional form of line_copies() returns a list of points if given a point.
// pts = line_copies([10,5],n=5,p=[0,0,0]); // pts = line_copies([10,5],n=5,p=[0,0,0]);
// move_copies(pts) circle(d=2); // move_copies(pts) circle(d=3);
module line_of(spacing, n, l, p1, p2) { module line_of(spacing, n, l, p1, p2) {
deprecate("line_copies"); deprecate("line_copies");