Module Expr Str Import alias identifier ImportFrom alias identifier ImportFrom alias alias alias alias alias alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str ClassDef bases NameLoad body FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr Call NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr ListLoad Call NameLoad Call NameLoad Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad TupleLoad Str AttributeLoad NameLoad attr Num TupleLoad Str AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr Num keyword NameLoad Assign SubscriptStore NameLoad Index Str ListLoad ListLoad Num Num ListLoad Num Num ListLoad Num Num ListLoad Num Num Assign SubscriptStore NameLoad Index Str ListLoad ListLoad Num Num ListLoad Num Num ListLoad Num Num ListLoad Num Num Assign NameStore Call NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str Num For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assert Call NameLoad NameLoad NameLoad Expr Call NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call NameLoad BinOpSub Num NameLoad keyword Str keyword Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad ExtSlice Slice Slice Index Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad Assign AttributeStore SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad With SubscriptLoad AttributeLoad NameLoad attr Index Num body Expr Call NameLoad BinOpAdd Call NameLoad NameLoad Call NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num Assign NameStore ListLoad For NameStore Call NameLoad Num body Assign NameStore Call NameLoad BinOpAdd NameLoad TupleLoad Num keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore SubscriptLoad AttributeLoad NameLoad attr Index Num attr SubscriptLoad NameLoad Index Num Assign AttributeStore SubscriptLoad AttributeLoad NameLoad attr Index Num attr SubscriptLoad NameLoad Index Num For NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num body Assign TupleStore SubscriptStore NameLoad Index Str SubscriptStore NameLoad Index Str NameLoad Assign NameStore Num With SubscriptLoad AttributeLoad NameLoad attr Index NameLoad body Expr Call NameLoad Num Num SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str Assign NameStore Call AttributeLoad BinOpFloorDiv Call AttributeLoad NameLoad attr NameLoad Num attr While CompareGt NameLoad Num body Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str SubscriptLoad NameLoad Index NameLoad Assign NameStore IfExp CompareEq NameLoad Num Num Num With SubscriptLoad AttributeLoad NameLoad attr Index NameLoad body Expr Call NameLoad Num Num SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str AugAssignFloorDiv NameStore Num Return SubscriptLoad NameLoad Index NameLoad decorator_list decorator_list
N/A N/A 
Jump flooding algoritm for EDT using GLSL code:
Author: Stefan Gustavson (stefan.gustavson@gmail.com)
2010-08-24. This code is in the public domain.

Adapted to `vispy` by Eric Larson <larson.eric.d@gmail.com>.
 N/A numpy np os path op gloo Program FrameBuffer VertexBuffer Texture2D set_viewport set_state N/A this_dir N/A N/A op dirname __file__ N/A vert_seed 
attribute vec2 a_position;
attribute vec2 a_texcoord;
varying vec2 v_uv;

void main( void )
{
  v_uv = a_texcoord.xy;
  gl_Position = vec4(a_position.xy, 0., 1.);
}
 N/A vert 
uniform float u_texw;
uniform float u_texh;
uniform float u_step;
attribute vec2 a_position;
attribute vec2 a_texcoord;
varying float v_stepu;
varying float v_stepv;
varying vec2 v_uv;

void main( void )
{
  v_uv = a_texcoord.xy;
  v_stepu = u_step / u_texw; // Saves a division in the fragment shader
  v_stepv = u_step / u_texh;
  gl_Position = vec4(a_position.xy, 0., 1.);
}
 N/A frag_seed 
uniform sampler2D u_texture;
varying vec2 v_uv;

void main( void )
{
  float pixel = texture2D(u_texture, v_uv).r;
  vec4 myzero = vec4(128. / 255., 128. / 255., 0., 0.);  // Zero
  vec4 myinfinity = vec4(0., 0., 0., 0.);                // Infinity
  // Pixels >= 0.5 are objects, others are background
  gl_FragColor = pixel >= 0.5 ? myzero : myinfinity;
}
 N/A frag_flood 
uniform sampler2D u_texture;
varying float v_stepu;
varying float v_stepv;
varying vec2 v_uv;

vec2 remap(vec4 floatdata) {
    vec2 scaleddata = vec2(floatdata.x * 65280. + floatdata.z * 255.,
                           floatdata.y * 65280. + floatdata.w * 255.);
    return scaleddata / 32768. - 1.0;
}

vec4 remap_inv(vec2 floatvec) {
    vec2 data = (floatvec + 1.0) * 32768.;
    float x = floor(data.x / 256.);
    float y = floor(data.y / 256.);
    return vec4(x, y, data.x - x * 256., data.y - y * 256.) / 255.;
}

void main( void )
{
  // Search for better distance vectors among 8 candidates
  vec2 stepvec; // Relative offset to candidate being tested
  vec2 newvec;  // Absolute position of that candidate
  vec3 newseed; // Closest point from that candidate (.xy) and its dist (.z)
  vec3 bestseed; // Closest seed so far
  bestseed.xy = remap(texture2D(u_texture, v_uv).rgba);
  bestseed.z = length(bestseed.xy);

  stepvec = vec2(-v_stepu, -v_stepv);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(-v_stepu, 0.0);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(-v_stepu, v_stepv);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(0.0, -v_stepv);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(0.0, v_stepv);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(v_stepu, -v_stepv);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(v_stepu, 0.0);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  stepvec = vec2(v_stepu, v_stepv);
  newvec = v_uv + stepvec;
  if (all(bvec4(lessThan(newvec, vec2(1.0)), greaterThan(newvec, vec2(0.0))))){
    newseed.xy = remap(texture2D(u_texture, newvec).rgba);
    if(newseed.x > -0.99999) { // if the new seed is not "indeterminate dist"
      newseed.xy = newseed.xy + stepvec;
      newseed.z = length(newseed.xy);
      if(newseed.z < bestseed.z) {
        bestseed = newseed;
      }
    }
  }

  gl_FragColor = remap_inv(bestseed.xy);
}
 N/A frag_insert 

uniform sampler2D u_texture;
uniform sampler2D u_pos_texture;
uniform sampler2D u_neg_texture;
varying float v_stepu;
varying float v_stepv;
varying vec2 v_uv;

vec2 remap(vec4 floatdata) {
    vec2 scaled_data = vec2(floatdata.x * 65280. + floatdata.z * 255.,
                            floatdata.y * 65280. + floatdata.w * 255.);
    return scaled_data / 32768. - 1.0;
}

void main( void )
{
    float pixel = texture2D(u_texture, v_uv).r;
    // convert distance from normalized units -> pixels
    vec2 rescale = vec2(v_stepu, v_stepv);
    float shrink = 8.;
    rescale = rescale * 256. / shrink;
    // Without the division, 1 RGB increment = 1 px distance
    vec2 pos_distvec = remap(texture2D(u_pos_texture, v_uv).rgba) / rescale;
    vec2 neg_distvec = remap(texture2D(u_neg_texture, v_uv).rgba) / rescale;
    if (pixel <= 0.5)
        gl_FragColor = vec4(0.5 - length(pos_distvec));
    else
        gl_FragColor = vec4(0.5 - (shrink - 1.) / 256. + length(neg_distvec));
}
 SDFRenderer N/A object N/A __init__ N/A N/A self N/A N/A N/A N/A self program_seed N/A Program vert_seed frag_seed N/A N/A self program_flood N/A Program vert frag_flood N/A N/A self program_insert N/A Program vert frag_insert N/A N/A self programs N/A N/A self program_seed N/A self program_flood N/A self program_insert N/A N/A self fbo_to N/A N/A FrameBuffer N/A FrameBuffer N/A FrameBuffer N/A vtype N/A N/A np dtype N/A N/A a_position N/A np float32 2 N/A a_texcoord N/A np float32 2 N/A vertices N/A N/A np zeros 4 dtype vtype N/A N/A vertices N/A a_position N/A N/A -1.0 -1.0 N/A -1.0 1.0 N/A 1.0 -1.0 N/A 1.0 1.0 N/A N/A vertices N/A a_texcoord N/A N/A 0.0 0.0 N/A 0.0 1.0 N/A 1.0 0.0 N/A 1.0 1.0 N/A vertices N/A VertexBuffer vertices N/A N/A N/A self program_insert N/A u_step 1.0 N/A program N/A self programs N/A N/A N/A N/A program bind vertices N/A render_to_texture N/A N/A self data texture offset size N/A N/A N/A Render a SDF to a texture at a given offset and size

        Parameters
        ----------
        data : array
            Must be 2D with type np.ubyte.
        texture : instance of Texture2D
            The texture to render to.
        offset : tuple of int
            Offset (x, y) to render to inside the texture.
        size : tuple of int
            Size (w, h) to render inside the texture.
         N/A N/A isinstance texture Texture2D N/A N/A set_state blend False depth_test False N/A orig_tex N/A Texture2D N/A 255 data format luminance wrapping clamp_to_edge interpolation nearest N/A edf_neg_tex N/A N/A self _render_edf orig_tex N/A N/A orig_tex N/A N/A N/A N/A 0 data N/A edf_pos_tex N/A N/A self _render_edf orig_tex N/A N/A N/A self program_insert N/A u_texture orig_tex N/A N/A N/A self program_insert N/A u_pos_texture edf_pos_tex N/A N/A N/A self program_insert N/A u_neg_texture edf_neg_tex N/A N/A N/A N/A self fbo_to N/A -1 color_buffer texture N/A N/A N/A self fbo_to N/A -1 N/A N/A N/A set_viewport N/A N/A tuple offset N/A tuple size N/A N/A N/A N/A self program_insert draw triangle_strip N/A _render_edf N/A N/A self orig_tex N/A N/A N/A Render an EDF to a texture N/A sdf_size N/A N/A orig_tex shape N/A 2 N/A comp_texs N/A N/A _ N/A range 2 N/A N/A tex N/A Texture2D N/A sdf_size N/A 4 format rgba interpolation nearest wrapping clamp_to_edge N/A N/A N/A comp_texs append tex N/A N/A N/A N/A self fbo_to N/A 0 color_buffer N/A comp_texs N/A 0 N/A N/A N/A N/A self fbo_to N/A 1 color_buffer N/A comp_texs N/A 1 N/A program N/A N/A self programs N/A 1 N/A N/A N/A N/A program N/A u_texh N/A program N/A u_texw sdf_size N/A last_rend 0 N/A N/A N/A self fbo_to N/A last_rend N/A N/A N/A set_viewport 0 0 N/A sdf_size N/A 1 N/A sdf_size N/A 0 N/A N/A N/A self program_seed N/A u_texture orig_tex N/A N/A N/A N/A self program_seed draw triangle_strip N/A stepsize N/A N/A N/A N/A N/A np array sdf_size 2 max N/A N/A stepsize 0 N/A N/A N/A N/A self program_flood N/A u_step stepsize N/A N/A N/A self program_flood N/A u_texture N/A comp_texs N/A last_rend N/A last_rend N/A N/A last_rend 0 1 0 N/A N/A N/A self fbo_to N/A last_rend N/A N/A N/A set_viewport 0 0 N/A sdf_size N/A 1 N/A sdf_size N/A 0 N/A N/A N/A N/A self program_flood draw triangle_strip N/A stepsize 2 N/A N/A comp_texs N/A last_rend N/A N/A