Skip to content

Instantly share code, notes, and snippets.

@UltiRequiem
Created January 27, 2022 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UltiRequiem/916ad525bd2f785f8fd6fb3df199954e to your computer and use it in GitHub Desktop.
Save UltiRequiem/916ad525bd2f785f8fd6fb3df199954e to your computer and use it in GitHub Desktop.
const size = 10.0;
const clr = 0.0;
const ps = 0.0;
rust
.then((canvas) => {
var nodes = document.getElementsByTagName("button");
for (var i = 0; i < nodes.length; i++) {
nodes[i].addEventListener(
"click",
function (i) {
console.log("You clicked element #" + i);
const color = [
Math.abs(Math.cos(clr)),
Math.abs(Math.sin(clr)),
Math.abs(Math.sin(clr / 2) * Math.cos(clr * 2)),
1.0,
];
const prop = {
color: color,
size: [100, 100],
marg: [20, 20],
pose: [ps * 200, Math.cos(ps) * 200 + 200],
shadow_size: size,
radius: 40.0,
};
canvas.add_obj("ololo", prop);
canvas.update();
clr += 0.1;
ps += 0.2;
}.bind(null, i)
);
}
})
.catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment