Skip to content

Commit 9e8459c

Browse files
committed
coolwarm colormap
1 parent 4356dd7 commit 9e8459c

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

webgpu/colormap.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numpy as np
2+
13
from .labels import Labels
24
from .renderer import BaseRenderer, Renderer, RenderOptions
35
from .uniforms import Binding, UniformBase, ct
@@ -15,7 +17,6 @@
1517
TextureFormat,
1618
TextureUsage,
1719
)
18-
import numpy as np
1920

2021

2122
class ColormapUniforms(UniformBase):
@@ -409,6 +410,40 @@ def set_max(self, maxval):
409410
[196, 0, 0],
410411
[159, 0, 0],
411412
],
413+
"matplotlib:coolwarm": [
414+
[59, 76, 192],
415+
[68, 90, 204],
416+
[78, 104, 216],
417+
[88, 117, 225],
418+
[98, 130, 234],
419+
[108, 143, 241],
420+
[119, 154, 247],
421+
[130, 166, 251],
422+
[141, 176, 254],
423+
[152, 185, 255],
424+
[163, 194, 254],
425+
[174, 201, 252],
426+
[185, 208, 249],
427+
[195, 213, 244],
428+
[204, 217, 237],
429+
[213, 219, 229],
430+
[221, 220, 220],
431+
[229, 216, 209],
432+
[236, 211, 197],
433+
[241, 204, 184],
434+
[245, 196, 172],
435+
[247, 186, 159],
436+
[247, 176, 147],
437+
[246, 165, 134],
438+
[244, 152, 122],
439+
[240, 139, 110],
440+
[235, 125, 98],
441+
[228, 110, 86],
442+
[221, 95, 75],
443+
[212, 78, 65],
444+
[202, 59, 55],
445+
[190, 36, 46],
446+
],
412447
}
413448

414449

@@ -426,7 +461,7 @@ def create_colormap(name: str, n_colors: int = 32):
426461

427462
if __name__ == "__main__":
428463
print("_colormaps = {")
429-
for name in ["viridis", "plasma", "cet_l20", "matlab:jet"]:
464+
for name in ["viridis", "plasma", "cet_l20", "matlab:jet", "matplotlib:coolwarm"]:
430465
colors = create_colormap(name, n_colors=32)
431466
print(f" '{name}' : [")
432467
for i in range(32):

0 commit comments

Comments
 (0)