MCPcopy Create free account
hub / github.com/vispy/vispy / STTransform

Class STTransform

vispy/visuals/transforms/linear.py:54–313  ·  view source on GitHub ↗

Transform performing only scale and translate, in that order. Parameters ---------- scale : array-like Scale factors for X, Y, Z axes. translate : array-like Scale factors for X, Y, Z axes.

Source from the content-addressed store, hash-verified

52
53
54class STTransform(BaseTransform):
55 """Transform performing only scale and translate, in that order.
56
57 Parameters
58 ----------
59 scale : array-like
60 Scale factors for X, Y, Z axes.
61 translate : array-like
62 Scale factors for X, Y, Z axes.
63 """
64
65 glsl_map = """
66 vec4 st_transform_map(vec4 pos) {
67 return vec4(pos.xyz * $scale.xyz + $translate.xyz * pos.w, pos.w);
68 }
69 """
70
71 glsl_imap = """
72 vec4 st_transform_imap(vec4 pos) {
73 return vec4((pos.xyz - $translate.xyz * pos.w) / $scale.xyz,
74 pos.w);
75 }
76 """
77
78 Linear = True
79 Orthogonal = True
80 NonScaling = False
81 Isometric = False
82
83 def __init__(self, scale=None, translate=None):
84 super(STTransform, self).__init__()
85
86 self._scale = np.ones(4, dtype=np.float32)
87 self._translate = np.zeros(4, dtype=np.float32)
88
89 s = ((1.0, 1.0, 1.0, 1.0) if scale is None else
90 as_vec4(scale, default=(1., 1., 1., 1.)))
91 t = ((0.0, 0.0, 0.0, 0.0) if translate is None else
92 as_vec4(translate, default=(0., 0., 0., 0.)))
93 self._set_st(s, t)
94 self._update_shaders()
95
96 @arg_to_vec4
97 def map(self, coords):
98 """Map coordinates
99
100 Parameters
101 ----------
102 coords : array-like
103 Coordinates to map.
104
105 Returns
106 -------
107 coords : ndarray
108 Coordinates.
109 """
110 m = np.empty(coords.shape)
111 m[:, :3] = (coords[:, :3] * self.scale[np.newaxis, :3] +

Callers 15

test_canvas_renderFunction · 0.90
test_blend_presetsFunction · 0.90
test_transformsFunction · 0.90
test_canvas_renderFunction · 0.90
test_blend_presetsFunction · 0.90
test_multiprogramFunction · 0.90
test_histogramFunction · 0.90
sphere.pyFile · 0.90
save_animation.pyFile · 0.90
colored_line.pyFile · 0.90
magnify.pyFile · 0.90

Calls

no outgoing calls

Tested by 9

test_canvas_renderFunction · 0.72
test_blend_presetsFunction · 0.72
test_transformsFunction · 0.72
test_canvas_renderFunction · 0.72
test_blend_presetsFunction · 0.72
test_multiprogramFunction · 0.72
test_histogramFunction · 0.72
test_gridlinesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…