1const seed = (42069 / 454 / 1127 / 47) * 9457;
2
3const noiseScale = 4137;
4const scale = 160; // 160
5var oldWidth = 0;
6var oldHeight = 0;
7var wiggleScale = 4;
8//var timeBeforeRefresh = 1*240;
9var thetaSpeed = 0.1;
10var zoomSpeed = 1.005;
11
12canvas = document.getElementsByTagName("canvas")[0];
13var width = canvas.width;
14var height = canvas.height;
15var ctx = canvas.getContext("2d");
16noise.seed(seed);
17
18function rMathRandom(rngSeed) {
19 return (
20 (noise.simplex2(((new Date() - 0) / noiseScale) * 80, rngSeed) + 1) / 2
21 );
22}
23
24function startDrawing() {
25 (function animloop() {
26 requestAnimationFrame(animloop);
27 ctx.fillStyle =
28 "hsl(341, " +
29 rMathRandom(441) * 85 +
30 "%, " +
31 rMathRandom(971) * 50 +
32 "%)";
33 ctx.font = rMathRandom(15622) * scale + "px Yusei Magic";
34 ctx.fillText(
35 listOfLemmas[Math.floor(rMathRandom(14441) * listOfLemmas.length)],
36 rMathRandom(1966241) * width,
37 rMathRandom(41) * height
38 );
39 ctx.translate(width / 2, height / 2);
40 ctx.rotate((thetaSpeed * Math.PI) / 180);
41 ctx.scale(zoomSpeed, zoomSpeed);
42 //ctx.transform(noise.simplex2((new Date()-0)/noiseScale,10010), noise.simplex2((new Date()-0)/noiseScale,1010), noise.simplex2((new Date()-0)/noiseScale,10), noise.simplex2((new Date()-0)/noiseScale,100010), noise.simplex2((new Date()-0)/noiseScale,20010), noise.simplex2((new Date()-0)/noiseScale,30010));
43 //ctx.transform(noise.simplex2((new Date()-0)/noiseScale,180010), noise.simplex2((new Date()-0)/noiseScale,10810), noise.simplex2((new Date()-0)/noiseScale,810), noise.simplex2((new Date()-0)/noiseScale,1008010), noise.simplex2((new Date()-0)/noiseScale,208010), noise.simplex2((new Date()-0)/noiseScale,380010));
44 ctx.translate(-width / 2, -height / 2);
45 ctx.drawImage(
46 canvas,
47 noise.simplex2((new Date() - 0) / noiseScale, 10010) * wiggleScale,
48 noise.simplex2((new Date() - 0) / noiseScale, 1080) * wiggleScale
49 );
50 ctx.resetTransform();
51 //if (Math.random()<1/timeBeforeRefresh){
52 //ctx.clearRect(0, 0, canvas.width, canvas.height);
53 //}
54 })();
55}
56
57// Get list of lemmas
58const url =
59 "https://ontake.dev/legacy/v5/daily-kanji/assets/datasets/listoflemmas.txt";
60$.ajax({
61 url: url,
62 success: function (result) {
63 listOfLemmas = result.split("\r\n");
64 startDrawing();
65 },
66});
67
68setInterval(function () {
69 if (oldWidth == window.innerWidth) {
70 } else if (oldHeight == window.innerHeight) {
71 } else {
72 canvas.width = window.innerWidth;
73 canvas.height = window.innerHeight;
74 width = canvas.width;
75 height = canvas.height;
76 oldWidth = window.innerWidth;
77 oldHeight = window.innerHeight;
78 }
79}, 1000);