From 3eb527008a9799a8d84497f09cb77948eba79fc1 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 6 Apr 2025 18:25:54 +1000 Subject: [PATCH 1/2] Made the bot version do bigger cell sizes --- poptimal.js | 21 +++++++++++++-------- src/components/dots.js | 1 - src/index.md | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/poptimal.js b/poptimal.js index 80b7414..01d107f 100644 --- a/poptimal.js +++ b/poptimal.js @@ -17,7 +17,7 @@ import {ColourNamer} from './src/components/colour_namer.js'; const CELL = 10; const MAG = 2; -const WIDTH = 20; +const WIDTH = 200; const HEIGHT = WIDTH; const VISIBLE_DOG = 1000; @@ -33,10 +33,12 @@ function randomise_params() { f: random.choice(RADIUS_OPTS), r: random.float(0, 0.4), }}); + const cell = 5 + random.float() * random.float() * 55; return { background: palette[0], palette: palette_name, - patterns: patterns + patterns: patterns, + cell: cell, } } @@ -109,18 +111,21 @@ function poptimal_svg(params) { const document = window.document; const container = d3.select(document.body).append("div"); - const dm = new DotMaker(WIDTH); + const width = WIDTH / params.cell; + const height = WIDTH / params.cell; + + const dm = new DotMaker(width, height); const svg = container.append("svg") - .attr("width", WIDTH * CELL * MAG) - .attr("height", HEIGHT * CELL * MAG) - .attr("viewBox", [ 0, 0, WIDTH, HEIGHT ]); + .attr("width", WIDTH * MAG) + .attr("height", HEIGHT * MAG) + .attr("viewBox", [ 0, 0, width, height ]); const background = svg.append("rect") .attr("x", 0) .attr("y", 0) - .attr("width", WIDTH) - .attr("height", WIDTH) + .attr("width", width) + .attr("height", height) .attr("fill", params.background); diff --git a/src/components/dots.js b/src/components/dots.js index b34cd15..3b061b3 100644 --- a/src/components/dots.js +++ b/src/components/dots.js @@ -45,7 +45,6 @@ function int_range(v1, v2) { class DotMaker { constructor(width, height) { - console.log(width, height); this.width = width; this.height = height; this.wh = 0.5 * (width + height); diff --git a/src/index.md b/src/index.md index 1dd835c..16add7a 100644 --- a/src/index.md +++ b/src/index.md @@ -144,8 +144,8 @@ const dots2 = dm.dots(1 / m2, n2, false); const svg = d3.create("svg") - .attr("width", width * cell * MAG) - .attr("height", height * cell * MAG) + .attr("width", WIDTH * MAG) + .attr("height", HEIGHT * MAG) .attr("viewBox", [ 0, 0, width, height ]); From ca10f8a0381e526afcda3ef6f6cc868f3c18994a Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 6 Apr 2025 23:03:48 +0000 Subject: [PATCH 2/2] Saves alt text to the image params --- poptimal.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/poptimal.js b/poptimal.js index aefa4bc..44b3dbf 100644 --- a/poptimal.js +++ b/poptimal.js @@ -232,7 +232,6 @@ async function main() { const colourf = params.palette === 'grayscale' ? cf['grayscale'] : cf['colour']; const namer = new ColourNamer(); - console.log(`Loading colours ${colourf}`); await namer.load_colours(colourf); @@ -255,7 +254,7 @@ async function main() { // so we don't include obscured colours const hist = await get_histogram(imgfile); const alt_text = image_description(namer, params, hist); - + params.alt_text = alt_text; await save_params(paramsfile, params); console.log(alt_text); console.log(imgfile);