Fix typescript build errors

This commit is contained in:
arne 2024-07-19 00:32:15 +02:00
commit c9f38a09cc

View file

@ -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<number>, 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",