コード例 #1
0
def tree(count,t,sf):
    if sf<0.1:
        leaves.append(Point(0,0))
        return
    line((0,0),(0,1))
    stroke(1,HSVA(0,0,0), cap=LineCap.ROUND)
    wind=t/sf/10
    if count%5!=3:
        with Move(0,1), Rotate(uniform(-20,20)+wind),Scale((0.93,0.93)):
            tree(count-1,t,sf*0.93)
        if random()<0.1:
            with Move(0,1), Rotate(uniform(-20,20)+wind),Scale((0.5,0.5)):
                tree(count//4,t,sf*0.5)
        return
    br=[]
    for i in range(choice([2,3,3,3,4])):
        d,s=cilrand(40)
        br.append((d,s))
    for d,s in br:
        d+=wind

        val=[0.6,0.5]
        shuffle(val)
        with Move(0,1), Rotate(d),Scale((0.9*s,0.95)):
            tree(count-1,t,sf*0.9)
コード例 #2
0
ファイル: example4.py プロジェクト: rt-tondilt/wisualia
def loop(t):
    t = t + 0.1
    with Rotate(0 * 90):
        stops = [(0, RGBA(1, 0, 0, 0.3)), (1, RGBA(0, 0, 0.5, 0.3))]
        f = LinearGradient((0, 0), (5, 5), stops)
        f2 = RadialGradient((0, 0), 1, (5, 5), 10, stops)
    paint(f2, alpha=0.2)
    with Scale((1.5, 1)):
        circle((0, 0), 1)
        stroke(width=0.5)
        paint(ImagePattern(im, pixels_per_unit=40), alpha=0.7)

        p = Pencil()
        p.move(0, 3)
        p.line(0, 6)
        p.line(3, 6)
        p.line(3, 3)
        with Scale((1, 1)):
            p.arc((-1, -1), t * 30)

        p.draw()
        (a, b), (c, d) = fill_extents()

        for x in range(int(a), int(c)):
            for y in range(int(b), int(d)):
                if in_fill(x, y):
                    circle((x, y), 0.5)
                    print(x, y)
        rect((a, b), (c, d))
        fill(RGBA(0.2, 0, 0, 0.3))

        text((0, 0), 'Hell World.', 2)
        (a, b), (c, d) = fill_extents()
        rect((a, b), (c, d))
        fill(RGBA(0.2, 0, 0, 0.3))
コード例 #3
0
def time(fn):
    cr=wisualia.core.context
    cr.save()
    cr.identity_matrix()
    with Scale((100,100)),Move(0.5,0.5):
        t=timeit(fn, number=10, globals=globals())
    cr.restore()
    print('{:<12} {}'.format(fn.__name__,t))
コード例 #4
0
def loop(t):
    global leaves
    leaves=[]
    seed(t)
    with Move(0,-5),Scale((0.7,0.7)):
        tree(40,3*sin(2*t*pi),1)
        for l in leaves:
            circle(tuple(l),0.5)
        fill(HSVA(0,0,0))
コード例 #5
0
ファイル: tree.py プロジェクト: rt-tondilt/wisualia
def loop(t):
    with Move(0, -5.5), Scale((2, 2)):
        global k, r, leaves
        leaves = []

        seed(6736)
        tree(7, 5 * sin(t * 5))
        for l in leaves:
            circle(tuple(l), 0.1 * t / 6)
        fill(HSVA(0, 0, 0))
コード例 #6
0
ファイル: tree.py プロジェクト: rt-tondilt/wisualia
def tree(count, t):
    if count == 0:
        leaves.append(Point(0, 0))
        return
    line((0, 0), (0, 1))
    stroke(0.2, HSVA(0, 0, 0))
    for d, w, n in [(-35, 0.4, 1), (0, 0.7, 1), (20, 0.5, 1)]:
        if True:
            d += t * 10 / count**2
        with Move(0, n), Rotate(d), Scale((w, 1.3 * w)):
            tree(count - 1, t)
コード例 #7
0
def loop(t):
    with  Scale((2.5,2.5)),Move(-4,-3):
        colors=[HSVA(0,0.4,0.7),HSVA(0.17,0.5,0.9),HSVA(0.17,0.5,0.56),HSVA(0.1,0.5)]
        if int(t)%2==0:
            colors=[HSVA(0,1,0.9),HSVA(0.17,1,0.9),HSVA(0.7,1,0.8),HSVA(0.1,1)]
        
        for d,c in zip(range(4),colors):
            ruudu(t,seitse,d)
            fill(c)

        ruudu(t,kaheksa)
        fill(HSVA(0,0.9,0.3))

        im=ImagePattern(image,300)
        paint(im,0.2)
        
        for d,c in zip(range(4),colors):
            ruudu(t,seitse,d)
        ruudu(t,kaheksa)
        
        n=0.56
        stroke(0.02,RGBA(n,n,n))
        paint(im,0.3)
コード例 #8
0
def ruudu(t,sisu,*args):
    for x in range(9):
        for y in range(6):
            with Move(x,y),Scale((1/12,1/12)):
                sisu(x,y,t,*args)