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

Function test_example2

vispy/visuals/shaders/tests/test_function.py:85–119  ·  view source on GitHub ↗

Demonstrate how a transform would work.

()

Source from the content-addressed store, hash-verified

83
84
85def test_example2():
86 """Demonstrate how a transform would work."""
87 vert_template = Function("""
88 void main(void)
89 {
90 gl_Position = $position;
91 }
92 """)
93
94 transformScale = Function("""
95 vec4 transform_scale(vec4 pos)
96 {
97 pos.xyz *= $scale;
98 return pos;
99 }
100 """)
101
102 class Transform(object):
103 def __init__(self):
104 # Equivalent methods to create new function object
105 self.func = Function(transformScale)
106 self.func['scale'] = 'uniform float'
107 # self.func = Function(transformScale)
108
109 def set_scale(self, scale):
110 self.func['scale'].value = scale
111
112 transforms = [Transform(), Transform(), Transform()]
113
114 code = Function(vert_template)
115 ob = Variable('attribute vec3 a_position')
116 for trans in transforms:
117 ob = trans.func(ob)
118 code['position'] = ob
119 print(code)
120
121# Tests
122

Callers

nothing calls this directly

Calls 3

FunctionClass · 0.90
VariableClass · 0.90
TransformClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…