Skip to content

Commit

Permalink
cleaned up gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Oct 19, 2023
1 parent 2d04ce7 commit 03814da
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 1,154 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ astro/.astro/types.d.ts
.vercel
*/node_modules
astro/.env
.env
7 changes: 5 additions & 2 deletions art/eca-henry/eca.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const t = new Turtle()
const t = createTurtle();

const w = 50

Expand Down Expand Up @@ -68,4 +68,7 @@ for (let gen = 0; gen < w * 2; gen++) {
drawGen(allGens[gen + 1], -gen)
}

drawTurtles([t])
t.scale(110/t.height);
t.translate([125/2, 125/2], t.cc);

drawTurtles([t]);
5 changes: 4 additions & 1 deletion art/hilbert_golf-henry/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
let t = new Turtle([7, -6])
let t = createTurtle([7, -7])
for (let i of eval(
`'A'` + `.replace(/[AB]/g,c=>c=='A'?'-BF+AFA+FB-':'+AF-BFB-FA+')`.repeat(5)
))
try {
eval(i == 'F' ? `t.forward(-0.1)` : `t.left(${i}87)`)
} catch {}

t.scale(125/t.width);
t.translate([125/2, 125/2], t.cc);
drawTurtles([t])
10 changes: 8 additions & 2 deletions art/landscape-henry/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const t = new Turtle()
drawTurtles([t])
const t = createTurtle();

const time = 106

const resX = 5.16
Expand Down Expand Up @@ -84,3 +84,9 @@ function drawLandscape() {
}

drawLandscape()

t.scale(125/t.width);
t.translate([125/2, 0], t.cb);

drawTurtles([t])

2 changes: 1 addition & 1 deletion art/raymarching-henry/raymarch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const screenHeight = 2
const dx = 0.01
const dy = 0.01

const t = new Turtle()
const t = createTurtle()

class Vec3 {
constructor(x, y, z) {
Expand Down
14 changes: 10 additions & 4 deletions art/roots-kai/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const WIDTH = 10
const HEIGHT = 20

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

// Manage array of turtles that need to be drawn
Expand Down Expand Up @@ -88,7 +88,7 @@ function thicken(turtle, startingTime) {
const deltaX = rightPoint[0] - leftPoint[0]
const deltaY = rightPoint[1] - leftPoint[1]

const ring = new Turtle(leftPoint)
const ring = createTurtle(leftPoint)
.setAngle((Math.atan2(deltaY, deltaX) / Math.PI) * 180)
.forward(Math.sqrt(deltaX * deltaX + deltaY * deltaY)) // Straight line from left to right
.resample(0.01) // Resample so we can modulate individual points
Expand Down Expand Up @@ -162,7 +162,7 @@ function makeBranch(turtle, length, startingT) {
pt[0] += parentThickness * Math.cos(curAngleRad - a)
pt[1] += parentThickness * Math.sin(curAngleRad - a)

const newBranch = new Turtle(pt)
const newBranch = createTurtle(pt)
newBranch.setAngle(curAngleDeg)

newBranch.right(a)
Expand All @@ -180,5 +180,11 @@ function makeBranch(turtle, length, startingT) {
// Make initial branch
makeBranch(t, 0.1, 0)

// Center piece
const final = createTurtle();
turtles.forEach(t => final.join(t));
final.scale(115/final.height)
final.translate([125/2, 125/2], final.cc)

// Draw turtles array
drawTurtles([turtles])
drawTurtles([ final ])
6 changes: 5 additions & 1 deletion art/tree-leo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ for (let i = 0; i < 100000; i++) {

randomWalk.rotate(randInRange(-5, 5)).translate([-0.1, -0.6])

drawTurtles([trunk, randomWalk])
const final = [trunk, randomWalk].reduce((acc, cur) => acc.join(cur), createTurtle());
final.scale(110/final.height);
final.translate([125/2, 0], final.cb);

drawTurtles([final]);
22 changes: 12 additions & 10 deletions astro/src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ function DownloadSVG() {
const paths = turtles.map(turtleToPath)

const svg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${
docDimensions.width
} ${docDimensions.height}" width="${
docDimensions.width
}mm" height="${docDimensions.height}mm">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 ${docDimensions.width} ${docDimensions.height}"
width="${docDimensions.width}mm"
height="${docDimensions.height}mm"
style="transform: scale(1, -1)">
${paths.join('\n')}
</svg>
`
Expand Down Expand Up @@ -239,11 +240,12 @@ function DownloadPNG() {
const paths = turtles.map(turtleToPath)

const svg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${
docDimensions.width
} ${docDimensions.height}" width="${
docDimensions.width
}mm" height="${docDimensions.height}mm">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 ${docDimensions.width} ${docDimensions.height}"
width="${docDimensions.width}mm"
height="${docDimensions.height}mm"
style="transform: scale(1, -1)">
${paths.join('\n')}
</svg>
`
Expand Down
1 change: 0 additions & 1 deletion astro/src/components/landing/ThreeDModel.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import { MTLLoader } from 'three/addons/loaders/MTLLoader.js'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
import * as THREE from 'three'
import { turtles } from '../../lib/paths.js'
import { runTextReturnTurtles } from '../../lib/runTextReturnTurtles.ts'

window.onload = () => {
Expand Down
Loading

1 comment on commit 03814da

@vercel
Copy link

@vercel vercel bot commented on 03814da 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.