Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6904bb4

Browse filesBrowse files
committed
more organized color feature
1 parent 3012e20 commit 6904bb4
Copy full SHA for 6904bb4

File tree

Expand file treeCollapse file tree

1 file changed

+16
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-6
lines changed

‎fastplotlib/graphics/_graphic_attribute.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_graphic_attribute.py
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def __init__(self, parent, data: Any):
99
self._parent = parent
1010
self._data = data.astype(np.float32)
1111

12-
@property
13-
def data(self) -> Any:
14-
return self._data
15-
1612
def set_parent(self, parent: Any):
1713
self._parent = parent
1814

15+
@property
16+
def data(self):
17+
return self._data
18+
1919
@abstractmethod
2020
def __getitem__(self, item):
2121
pass
@@ -28,6 +28,10 @@ def __setitem__(self, key, value):
2828
def _update_range(self, key):
2929
pass
3030

31+
@abstractmethod
32+
def __repr__(self):
33+
pass
34+
3135

3236
def cleanup_slice(slice_obj: slice, upper_bound) -> slice:
3337
start = slice_obj.start
@@ -56,7 +60,7 @@ def cleanup_slice(slice_obj: slice, upper_bound) -> slice:
5660

5761

5862
class ColorFeature(GraphicFeature):
59-
def __init__(self, parent, colors, n_colors):
63+
def __init__(self, parent, colors, n_colors, alpha: float = 1.0):
6064
"""
6165
ColorFeature
6266
@@ -119,6 +123,9 @@ def __init__(self, parent, colors, n_colors):
119123
c = Color(colors)
120124
data = np.repeat(np.array([c]), n_colors, axis=0)
121125

126+
if alpha != 1.0:
127+
data[:, -1] = alpha
128+
122129
super(ColorFeature, self).__init__(parent, data)
123130

124131
self._upper_bound = data.shape[0]
@@ -211,4 +218,7 @@ def _update_range(self, key):
211218
self._parent.world_object.geometry.colors.update_range(ix, size=1)
212219

213220
def __getitem__(self, item):
214-
return self._parent.world_object.geometry.colors.data[item]
221+
return self._parent.world_object.geometry.colors.data[item]
222+
223+
def __repr__(self):
224+
return repr(self._parent.world_object.geometry.colors.data)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.