diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nodes/Unzip.tsx | 30 | ||||
| -rw-r--r-- | src/nodes/index.ts | 4 | ||||
| -rw-r--r-- | src/wasm.ts | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/src/nodes/Unzip.tsx b/src/nodes/Unzip.tsx new file mode 100644 index 0000000..ff5832d --- /dev/null +++ b/src/nodes/Unzip.tsx @@ -0,0 +1,30 @@ +import { NodeShell, InputArray, OutputNumber, NodeComponentProps, NodeInfo } from '../node.tsx'; +import { unzip } from '../wasm.ts'; + +export interface UnzipInputs { + data: Float32Array, +} + +export interface UnzipOutputs { + a: Float32Array, + b: Float32Array, +} + +export const Unzip = ({ id, x, y, inputs }: NodeComponentProps<UnzipInputs>) => { + return ( + <NodeShell name="Unzip" id={id} x={x} y={y}> + <OutputNumber name="a" label="Even" /> + <OutputNumber name="b" label="Odd" /> + <InputArray name="data" label="Data" /> + </NodeShell> + ); +}; + +export const UnzipNode: NodeInfo<UnzipInputs, UnzipOutputs> = { + component: Unzip, + func: ({ data }) => { + const out = data ? unzip(data) : null; + return { a: out?.slice(0, out.length/2), b: out?.slice(out.length/2) }; + }, + inputs: { data: null }, +};
\ No newline at end of file diff --git a/src/nodes/index.ts b/src/nodes/index.ts index a5678fa..09310bb 100644 --- a/src/nodes/index.ts +++ b/src/nodes/index.ts @@ -5,9 +5,12 @@ import { ViewerNode } from './Viewer.tsx'; import { FourierNode } from './Fourier.tsx'; import { LinspaceNode } from './Linspace.tsx'; import { IntersperseNode } from './Intersperse.tsx'; +import { UnzipNode } from './Unzip.tsx'; import { MathNode } from './Math.tsx'; import { PlotNode } from './Plot.tsx'; +// TODO: ComplexMath + const nodeRegistry: Record<string, NodeInfo<any>> = { 'Combine XYZ': CombineXYZNode, 'Separate XYZ': SeparateXYZNode, @@ -15,6 +18,7 @@ const nodeRegistry: Record<string, NodeInfo<any>> = { 'Fourier Transform': FourierNode, 'Linspace': LinspaceNode, 'Intersperse': IntersperseNode, + 'Unzip': UnzipNode, 'Math': MathNode, 'Plot': PlotNode, } diff --git a/src/wasm.ts b/src/wasm.ts index 311a088..a62a8fc 100644 --- a/src/wasm.ts +++ b/src/wasm.ts @@ -5,6 +5,7 @@ export const { mathS, mathV, mathSS, mathSV, mathVS, mathVV, linspace, intersperse, + unzip, dft, fft, } = await instantiate(await WebAssembly.compileStreaming(fetch(url)), {});
\ No newline at end of file |
