let A and B be polygons
let a and b be vectors representing the movement of said polygons within a game tick
let c be the movement of A relative to B a-b
calculate the transformation matrix Ta that transforms c into the vector (1, 0)
<!doctype html> | |
<!-- Set type to one of "full", "all" or "selective" --> | |
<fun-matrix type="selective"> | |
</fun-matrix> | |
<script type="module"> | |
import {html} from "https://darkwiiplayer.github.io/js/skooma.js" | |
import element from "https://darkwiiplayer.github.io/js/element.js" |
local based = require 'based.32.crockford' | |
local basexx = require 'basexx' | |
local function bench(name, fn, vector) | |
local before = os.clock() | |
for _, input in ipairs(vector) do | |
fn(input) | |
end | |
local after = os.clock() | |
print(string.format("%-10s %1.6f seconds", name..":", after-before)) |
values = Symbol("values") | |
hijack = (object, callbacks) => { | |
const val = object[values] ||= Object.create(null) | |
Object.entries(callbacks).forEach(([key, callback]) => { | |
Object.defineProperty(object, key, { | |
get() { return val[key] }, | |
set(value) { | |
callback(value) | |
val[key] = value | |
return true |
<script type="module"> | |
import {Better} from "/better.js" | |
class ConstantInterval extends Better { | |
#timer | |
static attributes = { | |
interval: { get: Number }, | |
onTick: { | |
get: Function, | |
set: e => `(${e.toString()})()` |
local fun = require 'fun' () | |
local function avg(...) | |
local sum, count = 0, 0 | |
for i=1,select('#', ...) do | |
count = count + 1 | |
sum = sum + select(i, ...) | |
end | |
return sum / count | |
end |
local tableview = require 'tableview' | |
local pegasus = require 'pegasus' | |
local print = function(...) | |
print(...) | |
io.stdout:flush() | |
end | |
local function serve(tab) | |
local server = pegasus:new { |
let template = document.createElement("template") | |
template.innerHTML = ` | |
<svg> | |
<defs> | |
<filter id="zoom"> | |
<feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="2" /> | |
<feGaussianBlur in="distorted" stdDeviation="2" result="turbulence" /> | |
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="10" xChannelSelector="R" yChannelSelector="G" result="distorted"/> | |
<feGaussianBlur in="distorted" stdDeviation="2" /> |
local function time(times, fn) | |
local before = os.clock() | |
for i=1,times do | |
fn() | |
end | |
local after = os.clock() | |
return after - before | |
end | |
local function bench(name, times, fn) |
local t = setmetatable({}, {__name="foobar"}) | |
print(type(t)) --> foobar | |
print(rawtype(t)) --> table |