File: marker.frag

package info (click to toggle)
python-vispy 0.15.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,868 kB
  • sloc: python: 59,799; javascript: 6,800; makefile: 69; sh: 6
file content (36 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ----------------------------------------------------------------------------
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved.
// Distributed under the (new) BSD License.
// ----------------------------------------------------------------------------
// Hooks:
//  <paint>  : "stroke", "filled" or "outline"
//  <marker> : "arrow", "asterisk", "chevron", "clover", "club",
//             "cross", "diamond", "disc", "ellipse", "hbar",
//             "heart", "infinity", "pin", "ring", "spade",
//             "square", "tag", "triangle", "vbar"
// ----------------------------------------------------------------------------
#include "math/constants.glsl"
#include "markers/markers.glsl"
#include "antialias/antialias.glsl"

// Varyings
// ------------------------------------
varying float v_antialias;
varying float v_linewidth;
varying float v_size;
varying float v_texcoord;
varying vec4  v_fg_color;
varying vec4  v_bg_color;
varying vec2  v_orientation;

// Main (hooked)
// ------------------------------------
void main()
{
    vec2 P = gl_PointCoord.xy - vec2(0.5,0.5);
    P = vec2(v_orientation.x*P.x - v_orientation.y*P.y,
             v_orientation.y*P.x + v_orientation.x*P.y);
    float point_size = M_SQRT2*v_size  + 2 * (v_linewidth + 1.5*v_antialias);
    float distance = marker_<marker>(P*point_size, v_size);
    gl_FragColor = <paint>(distance, v_linewidth, v_antialias, v_fg_color, v_bg_color);
}