First commit, done on M6 from the PLAN.MD
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// Desk-level helpers shared by the paper panels.
|
||||
|
||||
export function hash(str) {
|
||||
let h = 2166136261;
|
||||
for (let i = 0; i < str.length; i++) h = Math.imul(h ^ str.charCodeAt(i), 16777619);
|
||||
return h >>> 0;
|
||||
}
|
||||
|
||||
// Give a paper a stable slight rotation derived from its id.
|
||||
export function tilt(el, id, amp = 0.8) {
|
||||
const r = ((hash(id) % 1000) / 1000 - 0.5) * 2 * amp;
|
||||
el.style.setProperty("--rot", `${r.toFixed(2)}deg`);
|
||||
}
|
||||
|
||||
export const $ = (root, sel) => root.querySelector(sel);
|
||||
|
||||
// Escape text for use inside innerHTML templates.
|
||||
export const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
||||
Reference in New Issue
Block a user