Fixed docs spelling. Standardized formatting.

This commit is contained in:
Revar Desmera 2019-08-31 23:13:25 -07:00
parent 1d449ef8a6
commit 207721012f

View File

@ -580,7 +580,7 @@ function star(n, r, d, or, od, ir, id, step, realign=false, anchor=CENTER, spin=
count = num_defined([ir,id,step]), count = num_defined([ir,id,step]),
stepOK = is_undef(step) || (step>1 && step<n/2) stepOK = is_undef(step) || (step>1 && step<n/2)
) )
assert(is_def(n), "Must specify number of points, n") assert(is_def(n), "Must specify number of points, n")
assert(count==1, "Must specify exactly one of ir, id, step") assert(count==1, "Must specify exactly one of ir, id, step")
assert(stepOK, str("Parameter 'step' must be between 2 and ",floor(n/2)," for ",n," point star")) assert(stepOK, str("Parameter 'step' must be between 2 and ",floor(n/2)," for ",n," point star"))
let( let(
@ -688,7 +688,7 @@ module supershape(step=0.5,m1=4,m2=undef,n1,n2=undef,n3=undef,a=1,b=undef, r=und
// - "length", length: Change the turtle move distance to `length` // - "length", length: Change the turtle move distance to `length`
// - "scale", factor: Multiply turtle move distance by `factor` // - "scale", factor: Multiply turtle move distance by `factor`
// - "addlength", length: Add `length` to the turtle move distance // - "addlength", length: Add `length` to the turtle move distance
// - "repeat", count, comands: Repeats a list of commands `count` times. // - "repeat", count, commands: Repeats a list of commands `count` times.
// - "arcleft", radius, [angle]: Draw an arc from the current position toward the left at the specified radius and angle // - "arcleft", radius, [angle]: Draw an arc from the current position toward the left at the specified radius and angle
// - "arcright", radius, [angle]: Draw an arc from the current position toward the right at the specified radius and angle // - "arcright", radius, [angle]: Draw an arc from the current position toward the right at the specified radius and angle
// //
@ -778,10 +778,10 @@ function _turtle_repeat(commands, state, full_state, repeat) =
_turtle_repeat(commands, _turtle(commands, state, true), full_state, repeat-1); _turtle_repeat(commands, _turtle(commands, state, true), full_state, repeat-1);
function _turtle_command_len(commands, index) = function _turtle_command_len(commands, index) =
let( one_or_two_arg = ["arcleft","arcright"] ) let( one_or_two_arg = ["arcleft","arcright"] )
commands[index] == "repeat"? 3 : // Repeat command requires 2 args commands[index] == "repeat"? 3 : // Repeat command requires 2 args
// For these, the first arg is required, second arg is present if it is not a string // For these, the first arg is required, second arg is present if it is not a string
in_list(commands[index], one_or_two_arg) && len(commands)>index+2 && !is_string(commands[index+2]) ? 3 : in_list(commands[index], one_or_two_arg) && len(commands)>index+2 && !is_string(commands[index+2]) ? 3 :
is_string(commands[index+1])? 1 : // If 2nd item is a string it's must be a new command is_string(commands[index+1])? 1 : // If 2nd item is a string it's must be a new command
2; // Otherwise we have command and arg 2; // Otherwise we have command and arg
@ -806,7 +806,7 @@ function _turtle_command(command, parm, parm2, state, index) =
step=1, step=1,
angle=2, angle=2,
parm = !is_string(parm) ? parm : undef, parm = !is_string(parm) ? parm : undef,
parm2 = !is_string(parm2) ? parm2 : undef, parm2 = !is_string(parm2) ? parm2 : undef,
needvec = ["jump"], needvec = ["jump"],
neednum = ["untilx","untily","xjump","yjump","angle","length","scale","addlength"], neednum = ["untilx","untily","xjump","yjump","angle","length","scale","addlength"],
needeither = ["setdir"], needeither = ["setdir"],
@ -853,18 +853,27 @@ function _turtle_command(command, parm, parm2, state, index) =
command=="length" ? list_set(state, step, parm*normalize(state[step])) : command=="length" ? list_set(state, step, parm*normalize(state[step])) :
command=="scale" ? list_set(state, step, parm*state[step]) : command=="scale" ? list_set(state, step, parm*state[step]) :
command=="addlength" ? list_set(state, step, state[step]+normalize(state[step])*parm) : command=="addlength" ? list_set(state, step, state[step]+normalize(state[step])*parm) :
command=="arcleft" || command=="arcright" ? command=="arcleft" || command=="arcright" ?
let( myangle = default(parm2,state[angle]), let(
lrsign = command=="arcleft" ? 1 : -1, myangle = default(parm2,state[angle]),
radius = parm, lrsign = command=="arcleft" ? 1 : -1,
center = lastpt + lrsign*radius*line_normal([0,0],state[step]), radius = parm,
arcpath = myangle == 0 ? [] : center = lastpt + lrsign*radius*line_normal([0,0],state[step]),
arc(segs(radius), points = [lastpt, rot(cp=center, p=lastpt, a=lrsign*myangle/2), arcpath = myangle == 0 ? [] : arc(
rot(cp=center, p=lastpt, a=lrsign*myangle)]) segs(radius),
) points = [
list_set(state, [path,step], lastpt,
[ concat(state[path],slice(arcpath,1,-1)), rot(cp=center, p=lastpt, a=lrsign*myangle/2),
rot(lrsign * myangle,p=state[step],planar=true) ]) : rot(cp=center, p=lastpt, a=lrsign*myangle)
]
)
)
list_set(
state, [path,step], [
concat(state[path], slice(arcpath,1,-1)),
rot(lrsign * myangle,p=state[step],planar=true)
]
) :
assert(false,str("Unknown turtle command \"",command,"\" at index",index)) assert(false,str("Unknown turtle command \"",command,"\" at index",index))
[]; [];