GSP API Reference¶
The Graphic Server Protocol (GSP) API provides a unified interface for creating and rendering graphics across different backends.
Core Module¶
gsp.core.canvas
¶
Canvas module for the GSP library.
Canvas
¶
Canvas class representing a drawing surface with specific dimensions and DPI.
Source code in src/gsp/core/canvas.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
__init__(width: int, height: int, dpi: float)
¶
Create a new Canvas object with the given width, height, and dpi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Width of the canvas in pixels. |
required |
height
|
int
|
Height of the canvas in pixels. |
required |
dpi
|
float
|
Dots per inch (DPI) of the canvas. If set to the screen PPI, the 'inch' unit in will correspond to one physical inch on the screen. |
required |
Source code in src/gsp/core/canvas.py
14 15 16 17 18 19 20 21 22 23 24 25 26 | |
__repr__() -> str
¶
Return string representation of the Canvas instance.
Source code in src/gsp/core/canvas.py
28 29 30 | |
get_dpi() -> float
¶
Get the DPI of the canvas.
Source code in src/gsp/core/canvas.py
64 65 66 | |
get_height() -> int
¶
Get the height of the canvas in pixels.
Source code in src/gsp/core/canvas.py
52 53 54 | |
get_uuid() -> str
¶
Get the UUID of the Canvas instance.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The UUID of the Canvas. |
Source code in src/gsp/core/canvas.py
32 33 34 35 36 37 38 | |
get_width() -> int
¶
Get the width of the canvas in pixels.
Source code in src/gsp/core/canvas.py
40 41 42 | |
set_dpi(dpi: float) -> None
¶
Set the DPI of the canvas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dpi
|
float
|
The new DPI value. |
required |
Source code in src/gsp/core/canvas.py
68 69 70 71 72 73 74 | |
set_height(height: int) -> None
¶
Set the height of the canvas in pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
height
|
int
|
The new height in pixels. |
required |
Source code in src/gsp/core/canvas.py
56 57 58 59 60 61 62 | |
set_width(width: int) -> None
¶
Set the width of the canvas in pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The new width in pixels. |
required |
Source code in src/gsp/core/canvas.py
44 45 46 47 48 49 50 | |
gsp.core.viewport
¶
Viewport class representing a rectangular area on the canvas.
Viewport
¶
Viewport class representing a rectangular area on the canvas.
Source code in src/gsp/core/viewport.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
__init__(x: int, y: int, width: int, height: int)
¶
Create a viewport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
The x offset (in pixels from left) of the viewport. |
required |
y
|
int
|
The y offset (in pixels from bottom) of the viewport. |
required |
width
|
int
|
The width (in pixels) of the viewport. |
required |
height
|
int
|
The height (in pixels) of the viewport. |
required |
Source code in src/gsp/core/viewport.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
__repr__() -> str
¶
Return string representation of the Viewport instance.
Source code in src/gsp/core/viewport.py
31 32 33 | |
get_height() -> int
¶
Get the height (in pixels) of the viewport.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The height. |
Source code in src/gsp/core/viewport.py
91 92 93 94 95 96 97 | |
get_uuid() -> str
¶
Get the unique identifier of the viewport.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The unique identifier. |
Source code in src/gsp/core/viewport.py
35 36 37 38 39 40 41 | |
get_width() -> int
¶
Get the width (in pixels) of the viewport.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The width. |
Source code in src/gsp/core/viewport.py
75 76 77 78 79 80 81 | |
get_x() -> int
¶
Get the x offset (in pixels from left) of the viewport.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The x offset. |
Source code in src/gsp/core/viewport.py
43 44 45 46 47 48 49 | |
get_y() -> int
¶
Get the y offset (in pixels from bottom) of the viewport.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The y offset. |
Source code in src/gsp/core/viewport.py
59 60 61 62 63 64 65 | |
set_height(height: int) -> None
¶
Set the height (in pixels) of the viewport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
height
|
int
|
The new height. |
required |
Source code in src/gsp/core/viewport.py
99 100 101 102 103 104 105 | |
set_width(width: int) -> None
¶
Set the width (in pixels) of the viewport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The new width. |
required |
Source code in src/gsp/core/viewport.py
83 84 85 86 87 88 89 | |
set_x(x: int) -> None
¶
Set the x offset (in pixels from left) of the viewport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
The new x offset. |
required |
Source code in src/gsp/core/viewport.py
51 52 53 54 55 56 57 | |
set_y(y: int) -> None
¶
Set the y offset (in pixels from bottom) of the viewport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
int
|
The new y offset. |
required |
Source code in src/gsp/core/viewport.py
67 68 69 70 71 72 73 | |
gsp.core.camera
¶
Camera module for the GSP library.
Camera
¶
Camera class representing a view and projection matrix for 3D rendering.
Source code in src/gsp/core/camera.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
userData: dict[str, Any] = {}
instance-attribute
¶
A dictionary for storing custom user data associated with the Camera instance.
__init__(view_matrix: TransBuf, projection_matrix: TransBuf)
¶
Initialize a Camera instance. Just a container for view and projection matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_matrix
|
gsp.types.transbuf.TransBuf
|
View matrix - view-matrix |
required |
projection_matrix
|
gsp.types.transbuf.TransBuf
|
Projection matrix - projection-matrix |
required |
Source code in src/gsp/core/camera.py
14 15 16 17 18 19 20 21 22 23 24 25 | |
__repr__() -> str
¶
Return string representation of the Camera instance.
Source code in src/gsp/core/camera.py
27 28 29 | |
get_projection_matrix() -> TransBuf
¶
Get the projection matrix of the Camera.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The projection matrix. |
Source code in src/gsp/core/camera.py
63 64 65 66 67 68 69 | |
get_uuid() -> str
¶
Get the UUID of the Camera instance.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The UUID of the Camera. |
Source code in src/gsp/core/camera.py
31 32 33 34 35 36 37 | |
get_view_matrix() -> TransBuf
¶
Get the view matrix of the Camera.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The view matrix. |
Source code in src/gsp/core/camera.py
47 48 49 50 51 52 53 | |
set_projection_matrix(projection_matrix: TransBuf)
¶
Set the projection matrix of the Camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projection_matrix
|
gsp.types.transbuf.TransBuf
|
The new projection matrix. |
required |
Source code in src/gsp/core/camera.py
55 56 57 58 59 60 61 | |
set_view_matrix(view_matrix: TransBuf)
¶
Set the view matrix of the Camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_matrix
|
gsp.types.transbuf.TransBuf
|
The new view matrix. |
required |
Source code in src/gsp/core/camera.py
39 40 41 42 43 44 45 | |
gsp.core.event
¶
A simple, standalone event implementation with subscribe and dispatch methods.
Event
¶
Bases: typing.Generic[gsp.core.event.Callback]
A simple, standalone event implementation with subscribe and dispatch methods.
This class allows for a "one-to-many" communication pattern where a single event can notify multiple listeners (subscribers) that an action has occurred.
The generic type Callback allows the event to be type-hinted with the
specific signature of the functions it will dispatch to, ensuring type safety.
Source code in src/gsp/core/event.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
__init__()
¶
Initialize the Event with an empty list of callbacks.
Source code in src/gsp/core/event.py
19 20 21 22 | |
dispatch(*args: Any, **kwargs: Any) -> None
¶
Dispatches the event, calling all subscribed callbacks with the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
typing.Any
|
Positional arguments to pass to the callbacks. |
()
|
**kwargs
|
typing.Any
|
Keyword arguments to pass to the callbacks. |
{}
|
Source code in src/gsp/core/event.py
41 42 43 44 45 46 47 48 49 | |
event_listener(callback: Callback) -> Callback
¶
Decorator to subscribe a function to the event. This is a convenience method.
It still ensure static type checking on the decorated function.
NOTE: it is possible to unsubscribe the function later using event.unsubscribe(handler).
Usage
@event.subscriber def handler(...): ...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
gsp.core.event.Callback
|
The function to be subscribed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Callback |
gsp.core.event.Callback
|
The same function that was passed in. |
Source code in src/gsp/core/event.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
subscribe(callback: Callback) -> None
¶
Subscribes a callback to the event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
gsp.core.event.Callback
|
The function to be called when the event is dispatched. Its signature should match the event's generic type. |
required |
Source code in src/gsp/core/event.py
24 25 26 27 28 29 30 31 | |
unsubscribe(callback: Callback) -> None
¶
Unsubscribes a previously subscribed callback from the event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
gsp.core.event.Callback
|
The function to be removed from the event's subscribers. |
required |
Source code in src/gsp/core/event.py
33 34 35 36 37 38 39 | |
main() -> None
¶
Example usage of the Event class.
Source code in src/gsp/core/event.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
Types Module¶
gsp.types.buffer
¶
Buffer module for typed array with single dimension.
Buffer
¶
Typed array with single dimension.
It is immutable in count and type, but mutable in content.
Source code in src/gsp/types/buffer.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
__init__(count: int, buffer_type: BufferType) -> None
¶
Initialize a Buffer instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
The number of elements in the buffer. |
required |
buffer_type
|
gsp.types.buffer_type.BufferType
|
The type of elements in the buffer. |
required |
Source code in src/gsp/types/buffer.py
19 20 21 22 23 24 25 26 27 28 29 | |
__repr__() -> str
¶
Return a string representation of the Buffer.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation showing count and type. |
Source code in src/gsp/types/buffer.py
31 32 33 34 35 36 37 | |
from_bytearray(_bytearray: bytearray, buffer_type: BufferType) -> Buffer
staticmethod
¶
Create a Buffer from a bytearray and a specified BufferType.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_bytearray
|
bytearray
|
The source bytearray. |
required |
buffer_type
|
gsp.types.buffer_type.BufferType
|
The type of elements in the buffer. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Buffer |
gsp.types.buffer.Buffer
|
The created Buffer instance. |
Source code in src/gsp/types/buffer.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_count() -> int
¶
Return the number of elements in the buffer.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of elements. |
Source code in src/gsp/types/buffer.py
39 40 41 42 43 44 45 | |
get_data(offset: int, count: int) -> Buffer
¶
Return a buffer of count elements starting from offset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
The starting index. |
required |
count
|
int
|
The number of elements to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Buffer |
gsp.types.buffer.Buffer
|
A new Buffer containing the requested data. |
Source code in src/gsp/types/buffer.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
get_type() -> BufferType
¶
Return the type of each element in the buffer.
Returns:
| Name | Type | Description |
|---|---|---|
BufferType |
gsp.types.buffer_type.BufferType
|
The buffer type. |
Source code in src/gsp/types/buffer.py
47 48 49 50 51 52 53 | |
set_data(_bytearray: bytearray, offset: int, count: int) -> None
¶
Copy count elements starting from offset in the source bytearray.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_bytearray
|
bytearray
|
The source bytearray containing data to copy. |
required |
offset
|
int
|
The starting index in the buffer where data will be copied. |
required |
count
|
int
|
The number of elements to copy. |
required |
Source code in src/gsp/types/buffer.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
to_bytearray() -> bytearray
¶
Return the content of the Buffer as a bytearray.
Returns:
| Name | Type | Description |
|---|---|---|
bytearray |
bytearray
|
The bytearray representation of the Buffer. |
Source code in src/gsp/types/buffer.py
98 99 100 101 102 103 104 | |
gsp.types.group
¶
Group type definitions for GSP.
This module defines types used to represent groups of elements in various forms.
Groups = Union[int, list[int], list[list[int]]]
module-attribute
¶
A type that can represent group IDs in various forms.
The Groups type supports three different formats
- int: Represents the size of a single group.
- list[int]: Each int represents the size of each subgroup.
- list[list[int]]: Each sublist represents element indices in a group.
- len(groups) represents the number of groups.
- groups[0] contains element indices of the first group.
- groups[1] contains element indices of the second group.
gsp.types.visual_base
¶
Base class for visual objects in GSP.
This module provides the foundational VisualBase class that all visual objects inherit from, providing common functionality like UUID generation and user data storage.
VisualBase
¶
Base class for all visual objects in the GSP library.
This class provides fundamental functionality for visual objects including automatic UUID generation and a userData dictionary for storing custom metadata.
Source code in src/gsp/types/visual_base.py
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 | |
__init__()
¶
Initialize a new VisualBase instance.
Creates a new visual object with a unique identifier and an empty userData dictionary.
Source code in src/gsp/types/visual_base.py
25 26 27 28 29 30 31 32 | |
get_uuid() -> str
¶
Get the unique identifier of the visual object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The unique identifier. |
Source code in src/gsp/types/visual_base.py
34 35 36 37 38 39 40 | |
set_uuid(uuid: str) -> None
¶
Set the unique identifier of the visual object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
str
|
The new unique identifier. |
required |
Source code in src/gsp/types/visual_base.py
42 43 44 45 46 47 48 | |
Visuals Module¶
gsp.visuals.points
¶
Points visual module.
Points
¶
Bases: gsp.types.visual_base.VisualBase
Points visual for rendering point markers.
This visual represents a collection of points with configurable positions, sizes, face colors, edge colors, and edge widths.
Source code in src/gsp/visuals/points.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
__init__(positions: TransBuf, sizes: TransBuf, face_colors: TransBuf, edge_colors: TransBuf, edge_widths: TransBuf)
¶
Initialize Points visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the points. |
required |
sizes
|
gsp.types.transbuf.TransBuf
|
Sizes of the points. |
required |
face_colors
|
gsp.types.transbuf.TransBuf
|
Face colors of the points. |
required |
edge_colors
|
gsp.types.transbuf.TransBuf
|
Edge colors of the points. |
required |
edge_widths
|
gsp.types.transbuf.TransBuf
|
Edge widths of the points. |
required |
Source code in src/gsp/visuals/points.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
check_attributes() -> None
¶
Check that the attributes are valid and consistent.
Source code in src/gsp/visuals/points.py
132 133 134 | |
get_edge_colors() -> TransBuf
¶
Get edge colors of the points.
Source code in src/gsp/visuals/points.py
80 81 82 | |
get_edge_widths() -> TransBuf
¶
Get edge widths of the points.
Source code in src/gsp/visuals/points.py
93 94 95 | |
get_face_colors() -> TransBuf
¶
Get face colors of the points.
Source code in src/gsp/visuals/points.py
67 68 69 | |
get_positions() -> TransBuf
¶
Get positions of the points.
Source code in src/gsp/visuals/points.py
41 42 43 | |
get_sizes() -> TransBuf
¶
Get sizes of the points.
Source code in src/gsp/visuals/points.py
54 55 56 | |
sanity_check_attributes(positions: TransBuf, sizes: TransBuf, face_colors: TransBuf, edge_colors: TransBuf, edge_widths: TransBuf) -> None
staticmethod
¶
Check that the attributes are valid and consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the points. |
required |
sizes
|
gsp.types.transbuf.TransBuf
|
Sizes of the points. |
required |
face_colors
|
gsp.types.transbuf.TransBuf
|
Face colors of the points. |
required |
edge_colors
|
gsp.types.transbuf.TransBuf
|
Edge colors of the points. |
required |
edge_widths
|
gsp.types.transbuf.TransBuf
|
Edge widths of the points. |
required |
Source code in src/gsp/visuals/points.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
sanity_check_attributes_buffer(positions: Buffer, sizes: Buffer, face_colors: Buffer, edge_colors: Buffer, edge_widths: Buffer)
staticmethod
¶
Same as .sanity_check_attributes() but accept only Buffers.
- It is meant to be used after converting TransBuf to Buffer.
Source code in src/gsp/visuals/points.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
set_attributes(positions: TransBuf | None = None, sizes: TransBuf | None = None, face_colors: TransBuf | None = None, edge_colors: TransBuf | None = None, edge_widths: TransBuf | None = None) -> None
¶
Set multiple attributes at once and then check their validity.
Source code in src/gsp/visuals/points.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
set_edge_colors(edge_colors: TransBuf) -> None
¶
Set edge colors of the points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_colors
|
gsp.types.transbuf.TransBuf
|
New edge colors for the points. |
required |
Source code in src/gsp/visuals/points.py
84 85 86 87 88 89 90 91 | |
set_edge_widths(edge_widths: TransBuf) -> None
¶
Set edge widths of the points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_widths
|
gsp.types.transbuf.TransBuf
|
New edge widths for the points. |
required |
Source code in src/gsp/visuals/points.py
97 98 99 100 101 102 103 104 | |
set_face_colors(face_colors: TransBuf) -> None
¶
Set face colors of the points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_colors
|
gsp.types.transbuf.TransBuf
|
New face colors for the points. |
required |
Source code in src/gsp/visuals/points.py
71 72 73 74 75 76 77 78 | |
set_positions(positions: TransBuf) -> None
¶
Set positions of the points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
New positions for the points. |
required |
Source code in src/gsp/visuals/points.py
45 46 47 48 49 50 51 52 | |
set_sizes(sizes: TransBuf) -> None
¶
Set sizes of the points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sizes
|
gsp.types.transbuf.TransBuf
|
New sizes for the points. |
required |
Source code in src/gsp/visuals/points.py
58 59 60 61 62 63 64 65 | |
gsp.visuals.markers
¶
Marker visual for rendering 2D/3D markers with customizable shapes, sizes, and colors.
Markers
¶
Bases: gsp.types.visual_base.VisualBase
Visual representation of markers with configurable properties.
This class manages marker visualization with properties including shape, positions, sizes, face colors, edge colors, and edge widths.
Attributes:
| Name | Type | Description |
|---|---|---|
_marker_shape |
gsp.types.marker_shape.MarkerShape
|
The shape of the markers. |
_positions |
gsp.types.transbuf.TransBuf
|
The positions of the markers. |
_sizes |
gsp.types.transbuf.TransBuf
|
The sizes of the markers. |
_face_colors |
gsp.types.transbuf.TransBuf
|
The face colors of the markers. |
_edge_colors |
gsp.types.transbuf.TransBuf
|
The edge colors of the markers. |
_edge_widths |
gsp.types.transbuf.TransBuf
|
The edge widths of the markers. |
Source code in src/gsp/visuals/markers.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
__init__(marker_shape: MarkerShape, positions: TransBuf, sizes: TransBuf, face_colors: TransBuf, edge_colors: TransBuf, edge_widths: TransBuf)
¶
Initialize a Markers visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker_shape
|
gsp.types.marker_shape.MarkerShape
|
The shape of the markers. |
required |
positions
|
gsp.types.transbuf.TransBuf
|
The positions of the markers. |
required |
sizes
|
gsp.types.transbuf.TransBuf
|
The sizes of the markers. |
required |
face_colors
|
gsp.types.transbuf.TransBuf
|
The face colors of the markers. |
required |
edge_colors
|
gsp.types.transbuf.TransBuf
|
The edge colors of the markers. |
required |
edge_widths
|
gsp.types.transbuf.TransBuf
|
The edge widths of the markers. |
required |
Source code in src/gsp/visuals/markers.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
check_attributes() -> None
¶
Check that the attributes are valid and consistent.
Source code in src/gsp/visuals/markers.py
182 183 184 | |
get_edge_colors() -> TransBuf
¶
Get the marker edge colors.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The marker edge colors. |
Source code in src/gsp/visuals/markers.py
120 121 122 123 124 125 126 | |
get_edge_widths() -> TransBuf
¶
Get the marker edge widths.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The marker edge widths. |
Source code in src/gsp/visuals/markers.py
137 138 139 140 141 142 143 | |
get_face_colors() -> TransBuf
¶
Get the marker face colors.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The marker face colors. |
Source code in src/gsp/visuals/markers.py
103 104 105 106 107 108 109 | |
get_marker_shape() -> MarkerShape
¶
Get the marker shape.
Returns:
| Name | Type | Description |
|---|---|---|
MarkerShape |
gsp.types.marker_shape.MarkerShape
|
The marker shape. |
Source code in src/gsp/visuals/markers.py
52 53 54 55 56 57 58 | |
get_positions() -> TransBuf
¶
Get the marker positions.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The marker positions. |
Source code in src/gsp/visuals/markers.py
69 70 71 72 73 74 75 | |
get_sizes() -> TransBuf
¶
Get the marker sizes.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
The marker sizes. |
Source code in src/gsp/visuals/markers.py
86 87 88 89 90 91 92 | |
sanity_check_attributes(marker_shape: MarkerShape, positions: TransBuf, sizes: TransBuf, face_colors: TransBuf, edge_colors: TransBuf, edge_widths: TransBuf) -> None
staticmethod
¶
Check that the marker attributes are valid and consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker_shape
|
gsp.types.marker_shape.MarkerShape
|
The marker shape. |
required |
positions
|
gsp.types.transbuf.TransBuf
|
The marker positions. |
required |
sizes
|
gsp.types.transbuf.TransBuf
|
The marker sizes. |
required |
face_colors
|
gsp.types.transbuf.TransBuf
|
The marker face colors. |
required |
edge_colors
|
gsp.types.transbuf.TransBuf
|
The marker edge colors. |
required |
edge_widths
|
gsp.types.transbuf.TransBuf
|
The marker edge widths. |
required |
Source code in src/gsp/visuals/markers.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
sanity_check_attributes_buffer(marker_shape: MarkerShape, positions: Buffer, sizes: Buffer, face_colors: Buffer, edge_colors: Buffer, edge_widths: Buffer)
staticmethod
¶
Same as .sanity_check_attributes() but accept only Buffers.
This method is meant to be used after converting TransBuf to Buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker_shape
|
gsp.types.marker_shape.MarkerShape
|
The marker shape. |
required |
positions
|
gsp.types.buffer.Buffer
|
The marker positions as a Buffer. |
required |
sizes
|
gsp.types.buffer.Buffer
|
The marker sizes as a Buffer. |
required |
face_colors
|
gsp.types.buffer.Buffer
|
The marker face colors as a Buffer. |
required |
edge_colors
|
gsp.types.buffer.Buffer
|
The marker edge colors as a Buffer. |
required |
edge_widths
|
gsp.types.buffer.Buffer
|
The marker edge widths as a Buffer. |
required |
Source code in src/gsp/visuals/markers.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
set_attributes(marker_shape: MarkerShape | None = None, positions: TransBuf | None = None, sizes: TransBuf | None = None, face_colors: TransBuf | None = None, edge_colors: TransBuf | None = None, edge_widths: TransBuf | None = None) -> None
¶
Set multiple attributes at once and then check their validity.
Source code in src/gsp/visuals/markers.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
set_edge_colors(edge_colors: TransBuf) -> None
¶
Set the marker edge colors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_colors
|
gsp.types.transbuf.TransBuf
|
The new marker edge colors. |
required |
Source code in src/gsp/visuals/markers.py
128 129 130 131 132 133 134 135 | |
set_edge_widths(edge_widths: TransBuf) -> None
¶
Set the marker edge widths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_widths
|
gsp.types.transbuf.TransBuf
|
The new marker edge widths. |
required |
Source code in src/gsp/visuals/markers.py
145 146 147 148 149 150 151 152 | |
set_face_colors(face_colors: TransBuf) -> None
¶
Set the marker face colors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_colors
|
gsp.types.transbuf.TransBuf
|
The new marker face colors. |
required |
Source code in src/gsp/visuals/markers.py
111 112 113 114 115 116 117 118 | |
set_marker_shape(marker_shape: MarkerShape) -> None
¶
Set the marker shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marker_shape
|
gsp.types.marker_shape.MarkerShape
|
The new marker shape. |
required |
Source code in src/gsp/visuals/markers.py
60 61 62 63 64 65 66 67 | |
set_positions(positions: TransBuf) -> None
¶
Set the marker positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
The new marker positions. |
required |
Source code in src/gsp/visuals/markers.py
77 78 79 80 81 82 83 84 | |
set_sizes(sizes: TransBuf) -> None
¶
Set the marker sizes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sizes
|
gsp.types.transbuf.TransBuf
|
The new marker sizes. |
required |
Source code in src/gsp/visuals/markers.py
94 95 96 97 98 99 100 101 | |
gsp.visuals.segments
¶
Segments visual module.
Segments
¶
Bases: gsp.types.visual_base.VisualBase
Segments visual for rendering line segments.
This visual represents a collection of line segments with configurable positions, line widths, cap styles, and colors.
Source code in src/gsp/visuals/segments.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
__init__(positions: TransBuf, line_widths: TransBuf, cap_style: CapStyle, colors: TransBuf) -> None
¶
Initialize Segments visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the segment endpoints. |
required |
line_widths
|
gsp.types.transbuf.TransBuf
|
Widths of the line segments. |
required |
cap_style
|
gsp.types.cap_style.CapStyle
|
Cap style for the line segments. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
Colors of the segments. |
required |
Source code in src/gsp/visuals/segments.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
check_attributes() -> None
¶
Check that the attributes are valid and consistent.
Source code in src/gsp/visuals/segments.py
113 114 115 | |
get_cap_style() -> CapStyle
¶
Get cap style of the segments.
Source code in src/gsp/visuals/segments.py
65 66 67 | |
get_colors() -> TransBuf
¶
Get colors of the segments.
Source code in src/gsp/visuals/segments.py
78 79 80 | |
get_line_widths() -> TransBuf
¶
Get line widths of the segments.
Source code in src/gsp/visuals/segments.py
52 53 54 | |
get_positions() -> TransBuf
¶
Get positions of the segment endpoints.
Source code in src/gsp/visuals/segments.py
39 40 41 | |
sanity_check_attributes(positions: TransBuf, line_widths: TransBuf, cap_style: CapStyle, colors: TransBuf) -> None
staticmethod
¶
Check that the attributes are valid and consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the segment endpoints. |
required |
line_widths
|
gsp.types.transbuf.TransBuf
|
Widths of the line segments. |
required |
cap_style
|
gsp.types.cap_style.CapStyle
|
Cap style for the line segments. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
Colors of the segments. |
required |
Source code in src/gsp/visuals/segments.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
sanity_check_attributes_buffer(positions: Buffer, line_widths: Buffer, cap_style: CapStyle, colors: Buffer) -> None
staticmethod
¶
Same as .sanity_check_attributes() but accept only Buffers.
- It is meant to be used after converting TransBuf to Buffer.
Source code in src/gsp/visuals/segments.py
117 118 119 120 121 122 123 124 125 126 127 128 | |
set_attributes(positions: TransBuf | None = None, line_widths: TransBuf | None = None, cap_style: CapStyle | None = None, colors: TransBuf | None = None) -> None
¶
Set multiple attributes at once and then check their validity.
Source code in src/gsp/visuals/segments.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
set_cap_style(cap_style: CapStyle) -> None
¶
Set cap style of the segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cap_style
|
gsp.types.cap_style.CapStyle
|
New cap style for the segments. |
required |
Source code in src/gsp/visuals/segments.py
69 70 71 72 73 74 75 76 | |
set_colors(colors: TransBuf) -> None
¶
Set colors of the segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
gsp.types.transbuf.TransBuf
|
New colors for the segments. |
required |
Source code in src/gsp/visuals/segments.py
82 83 84 85 86 87 88 89 | |
set_line_widths(line_widths: TransBuf) -> None
¶
Set line widths of the segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_widths
|
gsp.types.transbuf.TransBuf
|
New line widths for the segments. |
required |
Source code in src/gsp/visuals/segments.py
56 57 58 59 60 61 62 63 | |
set_positions(positions: TransBuf) -> None
¶
Set positions of the segment endpoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
New positions for the segments. |
required |
Source code in src/gsp/visuals/segments.py
43 44 45 46 47 48 49 50 | |
gsp.visuals.paths
¶
Path rendering visual for drawing connected line segments.
This module provides the Paths visual class for rendering continuous paths with customizable line widths, colors, cap styles, and join styles.
Paths
¶
Bases: gsp.types.visual_base.VisualBase
Visual for rendering continuous paths with customizable styling.
Paths are sequences of connected line segments that can have varying colors, line widths, and end/join styling.
Source code in src/gsp/visuals/paths.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
__init__(positions: TransBuf, path_sizes: TransBuf, colors: TransBuf, line_widths: TransBuf, cap_style: CapStyle, join_style: JoinStyle) -> None
¶
Initialize the Paths visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
3D positions for all path vertices. |
required |
path_sizes
|
gsp.types.transbuf.TransBuf
|
Number of vertices in each path. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
RGBA colors for each path. |
required |
line_widths
|
gsp.types.transbuf.TransBuf
|
Line widths for each path. |
required |
cap_style
|
gsp.types.cap_style.CapStyle
|
Style for line endings (round, square, butt). |
required |
join_style
|
gsp.types.join_style.JoinStyle
|
Style for line joins (miter, bevel, round). |
required |
Source code in src/gsp/visuals/paths.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
check_attributes() -> None
¶
Check that the attributes are valid and consistent.
Source code in src/gsp/visuals/paths.py
188 189 190 | |
get_cap_style() -> CapStyle
¶
Get the cap style.
Returns:
| Name | Type | Description |
|---|---|---|
CapStyle |
gsp.types.cap_style.CapStyle
|
Style for line endings (round, square, butt). |
Source code in src/gsp/visuals/paths.py
134 135 136 137 138 139 140 | |
get_colors() -> TransBuf
¶
Get the colors buffer.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
RGBA colors for each path. |
Source code in src/gsp/visuals/paths.py
83 84 85 86 87 88 89 | |
get_join_style() -> JoinStyle
¶
Get the join style.
Returns:
| Name | Type | Description |
|---|---|---|
JoinStyle |
gsp.types.join_style.JoinStyle
|
Style for line joins (miter, bevel, round). |
Source code in src/gsp/visuals/paths.py
117 118 119 120 121 122 123 | |
get_line_widths() -> TransBuf
¶
Get the line widths buffer.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
Line widths for each path. |
Source code in src/gsp/visuals/paths.py
100 101 102 103 104 105 106 | |
get_path_sizes() -> TransBuf
¶
Get the path sizes buffer.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
Number of vertices in each path. |
Source code in src/gsp/visuals/paths.py
66 67 68 69 70 71 72 | |
get_positions() -> TransBuf
¶
Get the positions buffer.
Returns:
| Name | Type | Description |
|---|---|---|
TransBuf |
gsp.types.transbuf.TransBuf
|
3D positions for all path vertices. |
Source code in src/gsp/visuals/paths.py
49 50 51 52 53 54 55 | |
sanity_check_attributes(positions: TransBuf, path_sizes: TransBuf, colors: TransBuf, line_widths: TransBuf, cap_style: CapStyle, join_style: JoinStyle) -> None
staticmethod
¶
Validate attribute dimensions and compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
3D positions for all path vertices. |
required |
path_sizes
|
gsp.types.transbuf.TransBuf
|
Number of vertices in each path. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
RGBA colors for each path. |
required |
line_widths
|
gsp.types.transbuf.TransBuf
|
Line widths for each path. |
required |
cap_style
|
gsp.types.cap_style.CapStyle
|
Style for line endings. |
required |
join_style
|
gsp.types.join_style.JoinStyle
|
Style for line joins. |
required |
Source code in src/gsp/visuals/paths.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
sanity_check_attributes_buffer(positions: Buffer, path_sizes: Buffer, colors: Buffer, line_widths: Buffer, cap_style: CapStyle, join_style: JoinStyle) -> None
staticmethod
¶
Same as .sanity_check_attributes() but accept only Buffers.
It is meant to be used after converting TransBuf to Buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.buffer.Buffer
|
3D positions for all path vertices. |
required |
path_sizes
|
gsp.types.buffer.Buffer
|
Number of vertices in each path. |
required |
colors
|
gsp.types.buffer.Buffer
|
RGBA colors for each path. |
required |
line_widths
|
gsp.types.buffer.Buffer
|
Line widths for each path. |
required |
cap_style
|
gsp.types.cap_style.CapStyle
|
Style for line endings. |
required |
join_style
|
gsp.types.join_style.JoinStyle
|
Style for line joins. |
required |
Source code in src/gsp/visuals/paths.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
set_attributes(positions: TransBuf | None = None, path_sizes: TransBuf | None = None, colors: TransBuf | None = None, line_widths: TransBuf | None = None, cap_style: CapStyle | None = None, join_style: JoinStyle | None = None) -> None
¶
Set multiple attributes at once and then check their validity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf | None
|
3D positions for all path vertices. |
None
|
path_sizes
|
gsp.types.transbuf.TransBuf | None
|
Number of vertices in each path. |
None
|
colors
|
gsp.types.transbuf.TransBuf | None
|
RGBA colors for each path. |
None
|
line_widths
|
gsp.types.transbuf.TransBuf | None
|
Line widths for each path. |
None
|
cap_style
|
gsp.types.cap_style.CapStyle | None
|
Style for line endings (round, square, butt). |
None
|
join_style
|
gsp.types.join_style.JoinStyle | None
|
Style for line joins (miter, bevel, round). |
None
|
Source code in src/gsp/visuals/paths.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
set_cap_style(cap_style: CapStyle) -> None
¶
Set the cap style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cap_style
|
gsp.types.cap_style.CapStyle
|
Style for line endings (round, square, butt). |
required |
Source code in src/gsp/visuals/paths.py
142 143 144 145 146 147 148 149 | |
set_colors(colors: TransBuf) -> None
¶
Set the colors buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
gsp.types.transbuf.TransBuf
|
RGBA colors for each path. |
required |
Source code in src/gsp/visuals/paths.py
91 92 93 94 95 96 97 98 | |
set_join_style(join_style: JoinStyle) -> None
¶
Set the join style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
join_style
|
gsp.types.join_style.JoinStyle
|
Style for line joins (miter, bevel, round). |
required |
Source code in src/gsp/visuals/paths.py
125 126 127 128 129 130 131 132 | |
set_line_widths(line_widths: TransBuf) -> None
¶
Set the line widths buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_widths
|
gsp.types.transbuf.TransBuf
|
Line widths for each path. |
required |
Source code in src/gsp/visuals/paths.py
108 109 110 111 112 113 114 115 | |
set_path_sizes(path_sizes: TransBuf) -> None
¶
Set the path sizes buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_sizes
|
gsp.types.transbuf.TransBuf
|
Number of vertices in each path. |
required |
Source code in src/gsp/visuals/paths.py
74 75 76 77 78 79 80 81 | |
set_positions(positions: TransBuf) -> None
¶
Set the positions buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
3D positions for all path vertices. |
required |
Source code in src/gsp/visuals/paths.py
57 58 59 60 61 62 63 64 | |
gsp.visuals.pixels
¶
Pixels visual module.
Pixels
¶
Bases: gsp.types.visual_base.VisualBase
Pixels visual for rendering individual colored pixels.
This visual represents a collection of pixels with configurable positions, colors, and groups for efficient rendering.
Source code in src/gsp/visuals/pixels.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
__init__(positions: TransBuf, colors: TransBuf, groups: Groups)
¶
Initialize Pixels visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the pixels. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
Colors of the pixels. |
required |
groups
|
gsp.types.group.Groups
|
Groups for organizing pixels. |
required |
Source code in src/gsp/visuals/pixels.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
__repr__() -> str
¶
Return string representation of the Pixels visual.
Source code in src/gsp/visuals/pixels.py
35 36 37 | |
check_attributes() -> None
¶
Check that the attributes are valid and consistent.
Source code in src/gsp/visuals/pixels.py
96 97 98 | |
get_colors() -> TransBuf
¶
Get colors of the pixels.
Source code in src/gsp/visuals/pixels.py
56 57 58 | |
get_groups() -> Groups
¶
Get groups for organizing pixels.
Source code in src/gsp/visuals/pixels.py
69 70 71 | |
get_positions() -> TransBuf
¶
Get positions of the pixels.
Source code in src/gsp/visuals/pixels.py
43 44 45 | |
sanity_check_attribute_buffers(positions: Buffer, colors: Buffer, groups: Groups)
staticmethod
¶
Same as .sanity_check_attributes() but accept only Buffers.
- It is meant to be used after converting TransBuf to Buffer.
Source code in src/gsp/visuals/pixels.py
100 101 102 103 104 105 106 107 108 109 110 | |
sanity_check_attributes(positions: TransBuf, colors: TransBuf, groups: Groups)
staticmethod
¶
Check that the attributes are valid and consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the pixels. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
Colors of the pixels. |
required |
groups
|
gsp.types.group.Groups
|
Groups for organizing pixels. |
required |
Source code in src/gsp/visuals/pixels.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
set_attributes(positions: TransBuf | None = None, colors: TransBuf | None = None, groups: Groups | None = None) -> None
¶
Set multiple attributes at once and then check their validity.
Source code in src/gsp/visuals/pixels.py
82 83 84 85 86 87 88 89 90 | |
set_colors(colors: TransBuf) -> None
¶
Set colors of the pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
gsp.types.transbuf.TransBuf
|
New colors for the pixels. |
required |
Source code in src/gsp/visuals/pixels.py
60 61 62 63 64 65 66 67 | |
set_groups(groups: Groups) -> None
¶
Set groups for organizing pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups
|
gsp.types.group.Groups
|
New groups for the pixels. |
required |
Source code in src/gsp/visuals/pixels.py
73 74 75 76 77 78 79 80 | |
set_positions(positions: TransBuf) -> None
¶
Set positions of the pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
New positions for the pixels. |
required |
Source code in src/gsp/visuals/pixels.py
47 48 49 50 51 52 53 54 | |
gsp.visuals.texts
¶
Texts visual module.
Texts
¶
Bases: gsp.types.visual_base.VisualBase
Texts visual.
Source code in src/gsp/visuals/texts.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
__init__(positions: TransBuf, strings: list[str], colors: TransBuf, font_sizes: TransBuf, anchors: TransBuf, angles: TransBuf, font_name: str) -> None
¶
Initialize Texts visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the texts. |
required |
strings
|
list[str]
|
List of text strings. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
Colors of the texts. |
required |
font_sizes
|
gsp.types.transbuf.TransBuf
|
Font sizes of the texts. |
required |
anchors
|
gsp.types.transbuf.TransBuf
|
Anchor positions of the texts. |
required |
angles
|
gsp.types.transbuf.TransBuf
|
Rotation angles of the texts. |
required |
font_name
|
str
|
Font name for the texts. |
required |
Source code in src/gsp/visuals/texts.py
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 | |
check_attributes() -> None
¶
Check that the attributes are valid and consistent.
Source code in src/gsp/visuals/texts.py
171 172 173 | |
get_anchors() -> TransBuf
¶
Get anchor positions of the texts.
Source code in src/gsp/visuals/texts.py
101 102 103 | |
get_angles() -> TransBuf
¶
Get rotation angles of the texts.
Source code in src/gsp/visuals/texts.py
114 115 116 | |
get_colors() -> TransBuf
¶
Get colors of the texts.
Source code in src/gsp/visuals/texts.py
75 76 77 | |
get_font_name() -> str
¶
Get font name used for the texts.
Source code in src/gsp/visuals/texts.py
127 128 129 | |
get_font_sizes() -> TransBuf
¶
Get font sizes of the texts.
Source code in src/gsp/visuals/texts.py
88 89 90 | |
get_positions() -> TransBuf
¶
Get positions of the texts.
Source code in src/gsp/visuals/texts.py
49 50 51 | |
get_strings() -> list[str]
¶
Get text strings.
Source code in src/gsp/visuals/texts.py
62 63 64 | |
sanity_check_attributes(positions: TransBuf, strings: list[str], colors: TransBuf, font_sizes: TransBuf, anchors: TransBuf, angles: TransBuf, font_name: str) -> None
staticmethod
¶
Check that the attributes are valid and consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
Positions of the texts. |
required |
strings
|
list[str]
|
List of text strings. |
required |
colors
|
gsp.types.transbuf.TransBuf
|
Colors of the texts. |
required |
font_sizes
|
gsp.types.transbuf.TransBuf
|
Font sizes of the texts. |
required |
anchors
|
gsp.types.transbuf.TransBuf
|
Anchor positions of the texts. |
required |
angles
|
gsp.types.transbuf.TransBuf
|
Rotation angles of the texts. |
required |
font_name
|
str
|
Font name for the texts. |
required |
Source code in src/gsp/visuals/texts.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
sanity_check_attributes_buffer(positions: Buffer, strings: list[str], colors: Buffer, font_sizes: Buffer, anchors: Buffer, angles: Buffer, font_name: str) -> None
staticmethod
¶
Same as .sanity_check_attributes() but accept only Buffers.
- It is meant to be used after converting TransBuf to Buffer.
Source code in src/gsp/visuals/texts.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
set_anchors(anchors: TransBuf) -> None
¶
Set anchor positions of the texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchors
|
gsp.types.transbuf.TransBuf
|
New anchor positions for the texts. |
required |
Source code in src/gsp/visuals/texts.py
105 106 107 108 109 110 111 112 | |
set_angles(angles: TransBuf) -> None
¶
Set rotation angles of the texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angles
|
gsp.types.transbuf.TransBuf
|
New rotation angles for the texts. |
required |
Source code in src/gsp/visuals/texts.py
118 119 120 121 122 123 124 125 | |
set_attributes(positions: TransBuf | None = None, strings: list[str] | None = None, colors: TransBuf | None = None, font_sizes: TransBuf | None = None, anchors: TransBuf | None = None, angles: TransBuf | None = None, font_name: str | None = None) -> None
¶
Set multiple attributes at once and then check their validity.
Source code in src/gsp/visuals/texts.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
set_colors(colors: TransBuf) -> None
¶
Set colors of the texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
gsp.types.transbuf.TransBuf
|
New colors for the texts. |
required |
Source code in src/gsp/visuals/texts.py
79 80 81 82 83 84 85 86 | |
set_font_name(font_name: str) -> None
¶
Set font name for the texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font_name
|
str
|
New font name for the texts. |
required |
Source code in src/gsp/visuals/texts.py
131 132 133 134 135 136 137 138 | |
set_font_sizes(font_sizes: TransBuf) -> None
¶
Set font sizes of the texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font_sizes
|
gsp.types.transbuf.TransBuf
|
New font sizes for the texts. |
required |
Source code in src/gsp/visuals/texts.py
92 93 94 95 96 97 98 99 | |
set_positions(positions: TransBuf) -> None
¶
Set positions of the texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
gsp.types.transbuf.TransBuf
|
New positions for the texts. |
required |
Source code in src/gsp/visuals/texts.py
53 54 55 56 57 58 59 60 | |
set_strings(strings: list[str]) -> None
¶
Set text strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strings
|
list[str]
|
New text strings. |
required |
Source code in src/gsp/visuals/texts.py
66 67 68 69 70 71 72 73 | |
Transforms Module¶
gsp.transforms
¶
GSP Transforms Package.
gsp.transforms.transform_chain
¶
Transform chain module for composing transformations.
This module provides the TransformChain class which allows chaining multiple transform links to process data through a series of transformations.
TransformChain
¶
Chain of transformations to apply to data.
Source code in src/gsp/transforms/transform_chain.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
__buffer_count = buffer_count
instance-attribute
¶
Number of elements in the output Buffer. -1 if not defined yet.
__buffer_type = buffer_type
instance-attribute
¶
Type of the output Buffer. None if not defined yet.
__links: list[TransformLinkBase] = []
instance-attribute
¶
Ordered list of links defining the transform.
__init__(buffer_count: int, buffer_type: BufferType | None) -> None
¶
Initialize a TransformChain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buffer_count
|
int
|
Number of elements in the output Buffer. -1 if not defined yet. |
required |
buffer_type
|
gsp.types.BufferType | None
|
Type of the output Buffer. None if not defined yet. |
required |
Source code in src/gsp/transforms/transform_chain.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
add(link: TransformLinkBase) -> None
¶
Add a TransformLink to the chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
gsp.transforms.transform_link_base.TransformLinkBase
|
The TransformLink to add to the chain. |
required |
Source code in src/gsp/transforms/transform_chain.py
103 104 105 106 107 108 109 | |
deserialize(data: dict[str, Any]) -> TransformChain
staticmethod
¶
Deserialize a TransformChain from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, typing.Any]
|
The serialized TransformChain. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TransformChain |
gsp.transforms.transform_chain.TransformChain
|
The deserialized TransformChain instance. |
Source code in src/gsp/transforms/transform_chain.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
get_buffer_count() -> int
¶
Get the number of elements in the output Buffer.
Note
This method should only be called if is_fully_defined() returns True.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of elements in the output Buffer. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If buffer_type is None or buffer_count is negative. |
Source code in src/gsp/transforms/transform_chain.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
get_buffer_type() -> BufferType
¶
Get the type of the output Buffer.
Note
This method should only be called if is_fully_defined() returns True.
Returns:
| Name | Type | Description |
|---|---|---|
BufferType |
gsp.types.BufferType
|
The type of the output Buffer. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If buffer_type is None or buffer_count is negative. |
Source code in src/gsp/transforms/transform_chain.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
is_fully_defined() -> bool
¶
Check if the TransformChain is fully defined.
A TransformChain is fully defined when both buffer_type is not None and buffer_count is >= 0.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if fully defined, False otherwise. |
Source code in src/gsp/transforms/transform_chain.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
remove(link: TransformLinkBase) -> None
¶
Remove a TransformLink from the chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
gsp.transforms.transform_link_base.TransformLinkBase
|
The TransformLink to remove from the chain. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the link is not found in the chain. |
Source code in src/gsp/transforms/transform_chain.py
111 112 113 114 115 116 117 118 119 120 | |
run() -> Buffer
¶
Compute the transform and return a Buffer with the result.
Applies each link in the chain sequentially, passing the output of each link to the next link in the chain.
Returns:
| Name | Type | Description |
|---|---|---|
Buffer |
gsp.types.Buffer
|
The final transformed buffer. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If no buffer is produced by the transform chain. |
Source code in src/gsp/transforms/transform_chain.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
serialize() -> dict[str, Any]
¶
Serialize the TransformChain to a dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
dict[str, Any]: The serialized TransformChain containing buffer_count, buffer_type, and links. |
Source code in src/gsp/transforms/transform_chain.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
gsp.transforms.transform_link_base
¶
Transform Link Base Module.
TransformLinkBase
¶
Bases: abc.ABC
Base class for a link in a Transform chain.
Source code in src/gsp/transforms/transform_link_base.py
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 | |
apply(buffer_src: Buffer | None) -> Buffer
abstractmethod
¶
Apply the transformation to the given buffer and return a new buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buffer_src
|
gsp.types.Buffer | None
|
The source buffer to transform. Can be None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Buffer |
gsp.types.Buffer
|
The transformed buffer. |
Source code in src/gsp/transforms/transform_link_base.py
16 17 18 19 20 21 22 23 24 25 26 | |
deserialize(data: dict[str, Any]) -> TransformLinkBase
abstractmethod
staticmethod
¶
Deserialize a TransformLink from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, typing.Any]
|
The serialized TransformLink. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TransformLinkBase |
gsp.transforms.transform_link_base.TransformLinkBase
|
The deserialized TransformLink instance. |
Source code in src/gsp/transforms/transform_link_base.py
37 38 39 40 41 42 43 44 45 46 47 48 | |
serialize() -> dict[str, Any]
abstractmethod
¶
Serialize the TransformLink to a dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
dict[str, Any]: The serialized TransformLink. |
Source code in src/gsp/transforms/transform_link_base.py
28 29 30 31 32 33 34 35 | |
Utilities Module¶
gsp.utils
¶
Utility modules for GSP.
gsp.utils.cmap_utils
¶
Colormap utilities for mapping values to colors using matplotlib colormaps.
CmapUtils
¶
Utility class for colormap operations. Leverage matplotlib colormaps.
Source code in src/gsp/utils/cmap_utils.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
get_color_map(colormap_name: str, values: np.ndarray, vmin: float | None = None, vmax: float | None = None) -> Buffer
staticmethod
¶
Get colors from a colormap for the given values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colormap_name
|
str
|
Name of the colormap (e.g., 'plasma', 'viridis', etc.). |
required |
values
|
numpy.ndarray
|
Array of input values to map to colors. |
required |
vmin
|
float | None
|
Minimum value for values normalization. if None, use min of values. |
None
|
vmax
|
float | None
|
Maximum value for values normalization. if None, use max of values. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Buffer |
gsp.types.Buffer
|
A Buffer containing the RGBA8 colors mapped from the input values. |
Source code in src/gsp/utils/cmap_utils.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
has_color_map(colormap_name: str) -> bool
staticmethod
¶
Check if the given colormap name is recognized by matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colormap_name
|
str
|
Name of the colormap to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the colormap exists, False otherwise. |
Source code in src/gsp/utils/cmap_utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
gsp.utils.group_utils
¶
Utility functions for handling and manipulating group objects.
This module provides utilities for working with Groups, which can be represented in multiple formats: int, list[int], or list[list[int]].
GroupUtils
¶
Utility class for group operations and validation.
This class provides static methods for: - Validating group objects - Computing group counts and indices - Converting between different group formats
Source code in src/gsp/utils/group_utils.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
compute_indices_per_group(vertex_count: int, groups: Groups) -> list[list[int]]
staticmethod
¶
Compute indices_per_group for groups depending on the type of groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertex_count
|
int
|
number of vertices |
required |
groups
|
gsp.types.group.Groups
|
groups object |
required |
Returns:
| Type | Description |
|---|---|
list[list[int]]
|
list[list[int]]: list of vertex indices per group |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
if the groups object type is not supported |
Source code in src/gsp/utils/group_utils.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
get_group_count(vertex_count: int, groups: Groups) -> int
staticmethod
¶
Return the number of groups from the groups object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertex_count
|
int
|
number of vertices |
required |
groups
|
gsp.types.group.Groups
|
groups object |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
number of groups |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
if the groups object type is not supported |
Source code in src/gsp/utils/group_utils.py
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 | |
is_instance_of_groups(groups: Groups) -> bool
staticmethod
¶
Check if the type of groups is valid.
Deep check where all elements are checked. Does not check the values themselves, only the types.
Groups can be: - int - list[int] - list[list[int]]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups
|
gsp.types.group.Groups
|
groups object |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if groups is a valid Groups object, False otherwise. |
Source code in src/gsp/utils/group_utils.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
sanity_check(vertex_count: int, groups: Groups) -> None
staticmethod
¶
Perform sanity checks on the groups object, raising exceptions if not valid.
Raise
ValueError: if the groups object is not valid.
Source code in src/gsp/utils/group_utils.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
sanity_check_safe(vertex_count: int, groups: Groups) -> bool
staticmethod
¶
Perform sanity checks on the groups object.
Same as .sanity_check_groups() but does not raise exceptions if not valid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertex_count
|
int
|
number of vertices |
required |
groups
|
gsp.types.group.Groups
|
groups object |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the groups object is valid, False otherwise. |
Source code in src/gsp/utils/group_utils.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
gsp.utils.math_utils
¶
Mathematical utility functions for GSP.
This module provides mathematical operations and transformations used throughout the GSP library, including: - Model-View-Projection (MVP) transformations for 3D graphics
MathUtils
¶
Utility class for mathematical operations in GSP.
This class provides static methods for common mathematical operations used in graphics programming, such as matrix transformations.
Source code in src/gsp/utils/math_utils.py
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 54 55 56 57 58 59 | |
apply_mvp_to_vertices(vertices: np.ndarray, model_matrix: np.ndarray, view_matrix: np.ndarray, projection_matrix: np.ndarray) -> np.ndarray
staticmethod
¶
Applies Model-View-Projection transformation to the vertices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertices
|
numpy.ndarray
|
Input vertices of shape (N, 3). |
required |
model_matrix
|
numpy.ndarray
|
Model matrix of shape (4, 4). |
required |
view_matrix
|
numpy.ndarray
|
View matrix of shape (4, 4). |
required |
projection_matrix
|
numpy.ndarray
|
Projection matrix of shape (4, 4). |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
np.ndarray: Transformed vertices of shape (N, 3). |
Source code in src/gsp/utils/math_utils.py
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 54 55 56 57 58 59 | |
gsp.utils.transbuf_utils
¶
Utility functions for working with TransBuf objects.
This module provides helper functions to convert TransBuf instances to Buffer objects, handling both direct Buffer instances and TransformChain objects.
TransBufUtils
¶
Utility class for TransBuf conversions and operations.
This class provides static methods for converting TransBuf objects to Buffer objects, supporting both direct Buffer instances and TransformChain objects that need to be executed.
Source code in src/gsp/utils/transbuf_utils.py
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 | |
to_buffer(trans_buf: TransBuf) -> Buffer
staticmethod
¶
Convert a TransBuf to a Buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trans_buf
|
gsp.types.transbuf.TransBuf
|
A TransBuf object which can be either a Buffer or a TransformChain. |
required |
Returns:
| Type | Description |
|---|---|
gsp.types.buffer.Buffer
|
A Buffer object. If the input is already a Buffer, it's returned directly. |
gsp.types.buffer.Buffer
|
If it's a TransformChain, it's executed and the resulting Buffer is returned. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the trans_buf is neither a Buffer nor a TransformChain. |
Source code in src/gsp/utils/transbuf_utils.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
gsp.utils.unit_utils
¶
"Utility functions for unit conversions related to display and typography.
UnitUtils
¶
Utility class for unit conversions related to display and typography.
Source code in src/gsp/utils/unit_utils.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
cm_to_in(cm: float) -> float
staticmethod
¶
Convert centimeters to inches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cm
|
float
|
Length in centimeters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Length in inches. |
Source code in src/gsp/utils/unit_utils.py
28 29 30 31 32 33 34 35 36 37 38 | |
device_pixel_ratio() -> float
staticmethod
¶
Get the device pixel ratio for high-DPI displays.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Device pixel ratio (typically 1.0 for standard displays, >1.0 for high-DPI). |
Source code in src/gsp/utils/unit_utils.py
40 41 42 43 44 45 46 47 48 49 50 51 52 | |
in_to_cm(inches: float) -> float
staticmethod
¶
Convert inches to centimeters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inches
|
float
|
Length in inches. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Length in centimeters. |
Source code in src/gsp/utils/unit_utils.py
16 17 18 19 20 21 22 23 24 25 26 | |
pixel_to_point(pixel_size: float, dpi: float) -> float
staticmethod
¶
Convert pixel size to typographic point size based on DPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_size
|
float
|
Size in pixels. |
required |
dpi
|
float
|
Dots per inch of the display. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Size in points. |
Source code in src/gsp/utils/unit_utils.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
pixel_to_point_numpy(pixel_sizes: np.ndarray, dpi: float) -> np.ndarray
staticmethod
¶
Convert an array of pixel sizes to point sizes based on DPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_sizes
|
numpy.ndarray
|
Array of sizes in pixels. |
required |
dpi
|
float
|
Dots per inch of the display. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
np.ndarray: Array of sizes in points. |
Source code in src/gsp/utils/unit_utils.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
point_to_pixel(point_size: float, dpi: float) -> float
staticmethod
¶
Convert point size to pixel size based on DPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_size
|
float
|
Size in points. |
required |
dpi
|
float
|
Dots per inch of the display. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Size in pixels. |
Source code in src/gsp/utils/unit_utils.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
point_to_pixel_numpy(point_sizes: np.ndarray, dpi: float) -> np.ndarray
staticmethod
¶
Convert an array of point sizes to pixel sizes based on DPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_sizes
|
numpy.ndarray
|
Array of sizes in points. |
required |
dpi
|
float
|
Dots per inch of the display. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
np.ndarray: Array of sizes in pixels. |
Source code in src/gsp/utils/unit_utils.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
gsp.utils.uuid_utils
¶
Utility functions for UUID generation.
UuidUtils
¶
Utility class for generating UUIDs.
Source code in src/gsp/utils/uuid_utils.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
generate_uuid() -> str
staticmethod
¶
Generate a UUID version 4.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The generated UUID. |
Source code in src/gsp/utils/uuid_utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
Constants¶
gsp.constants
¶
Common constants for GSP including color definitions.
Constants
¶
Common constants in GSP. e.g. colors.
Source code in src/gsp/constants.py
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 | |
Color
¶
Common colors as RGBA bytearrays.
Each color is represented as a bytearray of four integers corresponding to the red, green, blue, and alpha (opacity) channels, respectively. Each channel value ranges from 0 to 255.
Source code in src/gsp/constants.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |