Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Oct 19, 2023
1 parent 03814da commit 5b01f55
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion art/hilbert_golf-henry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ for (let i of eval(
eval(i == 'F' ? `t.forward(-0.1)` : `t.left(${i}87)`)
} catch {}

t.scale(125/t.width);
t.scale(110/t.width);
t.translate([125/2, 125/2], t.cc);
drawTurtles([t])
5 changes: 4 additions & 1 deletion guides/cubic_disarray.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ We can get started by setting up a turtle, and define some constants:

```js
const t = createTurtle()
drawTurtles([ t ])

const size = 10
const squareSize = 1

// ... other code goes here ...

drawTurtles([ t ])
```

Obviously we'll need a way to draw these rotated squares, so let's define a function for that:
Expand Down
14 changes: 7 additions & 7 deletions guides/joydivision.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ First, let's start by noticing what we see in the image. It seems to be composed

Let's give this a shot! First, simply declare a turtle, and draw it's path to the screen:

```
```js
const t = new Turtle();
drawTurtles([ t ]);
```

To actually get it to draw something, we can iterate through a grid, drawing horizontal lines:

```
```js
const height = 13;
const lineWidth = 10;
const lineSpacing = 0.2;
Expand All @@ -43,7 +43,7 @@ You should now be seeing a bunch of straight horizontal lines. Let's add some ra

A first attempt may look something like this:

```
```js
let height = Math.random();
```

Expand All @@ -53,7 +53,7 @@ We can call this in the Haxidraw editor with `noise([x, y], {octaves:n, falloff:

We don't want pure smooth noise, and we'll instead want to modify how we sample it a bit. Set `height` equal to `line + sampleNoise(x, line)`, and define that function:

```
```js
const baseNoiseHorizontalScale = 1.5;
const baseNoiseVerticalScale = 10;
const baseNoiseAmp = 0.1;
Expand Down Expand Up @@ -81,7 +81,7 @@ We define a few constants to dictate how vertically and horizontally stretched b

Notice that when defining the base noise, we use a function `distFromCenter`. We'll have to define this as such:

```
```js
function distFromCenter(x) {
return lineWidth/2 - Math.abs(x)
}
Expand All @@ -97,13 +97,13 @@ This looks close to the final product, but there's still one big thing that it's

Create the array, and fill it with zeroes:

```
```js
let maxHeights = new Array(lineWidth / dx);
```

Above the line `if (x == -lineWidth/2) t.up();` in our main loop, add the following logic doing what we outlined earlier:

```
```js
let maxHeightsIndex = Math.floor((x + lineWidth/2) / dx)
if (height > maxHeights[maxHeightsIndex]) {
t.down()
Expand Down
8 changes: 4 additions & 4 deletions guides/mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Next, let's define a scale for the whole image:

Then, we can create a grid. This is identical to a typical rectangular grid, except we offset every other line by a bit, making it triangular.

```
```js
var line, dot,
odd = false,
lines = [],
Expand All @@ -41,7 +41,7 @@ for(var y = gap / 2; y <= size; y+= gap) {
Then, use the built-in haxidraw noise function to offset the points again, this time randomly. Also, add an offset on the x axis if we're drawing an odd-numbered line.
```
```js
let n = noise([x * 0.1, y * 0.1])
line.push({
x: x + (n*4.1 - .4) * gap + (odd ? gap/2 : 0),
Expand All @@ -54,7 +54,7 @@ Then, use the built-in haxidraw noise function to offset the points again, this

Now, we need a way to draw this. We can define a simple function to render a triange, where we simply go through every point of the triangle with the turtle `goTo` function.

```
```js
function drawTriangle(pointA, pointB, pointC) {
t.goTo([pointA.x, pointA.y]);
t.down()
Expand All @@ -67,7 +67,7 @@ function drawTriangle(pointA, pointB, pointC) {

Now, to draw the whole mesh, we can iterate through the points, drawing triangles at every 3 points next to each other in 2D.

```
```js
var dotLine;
odd = true;

Expand Down
2 changes: 1 addition & 1 deletion guides/roots.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ We can first start by drawing a simple random walk, where during each step we (r
const WIDTH = 10
const HEIGHT = 20

const t = new Turtle([WIDTH / 2, 0])
const t = createTurtle([WIDTH / 2, 0])
t.right(90)

const turtles = [t]
Expand Down

1 comment on commit 5b01f55

@vercel
Copy link

@vercel vercel bot commented on 5b01f55 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blot – ./astro

blot.hackclub.dev
blot-git-main.hackclub.dev

Please sign in to comment.