This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'measure-text' { | |
function measureText({ | |
text, | |
fontFamily, | |
fontSize, | |
lineHeight, | |
fontWeight, | |
fontStyle, | |
canvas, | |
}: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken actually from https://github.com/adamwdraper/Numeral-js/blob/master/src/numeral.js#L241 | |
function commatizeMillions(number, lang) { | |
const str = (number).toFixed(0).toString() | |
const separator = lang === ITA ? '.' : ',' | |
const out = str.replace(/(\d)(?=(\d{3})+(?!\d))/g, `$1${separator}`) | |
return out | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: does not handle `URL.revokeObjectURL` | |
function downloadCanvasContent(canvas: HTMLCanvasElement, filename: string) { | |
const link = document.createElement('a') | |
link.href = canvas.toDataURL() | |
link.download = filename | |
link.click() | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logger(strings,...values) { | |
var str = ""; | |
for (let i = 0; i < strings.length; i++) { | |
if (i > 0) { | |
if (values[i-1] && typeof values[i-1] == "object") { | |
if (values[i-1] instanceof Error) { | |
if (values[i-1].stack) { | |
str += values[i-1].stack; | |
continue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { renderOnce, clearDOM } from "@thi.ng/hdom"; | |
import * as svg from "@thi.ng/hiccup-svg"; | |
import * as tx from "@thi.ng/transducers"; | |
import * as isec from "@thi.ng/geom-isec"; | |
import { add2, subN2 } from "@thi.ng/vectors"; | |
import { poissonDiscSampler } from "./poisson-disc-sampler"; | |
const width = 600; | |
const height = 500; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use typescript | |
// use math.js | |
import math from "mathjs"; | |
// a | |
// a1 a2 b c d | |
// (2^n*n!)^(-1/2) * Pi^(-1/4) * Exp[-x^2/2] * HermiteH[n, x]; | |
function psi(n: number, x: number) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as tx from "@thi.ng/transducers"; | |
import { clearDOM } from "@thi.ng/hdom"; | |
import { | |
stream, | |
Stream, | |
sync, | |
fromRAF, | |
sidechainToggle | |
} from "@thi.ng/rstream"; | |
import { updateDOM } from "@thi.ng/transducers-hdom"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { clearDOM } from '@thi.ng/hdom' | |
import { Vec } from '@thi.ng/vectors' | |
import { buildSketch3d } from './sketch-skelton' | |
import { adaptDPI, CanvasHandlers } from '@thi.ng/hdom-components' | |
import { compileModel, draw, ModelSpec, shader, quad } from '@thi.ng/webgl' | |
import { | |
defMain, | |
assign, | |
FLOAT0, | |
FLOAT1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ab2str(buf: any) { | |
return Buffer.from(buf).toString("utf8"); | |
} | |
console.log("hello"); | |
var oReq = new XMLHttpRequest(); | |
console.log(oReq); | |
oReq.addEventListener("load", reqListener); | |
oReq.open("GET", "./test.env"); | |
oReq.responseType = "arraybuffer"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
import { noop } from 'lodash'; | |
/** original code from | |
* https://usehooks.com/useScript/ | |
* https://stackoverflow.com/a/51242436/433685 | |
* */ | |
function isScriptLoaded(src: string) { | |
return document.querySelector('script[src="' + src + '"]') ? true : false; |