def wrap(render):

    global np_coords
    global np_vert_coords
    global grains

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

    if not render.steps%3:
      f = fn.name()
    else:
      f = None

    grains += (-1)**floor(2*random())
    print(grains)
    if grains<0:
      grains = 0

    res = steps(DF)
    render.set_front(FRONT)

    coord_num = DF.np_get_edges_coordinates(np_coords)
    sandstroke(render,np_coords[:coord_num,:],grains,f)

    if not random()<0.1:
      vert_num = DF.np_get_vert_coordinates(np_vert_coords)
      dots(render,np_vert_coords[:vert_num,:],None)

    return res
  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
Exemple #3
0
    def wrap(render):

        global np_coords
        global np_vert_coords
        global grains

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

        if not render.steps % 3:
            f = fn.name()
        else:
            f = None

        grains += (-1)**floor(2 * random())
        print(grains)
        if grains < 0:
            grains = 0

        res = steps(DF)
        render.set_front(FRONT)

        coord_num = DF.np_get_edges_coordinates(np_coords)
        sandstroke(render, np_coords[:coord_num, :], grains, f)

        if not random() < 0.1:
            vert_num = DF.np_get_vert_coordinates(np_vert_coords)
            dots(render, np_vert_coords[:vert_num, :], None)

        return res
  def wrap(steps_itt, render):

    global i
    global np_coords
    global np_vert_coords

    fn = None

    t1 = time()

    steps(DF)

    #coord_num = DF.np_get_edges_coordinates(np_coords)
    ##fn = './res/ani{:04d}.png'.format(i)
    #sandstroke(render,np_coords[:coord_num,:],10,fn)


    #if i%2==0:
      #fn = './res/ani{:04d}.png'.format(i)
    #else:
      #fn=None

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

    #render.set_front([0,0.8,0.8,0.05])
    #coord_num = DF.np_get_edges_coordinates(np_coords)
    #sandstroke(render,np_coords[:coord_num,:],8,None)

    #coord_num = DF.np_get_edges_coordinates(np_coords)
    #show(render,np_coords[:coord_num,:],clear=True)

    if i%10==0:
      coord_num = DF.np_get_edges_coordinates(np_coords)
      sandstroke(render,np_coords[:coord_num,:],8,None)

    t2 = time()
    print_stats(render.steps, t2-t1, DF)

    i += 1

    return True
def main():

    from time import time
    from itertools import count

    from differentialLine import DifferentialLine

    from iutils.render import Render
    from modules.helpers import print_stats

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

    np_coords = zeros(shape=(NMAX, 4), dtype='float')
    np_vert_coords = zeros(shape=(NMAX, 2), dtype='float')

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

    render = Render(SIZE, BACK, FRONT)

    render.ctx.set_source_rgba(*FRONT)
    render.ctx.set_line_width(LINEWIDTH)

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

    # arc

    # angles = sorted(random(INIT_NUM)*pi*1.5)
    # xys = []
    # for a in angles:
    #   x = 0.5 + cos(a)*0.2
    #   y = 0.5 + sin(a)*0.2
    #   xys.append((x,y))

    # DF.init_line_segment(xys, lock_edges=1)

    # vertical line

    # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM)))
    # xx = 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(MID + 0.2*(1-2*random(INIT_NUM)))
    # xx = sorted(MID + 0.2*(1-2*random(INIT_NUM)))
    # xys = []
    # for x, y in zip(xx, yy):
    #     xys.append((x, y))

    # DF.init_line_segment(xys, lock_edges=1)

    for i in count():

        t_start = time()

        DF.optimize_position(STP)
        spawn_curl(DF, NEARL, 0.016)

        if i % 500 == 0:
            fn = './res/chris_bd_{:04d}.png'.format(i)
        else:
            fn = None

        render.set_front(FRONT)
        num = DF.np_get_edges_coordinates(np_coords)
        #sandstroke(render, np_coords[:num, :], 20, fn)

        if random() < 0.05:
            sandstroke(render, np_coords[:num, :], 30, None)

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

        t_stop = time()

        print_stats(i, t_stop - t_start, DF)
def main():

  from time import time
  from itertools import count

  from differentialLine import DifferentialLine

  from render.render import Render
  from modules.helpers import print_stats

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


  np_coords = zeros(shape=(NMAX,4), dtype='float')
  np_vert_coords = zeros(shape=(NMAX,2), dtype='float')


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

  render = Render(SIZE, BACK, FRONT)

  render.ctx.set_source_rgba(*FRONT)
  render.ctx.set_line_width(LINEWIDTH)

  ## arc

  angles = sorted(random(INIT_NUM)*pi*1.5)
  xys = []
  for a in angles:
    x = 0.5 + cos(a)*0.2
    y = 0.5 + sin(a)*0.2
    xys.append((x,y))

  DF.init_line_segment(xys, lock_edges=1)

  ## vertical line

  #yy = sorted(MID + 0.2*(1-2*random(INIT_NUM)))
  #xx = 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(MID + 0.2*(1-2*random(INIT_NUM)))
  # xx = sorted(MID + 0.2*(1-2*random(INIT_NUM)))
  # xys = []
  # for x,y in zip(xx,yy):
    # xys.append((x,y))

  # DF.init_line_segment(xys, lock_edges=1)


  for i in count():

    t_start = time()

    DF.optimize_position(STP)
    spawn_curl(DF,NEARL,0.016)

    if i%100==0:
      fn = './res/sider_arc_ac_{:04d}.png'.format(i)
    else:
      fn = None

    render.set_front(FRONT)
    num = DF.np_get_edges_coordinates(np_coords)
    sandstroke(render,np_coords[:num,:],20,fn)


    if random()<0.05:
      sandstroke(render,np_coords[:num,:],30,None)

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


    t_stop = time()

    print_stats(i,t_stop-t_start,DF)
Exemple #7
0
def main():

    from time import time
    from itertools import count

    from differentialLine import DifferentialLine

    from render.render import Render
    from modules.helpers import print_stats

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

    np_coords = zeros(shape=(NMAX, 4), dtype='float')
    np_vert_coords = zeros(shape=(NMAX, 2), dtype='float')

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

    render = Render(SIZE, BACK, FRONT)

    render.ctx.set_source_rgba(*FRONT)
    render.ctx.set_line_width(LINEWIDTH)

    ## arc

    #angles = sorted(random(INIT_NUM)*pi*1.5)
    #xys = []
    #for a in angles:
    #x = 0.5 + cos(a)*0.2
    #y = 0.5 + sin(a)*0.2
    #xys.append((x,y))

    ## vertical line

    #yy = sorted(MID + 0.2*(1-2*random(INIT_NUM)))
    #xx = 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(MID + 0.2 * (1 - 2 * random(INIT_NUM)))
    xx = sorted(MID + 0.2 * (1 - 2 * random(INIT_NUM)))
    xys = []
    for x, y in zip(xx, yy):
        xys.append((x, y))

    DF.init_line_segment(xys, lock_edges=1)

    for i in count():

        t_start = time()

        DF.optimize_avoid(STP)
        spawn_curl(DF, NEARL)

        if i % 100 == 0:
            fn = './res/line_expand_ab_{:04d}.png'.format(i)
        else:
            fn = None

        render.set_front(FRONT)
        num = DF.np_get_edges_coordinates(np_coords)
        sandstroke(render, np_coords[:num, :], 20, fn)

        if i % 40 == 0:
            render.set_front([0, 0, 0, 0.3])
            num = DF.np_get_edges_coordinates(np_coords)
            sandstroke(render, np_coords[:num, :], 10, fn)

        t_stop = time()

        print_stats(i, t_stop - t_start, DF)