Skip to content

Instantly share code, notes, and snippets.

View bfgeek's full-sized avatar

Ian Kilpatrick bfgeek

View GitHub Profile
// animation worklet
registerAnimator('parallaxAnim', class {
static inputs = {
'scroller': {
'scrollTop'
},
'parallax': {
'style': ['transform']
}
}
registerAnimator('foo', class {
static elements = {
scroller: {
isRoot: true;
scrollInput: true;
},
parallax: {
outputProperties: ['transform']
}
const source = ???;
const audioWorkletNode = new AudioWorkletNode('filter');
source.connect(audioWorkletNode);
audioWorkletNode.connect(ctx.destination);
|----------|
|---|
@bfgeek
bfgeek / thing.html
Last active January 10, 2017 22:25
<style>
.painting {
background-image: paint(typed, 10px), url(foo2.png);
background-image: paint(typed, red), url(foo1.png);
}
</style>
<script>
// paint worklet
registerPaint('typed', class {
static inputArguments = ['<length>'];
interface VRAnchor {
readonly attribute VRCoordinateSystem coordinateSystem;
};
[Constructor(VRDisplay)]
interface VRStageAnchor : VRAnchor {
readonly attribute float sizeX;
readonly attribute float sizeY;
};
const canvas = new OffscreenCanvas(1000, 1000);
const ctx = canvas.getContext('2d' /* not sure if this is special */);
const layer = new CanvasVRLayer(canvas);
async function drawLoop() {
do {
} while (await ctx.commit());
}
@bfgeek
bfgeek / tasklets.js
Created April 5, 2017 17:22
tasklet examples.
api = await remote {
import B from 'b.js';
export class A {
constructor() { this.b = new B(); }
}
export function thing() {
}
}
<script worklet="paint" src="paint.js"></script>
<!--
This makes the script a type="module" and has similar loading behaviour, e.g.
if async is present it will not wait until the whole document is parsed to begin
executing, if not - it waits until the whole document is parsed to being executing
on worklets.
-->
<script worklet="paint">
<!doctype html><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Worklets Level 1</title>
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<meta content="ED" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="https://www.w3.org/StyleSheets/TR/2016/W3C-ED" rel="stylesheet" type="text/css">
<meta content="Bikeshed version 81c00a31d8c468599cf8337dd150a8be9a2b4e5d" name="generator">
console.log('hello world.');