Skip to content

Instantly share code, notes, and snippets.

@ryanswrt
Created August 14, 2019 06:29
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 ryanswrt/90a610ca6db2d6dbc923d77bbaf7149e to your computer and use it in GitHub Desktop.
Save ryanswrt/90a610ca6db2d6dbc923d77bbaf7149e to your computer and use it in GitHub Desktop.
pre.addEventListener("click", event => {
const boundingRect = pre.getBoundingClientRect();
const scaleX = 64 / boundingRect.width;
const scaleY = 64 / boundingRect.height;
const canvasLeft = (event.clientX - boundingRect.left) * scaleX;
const canvasTop = (event.clientY - boundingRect.top) * scaleY;
const row = Math.min(Math.floor(canvasTop), 64 - 1);
const col = Math.min(Math.floor(canvasLeft), 64 - 1);
contract.call(
wallet,
"toggle",
BigInt(0),
BigInt(1e7),
BigInt(0),
{
type: "uint32",
value: row
},
{
type: "uint32",
value: col
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment