-
Notifications
You must be signed in to change notification settings - Fork 0
/
hilbert2.js
53 lines (44 loc) · 1.15 KB
/
hilbert2.js
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
48
49
50
51
52
53
const {
Drawing,
Vector,
CanvasVector,
getRange,
} = CanvasDrawing;
const {
ALIGN_CENTER,
POS_CENTER,
} = CanvasDrawing;
const drawing = new Drawing({ canvasId: "item" });
const mainAction = () => {
const n = 11;
const minDim = 2 * 2 ** n;
width = minDim + 400;
height = minDim + 600 + 1600;
const origin = [200, 4296];
const mapx = 1;
const mapy = -1;
const bgcolor = '#000000';
drawing.reinit({ height, width, origin, mapx, mapy, bgcolor });
const N = 2 ** (2 * n);
const range = getRange(N);
range.forEach((i) => {
let p = hilbert1To2(n, i);
let v = new Vector([p[0] * 2, p[1] * 2]);
drawing.filledRectangle({
point0: v,
point1: v.add(2, 2),
color: hue2color(i / N),
});
})
drawing.addText({
text: 'Hilbert',
position: POS_CENTER,
point: new CanvasVector(2248, 5296),
textAlign: ALIGN_CENTER,
color: '#ffffff',
fontFamily: 'Calibri',
fontSize: '900px',
fontWeight: 'bold',
});
};
mainAction();