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 numpy as np | |
def cube_geometry(x, y, z): | |
xSize = x / 2 | |
ySize = y / 2 | |
zSize = z / 2 | |
positions = np.array([ | |
[-xSize, ySize, zSize], [xSize, ySize, zSize], | |
[-xSize, -ySize, zSize], [xSize, -ySize, zSize], |
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 circlePath(cx=0, cy=0, r=10) { | |
// https://stackoverflow.com/a/10477334/433685 | |
const startPointX = - r | |
const startPointY = 0 | |
return `M ${cx} ${cy} | |
m ${startPointX}, ${startPointY} | |
a ${r},${r} 0 1,0 ${(r * 2)},0 |
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
#!/usr/bin/env python3 | |
from io import BytesIO | |
import numpy as np | |
import numpy.linalg as linalg | |
import scipy.interpolate as interpolate | |
from PIL import Image | |
from flask import Flask, send_file, escape, request | |
app = Flask(__name__) |
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 { Type, typedArray } from '@thi.ng/api' | |
import { MemPool } from '@thi.ng/malloc' | |
import { Vec } from '@thi.ng/vectors' | |
import { computeNewData } from './buffers' | |
const { numSliceRows, numSliceColumns, resolution } = globalState.deref() | |
const poolSize = numSliceRows * numSliceColumns * (resolution + 3) | |
const POOL = new MemPool({ size: poolSize }) | |
console.log('poolSize of', { poolSize }) |
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 { | |
comp, | |
juxtR, | |
map, | |
mapcat, | |
partition, | |
reducer, | |
transduce, | |
wrapSides, | |
} from '@thi.ng/transducers' |
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
// 3d version of the 2d fitIntoBounds2 | |
// https://github.com/thi-ng/umbrella/blob/feaf8d3f8c1dd3e9141a151b4e473423a6f62242/packages/geom/src/ops/fit-into-bounds.ts#L34 | |
import { Vec, MAX3, MIN3, ReadonlyVec, neg, div4, div3, abs3, sub3, dist3 } from '@thi.ng/vectors'; | |
import { concat, translation44, ReadonlyMat, scale44, mulV344 } from '@thi.ng/matrices'; | |
import { bounds, centroid } from '@thi.ng/geom-poly-utils'; | |
import { isArray, isNull } from '@thi.ng/checks'; | |
/** |
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
/* | |
yarn add @thi.ng/hdom @thi.ng/pixel @thi.ng/hdom-canvas @thi.ng/geom @thi.ng/transducers @thi.ng/hdom-components @thi.ng/webgl @thi.ng/memoize @thi.ng/shader-ast @thi.ng/shader-ast-stdlib webgl-shadertoy | |
*/ | |
import { renderOnce } from "@thi.ng/hdom"; | |
import { PackedBuffer, canvas2d, ABGR8888, GRAY8 } from "@thi.ng/pixel"; | |
import { canvas as hdomCanvas } from "@thi.ng/hdom-canvas"; | |
import * as g from "@thi.ng/geom"; | |
import { range, map, normRange } from "@thi.ng/transducers"; | |
import { glCanvas } from "@thi.ng/webgl"; |
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
var dayjs = require('dayjs') | |
var minMax = require('dayjs/plugin/minMax') | |
dayjs.extend(minMax) | |
const input = [ | |
{time: '2020-07-23T11:30:00Z', value: 1}, | |
{time: '2020-07-24T11:30:00Z', value: 1}, | |
{time: '2020-07-05T11:30:00Z', value: 2}, | |
{time: '2020-07-30T11:30:00Z', value: 3}, |
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
export function mapIndexValues<Key extends string | number | symbol, ValueInput, ValueOutput>( | |
input: Record<Key, ValueInput>, | |
iteratee: (key: Key, val: ValueInput, index: number) => ValueOutput | |
): Record<Key, ValueOutput> { | |
const entries = Object.entries(input).map(([key, value], index) => [ | |
key, | |
iteratee(key as Key, value as ValueInput, index) | |
]); | |
return Object.fromEntries(entries); |
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 { useLayoutEffect, useState } from 'react'; | |
/** | |
* Determine if the input DOM element is truncated by CSS (using ellipse for example) | |
* @param domElement | |
* @returns boolean | |
*/ | |
export function isTruncated(domElement: Element): boolean { | |
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth | |
return domElement.scrollWidth > domElement.clientWidth; |