Segments
Segments
Quick documentation
Segments are line segments between two vertices. They can be colored and styled (dash pattern). They possess a thickness but always face the viewer such that their apparent thickness is constant. Their end points (caps) can be styled following the SVG specification (butt, round or cap).
import numpy as np
import matplotlib.pyplot as plt
from gsp import core, visual, transform, glm
canvas = core.Canvas(512, 512, 100.0)
viewport = core.Viewport(canvas, 0, 0, 512, 512)
camera = glm.Camera("ortho")
n = 50
P = glm.vec3(2*n).reshape(-1,2,3)
P[:] = (0.0, -0.5, 0.0), (0.0, +0.5, 0.0)
P[:,0,0] = np.linspace(-0.75, +0.75, n)
P[:,1,0] = P[:,0,0] + 0.1
LW = np.linspace(0.1, 5.0, n)
points = visual.Segments(P, line_widths=LW)
points.render(viewport, camera.model, camera.view, camera.proj)
plt.show()
__init__
Create a visual of n segments at given positions with given line_colors, line_widths and line_caps.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
positions |
Transform | Buffer
|
Points position (vec3) |
required |
line_caps |
Transform | Buffer
|
Line caps (vec2) |
LineCap.round
|
line_colors |
Transform | Buffer | Color
|
Points line colors (vec4) |
Color(0, 0, 0, 1)
|
line_widths |
Transform | Buffer | Measure
|
Points line colors (vec4) |
1
|
render
Render the visual on viewport using the given model, view, proj matrices
Parameters:
Name | Type | Description | Default |
---|---|---|---|
viewport |
Viewport
|
Viewport where to render the visual |
None
|
model |
mat4
|
Model matrix to use for rendering |
None
|
view |
mat4
|
View matrix to use for rendering |
None
|
proj |
mat4
|
Projection matrix to use for rendering |
None
|