Skip to main content
`Ctrl`+`K`

# vispy.visuals.glsl.antialiasing module

Antialiasing GLSL functions.

vispy.visuals.glsl.antialiasing.ANTIALIAS_OUTLINE = '\nvec4 outline(float distance)\n{\n vec4 frag_color;\n float t = $linewidth/2.0 - $antialias;\n float signed_distance = distance;\n float border_distance = abs(signed_distance) - t;\n float alpha = border_distance/$antialias;\n alpha = exp(-alpha*alpha);\n\n if( border_distance < 0.0 )\n frag_color = $stroke;\n else if( signed_distance < 0.0 )\n frag_color = mix($fill, $stroke, sqrt(alpha));\n else\n frag_color = vec4($stroke.rgb, $stroke.a * alpha);\n return frag_color;\n}\n'

  Compute antialiased fragment color for a filled shape.

  Inputs:

  - distance (float): Signed distance to border (in pixels).

  Template variables:

  - linewidth (float): Stroke line width (in pixels).

  - antialias (float): Stroke antialiased area (in pixels).

  - fill (vec4): Fill color.

  Outputs:

  - color (vec4): The final color.

vispy.visuals.glsl.antialiasing.ANTIALIAS_STROKE = '\nvec4 stroke(float distance)\n{\n vec4 frag_color;\n float t = $linewidth/2.0 - $antialias;\n float signed_distance = distance;\n float border_distance = abs(signed_distance) - t;\n float alpha = border_distance/$antialias;\n alpha = exp(-alpha*alpha);\n\n if( border_distance < 0.0 )\n frag_color = $stroke;\n else\n frag_color = vec4($stroke.rgb, $stroke.a * alpha);\n\n return frag_color;\n}\n'

  Compute antialiased fragment color for an outlined shape.

  Inputs:

  - distance (float): Signed distance to border (in pixels).

  Template variables:

  - linewidth (float): Stroke line width (in pixels).

  - antialias (float): Stroke antialiased area (in pixels).

  - stroke (vec4): Stroke color.

  - fill (vec4): Fill color.

  Outputs:

  - color (vec4): The final color.