mrview 0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mrview/__init__.py ADDED
@@ -0,0 +1,19 @@
1
+ import pathlib
2
+ import anywidget
3
+ import traitlets
4
+ import numpy as np
5
+
6
+ _here = pathlib.Path(__file__).parent
7
+
8
+ class ViewJSWidget(anywidget.AnyWidget):
9
+ _esm = (_here / "view.js").read_text()
10
+ _css = (_here / "view.css").read_text()
11
+ data = traitlets.Bytes().tag(sync=True)
12
+ dims = traitlets.Bytes().tag(sync=True)
13
+
14
+ def view(x):
15
+ x = np.asarray(x, dtype=np.complex64)
16
+ wdg = ViewJSWidget()
17
+ wdg.dims = np.array(x.shape, dtype=np.int64).tobytes()
18
+ wdg.data = x.tobytes(order='F')
19
+ return wdg
mrview/view.css ADDED
@@ -0,0 +1,72 @@
1
+ .viewjs-wrapper {
2
+ position: relative;
3
+ display: inline-block;
4
+ width: min(100%, 700px);
5
+ max-width: 100%;
6
+ aspect-ratio: 5 / 4;
7
+ min-width: min(450px, 100%);
8
+ min-height: 360px;
9
+ resize: both;
10
+ border: 1px solid #c0bfbc;
11
+ border-radius: 6px;
12
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
13
+ background: #ebebeb;
14
+ overflow: hidden;
15
+ font-family: system-ui, sans-serif;
16
+ }
17
+
18
+ .viewjs-canvas {
19
+ display: block;
20
+ width: 100%;
21
+ height: 100%;
22
+ margin: 0;
23
+ border: 0;
24
+ overflow: hidden;
25
+ image-rendering: optimizeSpeed;
26
+ image-rendering: -moz-crisp-edges;
27
+ image-rendering: -o-crisp-edges;
28
+ image-rendering: -webkit-optimize-contrast;
29
+ image-rendering: optimize-contrast;
30
+ image-rendering: crisp-edges;
31
+ image-rendering: pixelated;
32
+ -ms-interpolation-mode: nearest-neighbor;
33
+ }
34
+
35
+ .viewjs-overlay {
36
+ position: absolute;
37
+ inset: 0;
38
+ display: flex;
39
+ flex-direction: column;
40
+ align-items: center;
41
+ justify-content: center;
42
+ gap: 10px;
43
+ background: rgba(235, 235, 235, 0.9);
44
+ color: #2e3436;
45
+ font-size: 13px;
46
+ pointer-events: none;
47
+ }
48
+
49
+ .viewjs-error {
50
+ color: #c01c28;
51
+ font-size: 13px;
52
+ padding: 16px;
53
+ text-align: center;
54
+ }
55
+
56
+ .viewjs-spinner {
57
+ width: 28px;
58
+ height: 28px;
59
+ border: 3px solid rgba(0, 0, 0, 0.12);
60
+ border-top-color: #3584e4;
61
+ border-radius: 50%;
62
+ animation: viewjs-spin 0.8s linear infinite;
63
+ }
64
+
65
+ @keyframes viewjs-spin {
66
+ to { transform: rotate(360deg); }
67
+ }
68
+
69
+ .viewjs-loading-text {
70
+ color: #5e5c64;
71
+ letter-spacing: 0.02em;
72
+ }