diff --git a/art/eca-henry/eca.js b/art/eca-henry/eca.js index 60d7b1227..be29b6eb3 100644 --- a/art/eca-henry/eca.js +++ b/art/eca-henry/eca.js @@ -68,4 +68,4 @@ for (let gen = 0; gen < w * 2; gen++) { drawGen(allGens[gen + 1], -gen) } -drawTurtles(t) +drawTurtles([t]) diff --git a/art/hilbert_golf-henry/index.js b/art/hilbert_golf-henry/index.js index 70aaadd27..2ee35067b 100644 --- a/art/hilbert_golf-henry/index.js +++ b/art/hilbert_golf-henry/index.js @@ -5,4 +5,4 @@ for (let i of eval( try { eval(i == 'F' ? `t.forward(-0.1)` : `t.left(${i}87)`) } catch {} -drawTurtles(t) +drawTurtles([t]) diff --git a/art/landscape-henry/index.js b/art/landscape-henry/index.js index 5addd18f2..25c849828 100644 --- a/art/landscape-henry/index.js +++ b/art/landscape-henry/index.js @@ -1,5 +1,5 @@ const t = new Turtle() -drawTurtles(t) +drawTurtles([t]) const time = 106 const resX = 5.16 diff --git a/art/leaf-leo/index.js b/art/leaf-leo/index.js index 398ea6c93..6b2755c5e 100644 --- a/art/leaf-leo/index.js +++ b/art/leaf-leo/index.js @@ -73,4 +73,4 @@ t.iteratePath(pt => { t.translate([125 / 2, 125 / 2], t.cc) t.scale(17.2) -drawTurtles(t) +drawTurtles([t]) diff --git a/art/raymarching-henry/raymarch.js b/art/raymarching-henry/raymarch.js index 2b08ce732..2f6f22069 100644 --- a/art/raymarching-henry/raymarch.js +++ b/art/raymarching-henry/raymarch.js @@ -263,4 +263,4 @@ world.objects = [ new Plane(new Vec3(0, -3, 0)) ] renderFrame(cam) -drawTurtles(t) +drawTurtles([t]) diff --git a/art/roots-kai/index.js b/art/roots-kai/index.js index 48df0a12b..9b0317084 100644 --- a/art/roots-kai/index.js +++ b/art/roots-kai/index.js @@ -181,4 +181,4 @@ function makeBranch(turtle, length, startingT) { makeBranch(t, 0.1, 0) // Draw turtles array -drawTurtles(...turtles) +drawTurtles([turtles]) diff --git a/art/square-disarray-leo/index.js b/art/square-disarray-leo/index.js index 7a4dd724b..52bf996ab 100644 --- a/art/square-disarray-leo/index.js +++ b/art/square-disarray-leo/index.js @@ -45,4 +45,4 @@ for (let i = 0; i < nWidth; i++) { shapes.scale([0.9, -0.9]) -drawTurtles(shapes) +drawTurtles([shapes]) diff --git a/art/tree-leo/index.js b/art/tree-leo/index.js index 7d14af8d9..d9af821f4 100644 --- a/art/tree-leo/index.js +++ b/art/tree-leo/index.js @@ -84,4 +84,4 @@ for (let i = 0; i < 100000; i++) { randomWalk.rotate(randInRange(-5, 5)).translate([-0.1, -0.6]) -drawTurtles(trunk, randomWalk) +drawTurtles([trunk, randomWalk]) diff --git a/astro/src/components/landing/ThreeDModel.astro b/astro/src/components/landing/ThreeDModel.astro index 22ab17a7b..3dd0ee04b 100644 --- a/astro/src/components/landing/ThreeDModel.astro +++ b/astro/src/components/landing/ThreeDModel.astro @@ -259,7 +259,7 @@ t.iteratePath(pt => { t.translate([125 / 2, 125 / 2], t.cc) t.scale(70) -drawTurtles(t)`) +drawTurtles([t])`) if (testTurtles.length > 1) { const [first, ...rest] = testTurtles diff --git a/astro/src/lib/defaultProgram.js b/astro/src/lib/defaultProgram.js index 9feb758a5..a5280f0fd 100644 --- a/astro/src/lib/defaultProgram.js +++ b/astro/src/lib/defaultProgram.js @@ -18,7 +18,7 @@ testTurtle.translate( testTurtle.cc ); -drawTurtles( +drawTurtles([ testTurtle -); +]); `.trim() diff --git a/astro/src/lib/runTextReturnTurtles.ts b/astro/src/lib/runTextReturnTurtles.ts index e12aa06dd..abbc2c710 100644 --- a/astro/src/lib/runTextReturnTurtles.ts +++ b/astro/src/lib/runTextReturnTurtles.ts @@ -19,8 +19,14 @@ const customGlobal = { lerp(start: number, end: number, t: number) { return (1 - t) * start + t * end }, - drawTurtles: (...turtlesToDraw: Turtle[]) => { - turtlesToDraw.forEach(t => _returnTurtles.push(t)) + drawTurtles: (turtlesToDraw: Turtle[], style = {}) => { + turtlesToDraw.forEach(t => { + const temp = t.copy(); + if (style.fill === undefined) style.fill = "none"; + if (style.stroke === undefined) style.stroke = "black"; + temp.style = style; + turtles.push(temp); + }); }, setDocDimensions(w: number, h: number) {} } diff --git a/docs/TOOLKIT.md b/docs/TOOLKIT.md index 479ea197a..4f467420e 100644 --- a/docs/TOOLKIT.md +++ b/docs/TOOLKIT.md @@ -73,7 +73,7 @@ t.interpolate(tValue) To render a turtle use `drawTurtles` it is variadic (can take multiple turtles as arguments). ```js -drawTurtles(...turtles) +drawTurtles([ turtles ]) ``` You can drag in SVG's, and the interface will generate a turtle for it. Keep in mind that SVG's are often imported far too large, and will need to be scaled and translated. diff --git a/guides/10PRINT.md b/guides/10PRINT.md index 3f6c52186..bef85689e 100644 --- a/guides/10PRINT.md +++ b/guides/10PRINT.md @@ -132,7 +132,7 @@ Each time we're at a new row, start moving horizontally by increasing `x`. At ev And, lastly, let's draw this to the screen! This is done simply by calling the function `drawTurtles` with the turtle we defined at the start. -`drawTurtles(t);` +`drawTurtles([ t ]);` And, you're done! If all went well, you should be seeing something like the below art: diff --git a/guides/10PRINT2.md b/guides/10PRINT2.md index 3cba880d3..81ae606a6 100644 --- a/guides/10PRINT2.md +++ b/guides/10PRINT2.md @@ -59,7 +59,7 @@ Let's start by defining a constant `t`: this will represent our turtle. The turt const t = createTurtle() ``` -Directly below that, write `drawTurtles(t);`. This function makes it so that we can see the turtle's path in the preview window as we add to it. +Directly below that, write `drawTurtles([ t ]);`. This function makes it so that we can see the turtle's path in the preview window as we add to it. Since the original artwork is made up of many diagonal lines, we'll need a function that can draw these. diff --git a/guides/cubic_disarray.md b/guides/cubic_disarray.md index d95c67cc4..7cdf2924f 100644 --- a/guides/cubic_disarray.md +++ b/guides/cubic_disarray.md @@ -14,7 +14,7 @@ We can get started by setting up a turtle, and define some constants: ```js const t = createTurtle() -drawTurtles(t) +drawTurtles([ t ]) const size = 10 const squareSize = 1 diff --git a/guides/eca.md b/guides/eca.md index 5095d5d25..ec31da94c 100644 --- a/guides/eca.md +++ b/guides/eca.md @@ -167,7 +167,7 @@ for (let gen = 0; gen < w; gen++) { drawGen(allGens[gen + 1], gen) } -drawTurtles(t) +drawTurtles([ t ]) ``` Great job! There are plenty of variations on ECAs that you can explore. Here's a few more drawings done with the code, by setting only the center pixel as a one: diff --git a/guides/joydivision.md b/guides/joydivision.md index 97ad58ee6..54e50b182 100644 --- a/guides/joydivision.md +++ b/guides/joydivision.md @@ -14,7 +14,7 @@ Let's give this a shot! First, simply declare a turtle, and draw it's path to th ``` const t = new Turtle(); -drawTurtles(t); +drawTurtles([ t ]); ``` To actually get it to draw something, we can iterate through a grid, drawing horizontal lines: diff --git a/guides/landscape.md b/guides/landscape.md index e2a11ee69..9fece2d28 100644 --- a/guides/landscape.md +++ b/guides/landscape.md @@ -227,5 +227,5 @@ for (let y = 0; y < 15; y += dy) { } } -drawTurtles(t) +drawTurtles([ t ]) ``` diff --git a/guides/leaf.md b/guides/leaf.md index 4fa1a0d75..c239f86ee 100644 --- a/guides/leaf.md +++ b/guides/leaf.md @@ -39,7 +39,7 @@ const edge = createTurtle().forward(leafLength) // render the final leaf like such const leaf = createTurtle().join(edge) -drawTurtles(leaf) +drawTurtles([ leaf ]) ``` @@ -276,7 +276,7 @@ let startPt = trunk.ct; randomWalk.rotate(randInRange(-5, 5)).translate([-0.1, -0.6]); -drawTurtles(randomWalk, trunk); +drawTurtles([ randomWalk, trunk ]); ```