Skip to content

Instantly share code, notes, and snippets.

View shot-codes's full-sized avatar

Nicolai Oliver Verbaarschot shot-codes

View GitHub Profile
function handleHover(e: MouseEvent) {
const { clientX, clientY, currentTarget } = e;
const { clientWidth, clientHeight, offsetLeft, offsetTop } = currentTarget as HTMLDivElement;
if (currentTarget instanceof HTMLDivElement) {
const horizontal = (clientX - offsetLeft) / clientWidth;
const vertical = (clientY + scrollY - offsetTop) / clientHeight;
const rotateX = (THRESHOLD / 2 - horizontal * THRESHOLD).toFixed(2);
const rotateY = (vertical * THRESHOLD - THRESHOLD / 2).toFixed(2);
currentTarget.style.transform = `perspective(${clientWidth}px) rotateX(${rotateY}deg) rotateY(${rotateX}deg) scale3d(1.2, 1.2, 1.2)`;
// FILE * low;
// FILE * high;
// FILE * deriv;
// FILE * square;
// FILE * mwi;
//
// low = fopen ("../outputData/output_low.txt","w");
// high = fopen ("../outputData/out_high.txt","w");
// deriv = fopen ("../outputData/out_deriv.txt","w");
// square = fopen ("../outputData/out_square.txt","w");