Example #1
0
def disp_circuit(by_id, *map_to_col_list):
  canvas = vapp.Canvas(size=(800, 800), keys='interactive', title='Floating Pwn2Win Mask')
  gloo.set_viewport(0, 0, 800, 800)
  gloo.set_viewport(0, 0, canvas.size[0], canvas.size[1])
  gloo.set_state("translucent", depth_test=False)

  panzoom = PanZoomTransform(canvas, aspect=1)
  polys = PolygonCollection("agg", color="local", transform=panzoom)
  shift = np.zeros((1, 2))

  for colmap in map_to_col_list:
    nshift = np.zeros((1, 2))
    minp = np.zeros((1, 2))
    for entry in by_id.values():
      if entry.box.empty(): continue
      if entry.nodisplay: continue
      key = entry.idx
      if not key in colmap: continue

      points = np.concatenate((entry.box.poly() / 1e5 + shift, np.zeros((4, 1))), axis=1)
      nshift = np.maximum(nshift, np.amax(points, axis=0)[:2])
      minp = np.minimum(minp, np.amin(points, axis=0)[:2])
      polys.append(points, color=colmap[key].rgba)
    shift = (nshift - minp) * 1.1
    shift[0, 1] = 0
  polys.update.connect(canvas.update)

  @canvas.connect
  def on_draw(e):
    gloo.clear('white')
    polys.draw()

  @canvas.connect
  def on_resize(event):
    width, height = event.size
    gloo.set_viewport(0, 0, width, height)

  canvas.show()
  vapp.run()
Example #2
0
                stroke_width = path.style.stroke_width.value
            else:
                stroke_width = 2.0
            paths.append(vertices,
                         closed=closed,
                         color=path.style.stroke.rgba,
                         linewidth=stroke_width)
        if path.style.fill is not None:
            if path.style.stroke is None:
                vertices[:, 2] = z - 0.25 / 1000.
                paths.append(vertices,
                             closed=closed,
                             color=path.style.fill.rgba,
                             linewidth=1)
            vertices[:, 2] = z
            polys.append(vertices, color=path.style.fill.rgba)
    z -= 1 / 1000.

paths["linewidth"] = 1.0
paths['viewport'] = 0, 0, 800, 800


@canvas.connect
def on_draw(e):
    gloo.clear('white')
    polys.draw()
    paths.draw()


@canvas.connect
def on_resize(e):
Example #3
0
    P = np.zeros((2 * n, 3))
    P[:, 0] = R * np.cos(T)
    P[:, 1] = R * np.sin(T)
    return P

paths = PathCollection("agg", color='shared')
polys = PolygonCollection("raw", color='shared')

P = star()

n = 100
for i in range(n):
    c = i / float(n)
    x, y = np.random.uniform(-1, +1, 2)
    s = 100 / 800.0
    polys.append(P * s + (x, y, i / 1000.), color=(1, 0, 0, .5))
    paths.append(
        P * s + (x, y, (i - 1) / 1000.), closed=True, color=(0, 0, 0, .5))

paths["linewidth"] = 1.0
paths['viewport'] = 0, 0, 800, 800


@canvas.connect
def on_draw(e):
    gloo.clear('white')
    polys.draw()
    paths.draw()


@canvas.connect
Example #4
0
        if path.style.stroke is not None:
            vertices[:, 2] = z - 0.5 / 1000.
            if path.style.stroke_width:
                stroke_width = path.style.stroke_width.value
            else:
                stroke_width = 2.0
            paths.append(vertices, closed=closed, color=path.style.stroke.rgba,
                         linewidth=stroke_width)
        if path.style.fill is not None:
            if path.style.stroke is None:
                vertices[:, 2] = z - 0.25 / 1000.
                paths.append(vertices, closed=closed,
                             color=path.style.fill.rgba,
                             linewidth=1)
            vertices[:, 2] = z
            polys.append(vertices, color=path.style.fill.rgba)
    z -= 1 / 1000.


paths["linewidth"] = 1.0
paths['viewport'] = 0, 0, 800, 800


@canvas.connect
def on_draw(e):
    gloo.clear('white')
    polys.draw()
    paths.draw()


@canvas.connect