- Timeline events: immediate move after create
- Hide context menu when pointer down (how to blur from virtual canvas target)
- Velocity/Change/Cent Editor
- Optimise selection-rectangle for actual changes, only update on scroll
- Online version has smaller peaks on stems project
- Knob accepts out of range text input
❤️🔥
This file contains 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 org.openrndr.application | |
import org.openrndr.draw.* | |
import org.openrndr.internal.Driver | |
import org.openrndr.math.Vector2 | |
import org.openrndr.math.Vector3 | |
import java.io.File | |
class ShaderToy(fsCode: String) { | |
companion object { | |
fun fromFile(pathname: String): ShaderToy { |
This file contains 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
class Bar { type: 'bar' = 'bar' } | |
interface Foo { | |
hello?(): string | |
world?(event: Bar, foo: number): string | |
george?(): string | |
} | |
const bar: Foo = { | |
hello: () => 'world', |
This file contains 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
// Tested on all major browsers (Macbook Pro), Fails on IOS (https://caniuse.com/?search=MediaSource) | |
export const streamAndCacheMediaSource = (videoElement: HTMLVideoElement, url: string): void => { | |
const MimeCodec = "video/webm; codecs=\"vp9\"" | |
if (!MediaSource.isTypeSupported(MimeCodec)) {throw new Error(`${MimeCodec} is not supported`)} | |
const mediaSource = new MediaSource() | |
mediaSource.addEventListener("sourceopen", async () => { | |
if (mediaSource.readyState !== "open") {throw new Error("readyState not open")} | |
const sourceBuffer = mediaSource.addSourceBuffer(MimeCodec) | |
sourceBuffer.mode = "sequence" | |
sourceBuffer.addEventListener("error", () => {throw new Error("Unknown error. Check 'chrome://media-internals/'")}) |
This file contains 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 WeakRefSet<T extends WeakKey> { | |
readonly #set = new Set<WeakRef<T>>() | |
add(value: T): void {this.#set.add(new WeakRef<T>(value))} | |
forEach(callback: (value: T) => void): void { | |
for (const weakRef of this.#set) { | |
const value = weakRef.deref() | |
if (value === undefined) { | |
this.#set.delete(weakRef) |
This file contains 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
// Truncates the incoming text untill it fits into maxWidth | |
// Based on binary-search, hence only log(N) iterations | |
// | |
const findMaxFittingText = (context: CanvasRenderingContext2D, text: string, maxWidth: number): string => { | |
let l: number = 0 | |
let r: number = text.length | |
while (l < r) { | |
const mid: number = (r + l) >> 1 | |
const testString = text.substring(0, mid + 1) | |
if (Math.ceil(context.measureText(testString).width) <= maxWidth) { |