|
9 | 9 | if TYPE_CHECKING: |
10 | 10 | from cmap import _catalog |
11 | 11 | from cmap import Colormap |
12 | | -from cmap._util import report |
| 12 | +from cmap._util import report_cvds |
13 | 13 |
|
14 | 14 | # TODO: convert to jinja |
15 | 15 | TEMPLATE = """# {name} |
|
32 | 32 | {{{{ cmap_gray: {name} 30 }}}} |
33 | 33 | {{{{ cmap_sineramp: {name} }}}} |
34 | 34 |
|
| 35 | +<form id="cvd" class="radio-group"> |
| 36 | + <label class="radio-option" title="Full Vision"> |
| 37 | + <input type="radio" name="cvd_button" value="normal" checked> |
| 38 | + <span class="material-icons">visibility</span> |
| 39 | + <span class="radio-label"> Normal Vision</span> |
| 40 | + </label> |
| 41 | + <label class="radio-option" title="Protanopic"> |
| 42 | + <input type="radio" name="cvd_button" value="protan"> |
| 43 | + <span class="material-icons">filter_1</span> |
| 44 | + <span class="radio-label"> Protanopic</span> |
| 45 | + </label> |
| 46 | + <label class="radio-option" title="Deuteranopic"> |
| 47 | + <input type="radio" name="cvd_button" value="deutan"> |
| 48 | + <span class="material-icons">filter_2</span> |
| 49 | + <span class="radio-label"> Deuteranopic</span> |
| 50 | + </label> |
| 51 | + <label class="radio-option" title="Tritananopic"> |
| 52 | + <input type="radio" name="cvd_button" value="tritan"> |
| 53 | + <span class="material-icons">filter_3</span> |
| 54 | + <span class="radio-label"> Tritanopic</span> |
| 55 | + </label> |
| 56 | +</form> |
| 57 | +
|
35 | 58 | ## Perceptual Lightness |
36 | 59 |
|
37 | 60 | <canvas class="linearity-chart cmap-chart" data-cmap-name="{name}" width="800" height="350"></canvas> |
|
53 | 76 |
|
54 | 77 | <script> |
55 | 78 | window.cmap_data = {data}; |
| 79 | +
|
| 80 | +cvd?.addEventListener("change", (e) => {{ |
| 81 | + const selected = cvd.querySelector('input[name="cvd_button"]:checked')?.value; |
| 82 | + //window.cmap_data = {data}[selected]; |
| 83 | + console.log("CVD type selected:", selected); |
| 84 | + // re-render the charts |
| 85 | + initCharts(); |
| 86 | +
|
| 87 | + console.log("Selected variant:", selected); |
| 88 | +}}); |
| 89 | +
|
| 90 | +
|
| 91 | +
|
56 | 92 | <!-- Note: this is here because of `navigation.instant` in the mkdocs settings --> |
57 | 93 | typeof(initCharts) !== 'undefined' && initCharts(); |
58 | 94 | </script> |
@@ -111,11 +147,13 @@ def build_catalog(catalog: "_catalog.Catalog") -> None: |
111 | 147 | # write data used for charts |
112 | 148 | cm = Colormap(name) |
113 | 149 | cmap_data = { |
114 | | - k: np.around(v, 4).tolist() if isinstance(v, np.ndarray) else v |
115 | | - for k, v in report(cm).items() |
116 | | - if k in INCLUDE_DATA |
| 150 | + cvd_type: { |
| 151 | + k: np.around(v, 4).tolist() if isinstance(v, np.ndarray) else v |
| 152 | + for k, v in report.items() |
| 153 | + if k in INCLUDE_DATA |
| 154 | + } |
| 155 | + for cvd_type, report in report_cvds(cm).items() |
117 | 156 | } |
118 | | - |
119 | 157 | _aliases = [x for x in info.aliases if x != info.name] |
120 | 158 | aliases = _make_aliases_md(_aliases) if _aliases else "" |
121 | 159 |
|
|
0 commit comments