Exemplo n.º 1
0
def draw(canvas):
    background(Red)
    xc=canvas.width/2
    yc=canvas.height/2
    stroke(0.0, 0.25) # 75% transparent black.
    strokewidth(1)
    triangle(xc, yc, xc+50, yc+100, xc+100, yc)

    for path in paths:
        prev = None
        for point in path:
            pt=point
            nofill()
            stroke(1)
            strokewidth(0.75)

            if not prev:
                beginpath(pt.x, pt.y)
            elif pt.cmd == MOVETO:
                moveto(pt.x, pt.y)
            else:
                perpendicular_curve(prev, pt, c)

            prev = pt
        endpath()
        drawpath(path)
Exemplo n.º 2
0
Arquivo: bww.py Projeto: msarch/py
def draw(canvas):
    """ {{{ 
    - dessine en boucle 
    - Args : canvas (string)
    - Returns : none
    """ 

    stroke(White) # 75% transparent black.
    strokewidth(1)

    # random position, rect rotation, color and tranparency
    x1 = random()*canvas.width
    y1 = random()*canvas.height
        #
        #  | Y
        #  | 
        #  |
        #  |            X
        #  0 ------------
        #

    rot = int(random()*4)*90
    rndColor = color(random(),random(),random(),random())
        # You pass Color objects to fill() and stroke().
        # A Color object can be created with the color command.
        # It has clr.r, clr.g, clr.b, clr.a properties :
        #   clr = color(0.25, 0.15, 0.75, 0.5) # 50% transparent purple/blue.
        #   fill(clr)
        
    translate(x1,y1)
    rotate(rot)
    fill(rndColor)
    rect(0,0,rectWidth,rectHeight)
Exemplo n.º 3
0
def render(args):
    from nodebox.graphics import BezierPath, strokewidth, fill, directed, push, translate, rotate, pop, drawpath
    geom2d = getPropValue(args, 'inputs', 'geometry')

    # Do the drawing here!!
    path = BezierPath()
    strokewidth(width=1)
    fill(0)

    ps = geom2d.points
    for b_path in geom2d.bezier_paths:
        if len(b_path) > 4:
            path.moveto(*geom2d.points[b_path[0]])
            for p_num in xrange((len(b_path) - 1) // 3):
                # debugPrint b_path,p_num
                path.curveto(ps[b_path[p_num * 3 + 1]][0], ps[b_path[p_num * 3 + 1]][1], ps[b_path[p_num * 3 + 2]][0], ps[b_path[p_num * 3 + 2]][1]                             , ps[b_path[p_num * 3 + 3]][0], ps[b_path[p_num * 3 + 3]][1]
                             )

            #    points = path.points(amount=len(glyphs), start=0.05, end=0.95)
            points = path.points(amount=0, start=0.05, end=0.95)
            for angle, pt in directed(points):
                push()
                translate(pt.x, pt.y)
                rotate(angle)
                pop()
            drawpath(path, fill=None, stroke=(0, 0, 0, 1))
Exemplo n.º 4
0
Arquivo: bww.py Projeto: msarch/py
def draw(canvas):
    """ {{{ 
    - dessine en boucle 
    - Args : canvas (string)
    - Returns : none
    """

    stroke(White)  # 75% transparent black.
    strokewidth(1)

    # random position, rect rotation, color and tranparency
    x1 = random() * canvas.width
    y1 = random() * canvas.height
    #
    #  | Y
    #  |
    #  |
    #  |            X
    #  0 ------------
    #

    rot = int(random() * 4) * 90
    rndColor = color(random(), random(), random(), random())
    # You pass Color objects to fill() and stroke().
    # A Color object can be created with the color command.
    # It has clr.r, clr.g, clr.b, clr.a properties :
    #   clr = color(0.25, 0.15, 0.75, 0.5) # 50% transparent purple/blue.
    #   fill(clr)

    translate(x1, y1)
    rotate(rot)
    fill(rndColor)
    rect(0, 0, rectWidth, rectHeight)
Exemplo n.º 5
0
def draw(canvas):
   
    xc=canvas.width/2
    yc=canvas.height/2
    nofill()
    stroke(0.0, 0.25) # 75% transparent black.
    strokewidth(5)
    autoclosepath(close=False)
    triangle(xc, yc, xc+50, yc+100, xc+100, yc)
    line(xc, yc, xc+5, yc+234)
    
    global n,w, points
    
    strokewidth(w)
    line(points[n-1].x, points[n-1].y,points[n].x, points[n].y)

    if n<49:
        # print n, w, points[n].x, points[n].y
        w -= 0.2
        n += 1
    else:canvas.stop()
Exemplo n.º 6
0
def draw(canvas):
    background(Red)
    xc = canvas.width / 2
    yc = canvas.height / 2
    stroke(White)  # 75% transparent black.
    strokewidth(1)
    triangle(xc, yc, xc + 50, yc + 100, xc + 100, yc)

    # While rect() and ellipse() expect x, y, width, height parameters,
    # triangle() expects the coordinates of three points,
    # which are connected into a triangle.

    # Clear the current stroke,
    # otherwise it is still active in the next frame
    # when we start drawing the rectangle and the ellipse.
    # nostroke()

    # You can also pass Color objects to fill() and stroke().
    # A Color object can be created with the color command.
    # It has clr.r, clr.g, clr.b, clr.a properties :
    #   clr = color(0.25, 0.15, 0.75, 0.5) # 50% transparent purple/blue.
    #   fill(clr)

    for i in range(10):
        dx = random() * 200.0
        dy = random() * 200.0
        xs = random() * 1.6
        ys = random() * 1.6
        dr = random() * 360.0
        translate(dx, dy)
        scale(xs, ys, 1)
        rotate(dr)
        fill(1, 1, 0.9, 0.1)

        for path in paths:
            # Use copies of the paths
            # that adhere to the transformations
            # (translate, scale, rotate) we defined.
            drawpath(path)
Exemplo n.º 7
0
def draw(canvas):
    background(Red)
    xc=canvas.width/2
    yc=canvas.height/2
    stroke(White) # 75% transparent black.
    strokewidth(1)
    triangle(xc, yc, xc+50, yc+100, xc+100, yc)

# While rect() and ellipse() expect x, y, width, height parameters,
    # triangle() expects the coordinates of three points,
    # which are connected into a triangle.

    # Clear the current stroke,
    # otherwise it is still active in the next frame
    # when we start drawing the rectangle and the ellipse.
    # nostroke()
   
    # You can also pass Color objects to fill() and stroke().
    # A Color object can be created with the color command.
    # It has clr.r, clr.g, clr.b, clr.a properties :
    #   clr = color(0.25, 0.15, 0.75, 0.5) # 50% transparent purple/blue.
    #   fill(clr)

    for i in range(10):
        dx=random()*200.0
        dy=random()*200.0
        xs=random()*1.6
        ys=random()*1.6
        dr=random()*360.0
        translate(dx,dy)
        scale(xs,ys,1)
        rotate(dr)
        fill(1, 1, 0.9, 0.1)

        for path in paths:
            # Use copies of the paths
            # that adhere to the transformations
            # (translate, scale, rotate) we defined.
            drawpath(path)
Exemplo n.º 8
0
def draw(canvas):

    xc = canvas.width / 2
    yc = canvas.height / 2
    nofill()
    stroke(0.0, 0.25)  # 75% transparent black.
    strokewidth(5)
    autoclosepath(close=False)
    triangle(xc, yc, xc + 50, yc + 100, xc + 100, yc)
    line(xc, yc, xc + 5, yc + 234)

    global n, w, points

    strokewidth(w)
    line(points[n - 1].x, points[n - 1].y, points[n].x, points[n].y)

    if n < 49:
        # print n, w, points[n].x, points[n].y
        w -= 0.2
        n += 1
    else:
        canvas.stop()