Fix typescript build errors
This commit is contained in:
parent
e66f784344
commit
c9f38a09cc
1 changed files with 12 additions and 13 deletions
25
src/main.ts
25
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 { $canvas } from "@thi.ng/rdom-canvas";
|
||||||
import { reactive, sync, } from "@thi.ng/rstream";
|
import { reactive, sync, } from "@thi.ng/rstream";
|
||||||
import { $compile, $input } from '@thi.ng/rdom'
|
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 cellSize_ = "12"
|
||||||
const xs_ = "101110100101100"
|
const xs_ = "101110100101100"
|
||||||
|
|
@ -21,10 +21,6 @@ const cellSize = reactive(cellSize_).map(num => {
|
||||||
const width = 420
|
const width = 420
|
||||||
const height = 594
|
const height = 594
|
||||||
|
|
||||||
// calculate available drawing area
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const size = [width, height]
|
const size = [width, height]
|
||||||
|
|
||||||
// build a list of start positions
|
// build a list of start positions
|
||||||
|
|
@ -37,7 +33,7 @@ const startPoints = (pattern: Iterable<number>, cellSize: number, maxCoord: numb
|
||||||
),
|
),
|
||||||
push(),
|
push(),
|
||||||
cycle(pattern)
|
cycle(pattern)
|
||||||
)
|
) as (readonly [number, number])[]
|
||||||
|
|
||||||
const scene = sync({
|
const scene = sync({
|
||||||
src: { cellSize, xs, ys, }
|
src: { cellSize, xs, ys, }
|
||||||
|
|
@ -46,6 +42,7 @@ const scene = sync({
|
||||||
|
|
||||||
const minPadding = cellSize
|
const minPadding = cellSize
|
||||||
|
|
||||||
|
// calculate available drawing area
|
||||||
const xCells = Math.floor((width - 2 * minPadding) / cellSize)
|
const xCells = Math.floor((width - 2 * minPadding) / cellSize)
|
||||||
const xPadding = (width - (xCells * cellSize)) / 2
|
const xPadding = (width - (xCells * cellSize)) / 2
|
||||||
|
|
||||||
|
|
@ -56,35 +53,37 @@ const scene = sync({
|
||||||
const yStarts = startPoints(ys, cellSize, height - 2 * yPadding)
|
const yStarts = startPoints(ys, cellSize, height - 2 * yPadding)
|
||||||
|
|
||||||
const yLines = xStarts.flatMap(
|
const yLines = xStarts.flatMap(
|
||||||
([xCoord, val]: [number, number]) =>
|
([xCoord, seed]) =>
|
||||||
Array
|
Array
|
||||||
.from({ length: yCells })
|
.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])
|
? line([xCoord, cell * cellSize], [xCoord, (cell + 1) * cellSize])
|
||||||
: null)
|
: null)
|
||||||
.filter(v => v != null)
|
.filter(v => v != null)
|
||||||
)
|
)
|
||||||
|
|
||||||
const xLines = yStarts.flatMap(
|
const xLines = yStarts.flatMap(
|
||||||
([yCoord, val]: [number, number]) =>
|
([yCoord, seed]) =>
|
||||||
Array
|
Array
|
||||||
.from({ length: xCells })
|
.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])
|
? line([cell * cellSize, yCoord], [(cell + 1) * cellSize, yCoord])
|
||||||
: null)
|
: null)
|
||||||
.filter(v => v != null)
|
.filter(v => v != null)
|
||||||
)
|
)
|
||||||
|
|
||||||
return translate(
|
const scene = translate(
|
||||||
group(
|
group(
|
||||||
{ __background: '#eee', stroke: '#222' },
|
{ __background: '#eee', stroke: '#222' },
|
||||||
[...yLines, ...xLines]
|
[...yLines, ...xLines]
|
||||||
),
|
),
|
||||||
[xPadding, yPadding]
|
[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(
|
$compile(
|
||||||
["main",
|
["main",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue