updates updates updates updates updates updates better updates array of updates updates updates updates Signed-off-by: Jess Frazelle <github@jessfraz.com>
38 KiB
38 KiB
title, excerpt, layout
title | excerpt | layout |
---|---|---|
arrayReduce | Take a starting value. Then, for each element of an array, calculate the next value, | manual |
Take a starting value. Then, for each element of an array, calculate the next value,
using the previous value and the element.
arrayReduce(array: [u64], start: Sketch, reduce_fn: FunctionParam) -> Sketch
Arguments
Name | Type | Description | Required |
---|---|---|---|
array |
[u64] |
Yes | |
start |
Sketch |
A sketch is a collection of paths. | Yes |
reduce_fn |
FunctionParam |
Yes |
Returns
Sketch
- A sketch is a collection of paths.
Examples
fn decagon = (radius) => {
let step = 1 / 10 * tau()
let sketch001 = startSketchAt([cos(0) * radius, sin(0) * radius])
return arrayReduce([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], sketch001, (i, sg) => {
let x = cos(step * i) * radius
let y = sin(step * i) * radius
return lineTo([x, y], sg)
})
}
decagon(5.0)
|> close(%)