-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
47 lines (39 loc) · 1.26 KB
/
index.html
File metadata and controls
47 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NinePatch.js Example</title>
<script src="https://cdn.jsdelivr.net/npm/p5@1.11.3/lib/p5.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Omay238/nine-patch@latest/ninepatch.min.js"></script>
<script>
let img = "https://cdn.jsdelivr.net/gh/Omay238/nine-patch@latest/images/logo.png";
let ninePatch;
function preload() {
ninePatch = new NinePatch(img, "tile", 5);
}
function setup() {
createCanvas(400, 400);
noSmooth();
}
function loopBetweenValues(n, min, max) {
return min + abs((n % (2 * (max - min))) - (max - min));
}
let minFramerate = Infinity;
function draw() {
background(220);
noStroke();
let w = loopBetweenValues(frameCount + 350, 16, 400);
let h = loopBetweenValues(frameCount, 16, 400);
let img = ninePatch.gen(w, h, 4);
image(img, 0, 0);
if (frameRate() < minFramerate) {
minFramerate = frameRate();
}
text(minFramerate, 10, 20);
}
</script>
</head>
<body>
</body>
</html>