xxxxxxxxxx
60
let nl;
let numFont;
let st, play;
function preload() {
numFont = loadFont("LaTeX Font.otf");
}
function setup() {
createCanvas(960, 540);
nl = new NumberLine();
st = createSelect();
st.position(10, 550);
st.option(1);
st.option(1 / 2);
st.option(2);
st.option(-3);
st.option(3);
st.option(6);
play = createButton("Apply Transformation");
play.position(10, 580);
play.mousePressed(transform);
}
function draw() {
background(0);
nl.update();
nl.show();
// console.log(nl.t);
// console.log(nl.m);
// console.log(map(smooth0to1(nl.t), 0, 1, 0.5, 1));
}
function transform() {
nl.applyTransformation(st.value());
}
// Math functions for smoothing of transformations
function f(x) {
if (x > 0) {
return Math.exp(-1 / x);
} else if (x <= 0) {
return 0;
}
}
function smooth0to1(x) {
return x;
}