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
Lux Capital (lead) | |
Amplify Partners | |
Sabrina Hahn | |
Guillermo Rauch, founder Vercel | |
Liu Jiang | |
NP-Hard Ventures | |
Badrul Farooqi | |
Soleio Cuervo | |
Tom Preston-Werner, co-founder Github | |
Adam Wiggins, founder Ink and Switch, Muse |
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
// segments are all of the segments in all of the shapes in the scene | |
// point is light point | |
// viewport is top left, top right, bottom right, bottom left | |
function getVisibilityPolygon(segments: Segment[], point: Point, viewport: Point[]) { | |
const brokenSegments: Segment[] = [] | |
const viewportMinCorner = viewport[0] | |
const viewportMaxCorner = viewport[2] |
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
animateCamera = ( | |
x: number, | |
y: number, | |
z: number, | |
opts = {} as { duration: number; ease: (t: number) => number } | |
) => { | |
const { duration = 1000 } = opts | |
const { center } = this.viewport | |
const currCenter = new Vec2d(center.x, center.y, this.camera.z) | |
const nextCenter = new Vec2d(x, y, z) |
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 intersectSets<T>(sets: Set<T>[]) { | |
if (sets.length === 0) return new Set<T>() | |
const first = sets[0] | |
const rest = sets.slice(1) | |
const result = new Set<T>() | |
for (const val of first) { | |
if (rest.every((set) => set.has(val))) { | |
result.add(val) | |
} |
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 class Cache<T extends object, K> { | |
items = new WeakMap<T, K>() | |
get<P extends T>(item: P, cb: (item: P) => K) { | |
if (!this.items.has(item)) { | |
this.items.set(item, cb(item)) | |
} | |
return this.items.get(item)! | |
} |
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
const TAU = Math.PI / 2 | |
const PI2 = Math.PI * 2 | |
interface VecLike {x: number, y: number } | |
/** | |
* Get info about an arc formed by three points. | |
* | |
* @param a The start of the arc | |
* @param b A point on the arc |
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 { NextApiRequest, NextApiResponse } from 'next' | |
import chromium from 'chrome-aws-lambda' | |
import Cors from 'cors' | |
import { TDExport, TDExportTypes, TldrawApp } from '@tldraw/tldraw' | |
// NOTE: You might have to downgrade puppeteer etc in order to fit under the endpoint size limit of 50mb. | |
const cors = Cors({ | |
methods: ['POST'], | |
}) |
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
/** | |
* Find the control points for a quadratic segment from point a to point c passing through point b. | |
* @param a The segments's first point | |
* @param b The point to curve through | |
* @param c The segment's end point | |
*/ | |
export function getQuadraticControlPoints( | |
a: { x: number; y: number }, | |
b: { x: number; y: number }, | |
c: { x: number; y: 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
/** | |
* Find the control points for a cubic segment from point a to point c passing through point b. | |
* @param a The curve's start point | |
* @param b The point to curve through | |
* @param c The curve's end point | |
*/ | |
export function findCubicControlPoints( | |
a: { x: number; y: number }, | |
b: { x: number; y: number }, | |
c: { x: number; y: 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
var DBOpenRequest = window.indexedDB.open("keyval-store", 1); | |
DBOpenRequest.onsuccess = function(event) { | |
db = DBOpenRequest.result; | |
var transaction = db.transaction(["keyval"], "readwrite"); | |
var objectStore = transaction.objectStore("keyval"); | |
var objectStoreRequest = objectStore.get("home"); | |
objectStoreRequest.onsuccess = function(event) { | |
console.log(JSON.stringify(objectStoreRequest.result)) | |
}; | |
}; |