Exemple #1
0
 def draw(self):
     clr1 = self.color
     clr2 = self.pressed and [v * 0.85 for v in self.color] or self.color
     translate(self.width / 2, self.height / 2)
     image(self.src["socket"], -self.width / 2, -self.height / 2, color=clr1)
     rotate(360 - self.value)
     image(self.src["face"], -self.width / 2, -self.height / 2, color=clr2)
Exemple #2
0
Fichier : bww.py Projet : 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)
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))
Exemple #4
0
Fichier : bww.py Projet : 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)
Exemple #5
0
def draw(canvas):
    gr.background(1)
    gr.fill(0,0.75)
    psystem.update()
    #print psystem[0].position.array
    for particle in psystem:
        gr.push()
        gr.translate(particle.position.x,particle.position.y)
        #if particle.position.y < 0:
        #    particle.position.y = 1000.0
        #   particle.color = (np.random.random(),np.random.random(),np.random.random(),np.random.random())
        #print particle.force.x
        gr.ellipse(0,0,5.0,5.0,fill = (50/abs(particle.velocity),0.1,0.5,0.5))
        gr.pop()
Exemple #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)
Exemple #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)
Exemple #8
0
 def draw(self):
     translate(self.width/2, self.height/2)
     image(self.src["socket"], -self.width/2, -self.height/2)
     rotate(360-self.value)
     clr = self.pressed and (0.85, 0.85, 0.85) or (1.0, 1.0, 1.0)
     image(self.src["face"], -self.width/2, -self.height/2, color=clr)
Exemple #9
0
 def draw(self):
     translate(self.width/2, self.height/2)
     image(self.src["socket"], -self.width/2, -self.height/2)
     rotate(360-self.value)
     clr = self.pressed and (0.85, 0.85, 0.85) or (1.0, 1.0, 1.0)
     image(self.src["face"], -self.width/2, -self.height/2, color=clr)