const log = (key, value) =>
document.body.innerHTML += `<pre>${key}: ${value}</pre>`
const uuid = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
let uuid = ''
for (let i = 0; i < 32; i += 1) {
switch (i) {
case 8:
case 20:
uuid += '-'
uuid += (Math.random() * 16 | 0).toString(16)
break
case 12:
uuid += '-'
uuid += '4'
break
case 16:
uuid += '-'
uuid += (Math.random() * 4 | 8).toString(16)
break
default:
uuid += (Math.random() * 16 | 0).toString(16)
}
}
return uuid
}
class BaseScene {
constructor(name, description, duration, resizable) {
if (new.target === BaseScene)
throw new TypeError("Cannot construct Abstract instances directly")
if (!name)
throw new TypeError("Parameter \"name\" is required!")
if (!duration)
throw new TypeError("Parameter \"duration\" is required!")
if (duration < 1000)
throw new TypeError("Parameter \"duration\" can't be less than 1000!")
this.name = name
this.description = description || ""
this.duration = duration
this.resizable = !!resizable
}
/**
* Clamp value in range min..max
* @param value — Current value
* @param min — Range minimum
* @param max — Range maximum
* @return number — interpolated value between min and max
*/
clamp(value, min, max) {
return Math.min(Math.max(value, min), max)
}
slope(A, B, a, b, val) {
return (val - A) * (b - a) / (B - A) + a
}
rgbh(r, g, b, h) {
// return [r, g, b, h * .33]
return [r, g, b, h]
}
hsvh(h, s, v, height) {
let r, g, b, i, f, p, q, t
h = h % 360
// Achromatic (grey)
if (s === 0) return this.rgbh(v, v, v, height)
h /= 60 // sector 0 to 5
i = ~~(h)
f = h - i // factorial part of h
p = v * (1 - s)
q = v * (1 - s * f)
t = v * (1 - s * (1 - f))
switch (i) {
case 0:
r = v;
g = t;
b = p;
break
case 1:
r = q;
g = v;
b = p;
break
case 2:
r = p;
g = v;
b =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.