他人に読まれたくない紙を捨てたい
他人に読まれたくない情報が書かれた紙を廃棄するのに目隠しパターンが出るコロコロスタンプを使用しているのですが、大量に紙を処分したいときに、スタンプのインクが切れたら嫌だと思い、インクジェットプリンターで紙一面目隠しパターンで塗りつぶすスクリプトを考えてみた。
仕組み
稚拙なスクリプトですが、ランダムな英数字をランダムな方向、位置で書きつぶすJavascriptを書いてみました。
このhtmlをブラウザで開いて目隠ししたい紙をプリンタにセットして1枚に収まるように印刷すればいいはず…
<html>
<body>
<svg id="picture"></svg>
<script>
const draw = () => {
const dens=3.5;
const h=297*dens;
const w=210*dens;
const n=700*dens*dens;
const color="black";
const c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789";
const box=document.getElementById("picture");
box.setAttribute("width", w);
box.setAttribute("height", h);
box.setAttribute("stroke", color);
for(let i=0; i<n; i++){
const letter=document.createElementNS("http://www.w3.org/2000/svg", "text");
letter.setAttribute("x", Math.random()*w);
letter.setAttribute("y", Math.random()*h);
letter.setAttribute("rotate", Math.random()*360);
letter.textContent=c[Math.floor(Math.random()*c.length)];
box.appendChild(letter);
}
};
draw();
</script>
</body>
</html>
課題
- FireFoxで印刷しようとすると、余白とか用紙サイズとかがぴったりいかない。
- 色を変えたいときにスクリプトを触る必要がある。
気が向いたら更新してゆきます。