diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-19 23:32:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-19 23:38:20 +0300 |
commit | 3c8c9760865d14c8dffa3a4cd091e4027b1501e3 (patch) | |
tree | 50639787a78d9bc592d8235c14655bc535ca0349 /doc/python_api/examples/gpu.11.py | |
parent | 5f21030a81fa306f807be5bee8bb1df8dd93a98e (diff) |
Cleanup: gpu docs
Diffstat (limited to 'doc/python_api/examples/gpu.11.py')
-rw-r--r-- | doc/python_api/examples/gpu.11.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/doc/python_api/examples/gpu.11.py b/doc/python_api/examples/gpu.11.py index 61e7a842a59..2f255b7127d 100644 --- a/doc/python_api/examples/gpu.11.py +++ b/doc/python_api/examples/gpu.11.py @@ -3,8 +3,9 @@ Custom Shader for dotted 3D Line -------------------------------- In this example the arc length (distance to the first point on the line) is calculated in every vertex. -Between the vertex and fragment shader that value is automatically interpolated for all points that will be visible on the screen. -In the fragment shader the `sin` of the arc length is calculated. +Between the vertex and fragment shader that value is automatically interpolated +for all points that will be visible on the screen. +In the fragment shader the ``sin`` of the arc length is calculated. Based on the result a decision is made on whether the fragment should be drawn or not. """ import bpy @@ -47,9 +48,11 @@ for a, b in zip(coords[:-1], coords[1:]): arc_lengths.append(arc_lengths[-1] + (a - b).length) shader = gpu.types.GPUShader(vertex_shader, fragment_shader) -batch = batch_for_shader(shader, 'LINE_STRIP', - {"position" : coords, - "arcLength" : arc_lengths}) +batch = batch_for_shader( + shader, 'LINE_STRIP', + {"position": coords, "arcLength": arc_lengths}, +) + def draw(): shader.bind() @@ -58,4 +61,5 @@ def draw(): shader.uniform_float("u_Scale", 10) batch.draw(shader) -bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
\ No newline at end of file + +bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW') |