From c9f38a09ccd1d69aab298847d94b74394703eaf4 Mon Sep 17 00:00:00 2001 From: arne Date: Fri, 19 Jul 2024 00:32:15 +0200 Subject: [PATCH] Fix typescript build errors --- src/main.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main.ts b/src/main.ts index 2a671af..b6d85f1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import { line, group, translate, asSvg, svgDoc } from "@thi.ng/geom"; import { $canvas } from "@thi.ng/rdom-canvas"; import { reactive, sync, } from "@thi.ng/rstream"; import { $compile, $input } from '@thi.ng/rdom' -import { cycle, takeWhile, comp, mapIndexed, transduce, push, trace } from "@thi.ng/transducers" +import { cycle, takeWhile, comp, mapIndexed, transduce, push } from "@thi.ng/transducers" const cellSize_ = "12" const xs_ = "101110100101100" @@ -21,10 +21,6 @@ const cellSize = reactive(cellSize_).map(num => { const width = 420 const height = 594 -// calculate available drawing area - - - const size = [width, height] // build a list of start positions @@ -37,7 +33,7 @@ const startPoints = (pattern: Iterable, cellSize: number, maxCoord: numb ), push(), cycle(pattern) - ) + ) as (readonly [number, number])[] const scene = sync({ src: { cellSize, xs, ys, } @@ -46,6 +42,7 @@ const scene = sync({ const minPadding = cellSize + // calculate available drawing area const xCells = Math.floor((width - 2 * minPadding) / cellSize) const xPadding = (width - (xCells * cellSize)) / 2 @@ -56,35 +53,37 @@ const scene = sync({ const yStarts = startPoints(ys, cellSize, height - 2 * yPadding) const yLines = xStarts.flatMap( - ([xCoord, val]: [number, number]) => + ([xCoord, seed]) => Array .from({ length: yCells }) - .map((_, cell) => (cell + val) % 2 === 0 // start at the beginning or skip it + .map((_, cell) => (cell + seed) % 2 === 0 // start at the beginning or skip it ? line([xCoord, cell * cellSize], [xCoord, (cell + 1) * cellSize]) : null) .filter(v => v != null) ) const xLines = yStarts.flatMap( - ([yCoord, val]: [number, number]) => + ([yCoord, seed]) => Array .from({ length: xCells }) - .map((_, cell) => (cell + val) % 2 === 0 // start at the beginning or skip it + .map((_, cell) => (cell + seed) % 2 === 0 // start at the beginning or skip it ? line([cell * cellSize, yCoord], [(cell + 1) * cellSize, yCoord]) : null) .filter(v => v != null) ) - return translate( + const scene = translate( group( { __background: '#eee', stroke: '#222' }, [...yLines, ...xLines] ), [xPadding, yPadding] ) -}) -scene.map(scene => asSvg(svgDoc({ viewBox: `0 0 ${size[0]} ${size[1]}` }, scene))).subscribe(trace("svg")) + console.log(asSvg(svgDoc({ viewBox: `0 0 ${size[0]} ${size[1]}` }, scene))) + + return scene +}) $compile( ["main",