def main():

    import gtk

    from differentialMesh import DifferentialMesh
    from render.render import Animate
    from modules.helpers import darts

    DM = DifferentialMesh(NMAX, 2 * FARL, NEARL, FARL, PROCS)

    DM.new_faces_in_ngon(MID, MID, H, 3, 0)
    DM.set_edge_intensity(1, 1)

    sources = [(x, y)
               for x, y in darts(NUM_SOURCES, MID, MID, 0.40, 3 * NEARL)]
    DM.initialize_sources(sources, NEARL)

    def wrap(render):

        res = steps(DM)
        show(render, DM, sources)

        return res

    render = Animate(SIZE, BACK, FRONT, wrap)
    render.set_line_width(LINEWIDTH)

    gtk.main()
def main():

  import gtk

  from differentialMesh import DifferentialMesh
  from render.render import Animate
  from modules.helpers import darts


  DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS)

  DM.new_faces_in_ngon(MID,MID, H, 3, 0)
  DM.set_edge_intensity(1, 1)

  sources = [(x,y) for x,y in darts(NUM_SOURCES, MID, MID, 0.40, 3*NEARL)]
  DM.initialize_sources(sources, NEARL)

  def wrap(render):

    res = steps(DM)
    show(render, DM, sources)

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)
  render.set_line_width(LINEWIDTH)

  gtk.main()
Пример #3
0
def main():

  from render.render import Animate
  from differentialLine import DifferentialLine
  from modules.helpers import get_exporter

  # from modules.show import show_closed
  # from modules.show import show_detail
  from modules.show import show


  DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS)

  angles = sorted(random(INIT_NUM)*TWOPI)
  DF.init_circle_segment(MID,MID,INIT_RAD, angles)

  from fn import Fn
  fn = Fn(prefix='./res/')

  exporter = get_exporter(
    NMAX,
    {
      'nearl': NEARL,
      'farl': FARL,
      'stp': STP,
      'size': SIZE,
      'procs': PROCS
    }
  )

  def wrap(render):

    global i

    # animation stops when res is False
    res = steps(DF)

    ## if fn is a path each image will be saved to that path

    ## render outline
    num = DF.np_get_edges_coordinates(np_edges)
    if not i % 100:
      show(render,np_edges[:num,:], None, r=1.3*ONE)
      # render.write_to_png(fn.name())
      exporter(
        DF,
        fn.name()+'.2obj'
      )

    ## render solid
    # num = DF.get_sorted_vert_coordinates(np_verts)
    #show_closed(render,np_verts[:num,:],fn)

    i += 1

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)
  render.start()
Пример #4
0
def main():

  from modules.sand import Sand
  from render.render import Animate
  from fn import Fn


  fn = Fn(prefix='./res/', postfix='.png')

  sand = Sand(
      SIZE,
      INUM,
      NOISE_STP,
      fn
      )

  ## radial lines
  # n = 50
  # for i, snum in enumerate(linspace(5,100,n).astype('int')):
  #   a = ones(snum, 'float') * i/n*TWOPI
  #   r = sorted(random(size=(snum, 1))*RAD)
  #   xy = 0.5+column_stack((cos(a), sin(a)))*r
  #   sand.init(xy)

  ## horizontal lines
  # n = 50
  # for i, snum in enumerate(linspace(5,100,n).astype('int')):
  #   x = linspace(EDGE, 1.0-EDGE, snum)
  #   y = ones(snum)*(EDGE + (i/(n-1.0))*2*RAD)
  #   xy = column_stack((x,y))
  #   sand.init(xy)

  ## messy spheres
  # n = 50
  # for i, snum in enumerate(linspace(5,100,n).astype('int')):
  #   a = sorted(random(snum)*TWOPI)
  #   r = ones((snum, 1))*(EDGE + (i/(n-1.0))*(RAD-EDGE))
  #   xy = 0.5+column_stack((cos(a), sin(a)))*r
  #   sand.init(xy)

  ## tidy spheres
  n = 50
  for i, snum in enumerate(linspace(20,80,n).astype('int')):
    a = linspace(0,TWOPI, snum)
    r = ones((snum, 1))*(EDGE + (i/(n-1.0))*(RAD-EDGE))
    xy = 0.5+column_stack((cos(a), sin(a)))*r
    sand.init(xy)

  render = Animate(SIZE, BACK, FRONT, sand.wrap)
  render.set_line_width(sand.one)
  render.transparent_pix()
  render.set_front(FRONT)

  render.start()
Пример #5
0
def main():

  import gtk

  from differentialMesh import DifferentialMesh
  from render.render import Animate

  DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS)

  DM.new_faces_in_ngon(MID,MID, H, 6, 0.0)

  def wrap(render):

    res = steps(DM)
    show(render, DM)

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)
  render.set_line_width(LINEWIDTH)

  gtk.main()
def main():

    import gtk

    from differentialMesh import DifferentialMesh
    from render.render import Animate

    DM = DifferentialMesh(NMAX, 2 * FARL, NEARL, FARL, PROCS)

    DM.new_faces_in_ngon(MID, MID, H, 6, 0.0)

    def wrap(render):

        res = steps(DM)
        show(render, DM)

        return res

    render = Animate(SIZE, BACK, FRONT, wrap)
    render.set_line_width(LINEWIDTH)

    gtk.main()
Пример #7
0
def main():

    import gtk

    from render.render import Animate
    from differentialLine import DifferentialLine

    from modules.show import show_closed
    from modules.show import show_detail
    from modules.show import show

    DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS)

    angles = sorted(random(INIT_NUM) * TWOPI)
    DF.init_circle_segment(MID, MID, INIT_RAD, angles)

    def wrap(render):

        global i

        # animation stops when res is False
        res = steps(DF)

        ## if fn is a path each image will be saved to that path
        fn = None

        ## render outline
        num = DF.np_get_edges_coordinates(np_edges)
        show(render, np_edges[:num, :], fn, r=1.3 * ONE)

        ## render solid
        # num = DF.get_sorted_vert_coordinates(np_verts)
        #show_closed(render,np_verts[:num,:],fn)

        i += 1

        return res

    render = Animate(SIZE, BACK, FRONT, wrap)

    gtk.main()
Пример #8
0
def main():

  from render.render import Animate
  from numpy.random import random
  from numpy import array
  from modules.wind import Wind

  W = Wind(
    NMAX,
    SIZE,
    STP,
    ANGLE_STP,
    ANGLE_LOCAL_STP
  )

  W.rnd_seed(INIT_NUM)
  # W.seed(array([[0.5,0.5]]))

  def wrap(render):

    if W.i % 5:
      show(render,W)
      # render.write_to_png('{:04d}.png'.format(W.i))

    res = W.step()

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)

  def __write_and_exit(*args):
    gtk.main_quit(*args)
    show(render,W)
    render.write_to_png('./res/exit.png')

  render.window.connect("destroy", __write_and_exit)

  gtk.main()
Пример #9
0
def main():

    import gtk
    from render.render import Animate
    from numpy.random import random
    from numpy import zeros
    from dddUtils.pointCloud import point_cloud

    from modules.utils import get_dens_example
    from modules.utils import get_dens_from_img
    from modules.utils import sample_from_dens

    from ccvt import Ccvt as ccvt

    fn = './data/kelp.png'
    n = 100
    m = 1000

    print('get density')
    dens = get_dens_from_img(fn)
    # dens = get_dens_example(100)

    print('sample domain')
    domain = sample_from_dens(dens, m)
    print('sample dens')
    org_sites = sample_from_dens(dens, n)

    sites, inv_tesselation = ccvt(domain, org_sites, maxitt=5)

    def show(render):
        render.clear_canvas()

        render.set_front(LIGHT)
        for i, s in enumerate(domain):
            render.circle(*s, r=ONE, fill=True)

        render.set_front(BLACK)
        for s, sxy in enumerate(sites):
            render.circle(*sxy, r=3 * ONE, fill=True)

        for s, xx in inv_tesselation.iteritems():

            sx, sy = sites[s]

            render.set_front(FRONT)
            for x in xx:
                render.line(sx, sy, domain[x, 0], domain[x, 1])

            render.set_front(BLACK)
            render.line(sx, sy, *org_sites[s, :])

        # render.set_front(BLACK)
        # for i, s in enumerate(org_sites):
        # render.circle(*s, r=3*ONE, fill=False)

    def wrap(render):
        show(render)
        return False

    render = Animate(SIZE, BACK, FRONT, wrap)
    render.set_line_width(ONE)

    gtk.main()
Пример #10
0
def main():

  import gtk

  from render.render import Animate
  from differentialLine import DifferentialLine

  from modules.show import sandstroke
  from modules.show import dots
  from modules.show import show

  DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS)

  ## arc
  #angles = sorted(random(INIT_NUM)*pi*1.5)
  #xys = []
  #for a in angles:
    #x = 0.5 + cos(a)*0.06
    #y = 0.5 + sin(a)*0.06
    #xys.append((x,y))
  #DF.init_line_segment(xys, lock_edges=1)

  ## vertical line
  #xx = sorted(0.45+0.1*random(INIT_NUM))
  #yy = MID+0.005*(0.5-random(INIT_NUM))
  #xys = []
  #for x,y in zip(xx,yy):
    #xys.append((x,y))
  #DF.init_line_segment(xys, lock_edges=1)

  # diagonal line
  yy = sorted(0.3+0.4*random(INIT_NUM))
  xx = 0.3+linspace(0,0.4,num=INIT_NUM)
  xys = []
  for x,y in zip(xx,yy):
    xys.append((x,y))
  DF.init_line_segment(xys, lock_edges=1)


  #angles = sorted(random(INIT_NUM)*TWOPI)
  #DF.init_circle_segment(MID,MID,FARL*0.2, angles)


  def wrap(render):

    global i
    global np_coords
    global np_vert_coords

    ## if fn is a path each image will be saved to that path
    #fn = './res/ani{:04d}.png'.format(i)
    fn = None


    res = steps(DF)

    render.set_front(FRONT)

    coord_num = DF.np_get_edges_coordinates(np_coords)
    sandstroke(render,np_coords[:coord_num,:],10,fn)

    #vert_num = DF.np_get_vert_coordinates(np_vert_coords)
    #dots(render,np_vert_coords[:vert_num,:],fn)


    i += 1

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)

  gtk.main()
Пример #11
0
def main():

  from modules.leaf import LeafClosed as Leaf
  from render.render import Animate
  from numpy.random import random
  from numpy import array

  colors = {
    'back': [1,1,1,1],
    'front': [0,0,0,0.3],
    'vein': [0,0,0,0.9],
    'edge': [0,0,0,0.6],
    'cyan': [0,0.6,0.6,0.3],
    'red': [0.7,0.0,0.0,0.8],
    'blue': [0.0,0.0,0.7,0.8],
    'light': [0,0,0,0.2],
  }

  threads = 256

  render_steps = 10
  export_steps = 10

  size = 512*2
  one = 1.0/size

  node_rad = 1*one

  area_rad = 15*node_rad
  stp = node_rad*2
  kill_rad = 2*stp
  sources_dst = 2*kill_rad

  init_num_sources = 3

  # init_num_sources = 4
  # init_veins = 0.2+0.6*random((init_num_sources,2))
  init_veins = array([[0.5, 0.5]])

  init_num_sources = 100000

  # from dddUtils.random import darts
  # init_sources = darts(init_num_sources, 0.5, 0.5, 0.45, sources_rad)
  from dddUtils.random import darts_rect
  init_sources = darts_rect(init_num_sources, 0.5, 0.5, 0.95, 0.95, sources_dst)

  L = Leaf(
    size,
    stp,
    init_sources,
    init_veins,
    area_rad,
    kill_rad,
    threads = threads
  )
  print('nz', L.nz)
  print('dens', L.sv_leap)

  wrap = get_wrap(
    L,
    colors,
    node_rad=node_rad,
    export_steps=export_steps,
    render_steps=render_steps
  )

  render = Animate(size, colors['back'], colors['front'], wrap)
  render.set_line_width(L.one*2)
  render.start()
Пример #12
0
def main():

  import gtk
  from render.render import Animate
  from numpy.random import random
  from numpy import zeros
  from dddUtils.pointCloud import point_cloud

  from modules.utils import get_dens_example
  from modules.utils import get_dens_from_img
  from modules.utils import sample_from_dens

  from ccvt import Ccvt as ccvt

  fn = './data/kelp.png'
  n = 100
  m = 1000

  print('get density')
  dens = get_dens_from_img(fn)
  # dens = get_dens_example(100)

  print('sample domain')
  domain = sample_from_dens(dens, m)
  print('sample dens')
  org_sites = sample_from_dens(dens, n)

  sites, inv_tesselation = ccvt(domain, org_sites, maxitt=5)

  def show(render):
    render.clear_canvas()

    render.set_front(LIGHT)
    for i, s in enumerate(domain):
      render.circle(*s, r=ONE, fill=True)

    render.set_front(BLACK)
    for s, sxy in enumerate(sites):
      render.circle(*sxy, r=3*ONE, fill=True)

    for s,xx in inv_tesselation.iteritems():

      sx, sy = sites[s]

      render.set_front(FRONT)
      for x in xx:
        render.line(sx, sy, domain[x,0], domain[x,1])

      render.set_front(BLACK)
      render.line(sx, sy, *org_sites[s,:])

    # render.set_front(BLACK)
    # for i, s in enumerate(org_sites):
      # render.circle(*s, r=3*ONE, fill=False)

  def wrap(render):
    show(render)
    return False

  render = Animate(SIZE, BACK, FRONT, wrap)
  render.set_line_width(ONE)

  gtk.main()