def draw(canvas):
    
    canvas.clear()

    # Apply a blur filter to the procedural image and draw it.
    image(blur(img, scale=canvas.mouse.relative_x), 20, 100)
    
    # Compare to the same shapes drawn directly to the canvas.
    # You may notice that the rendered image has jagged edges...
    # For now, there is nothing to be done about that - a soft blur can help.
    translate(300,100)
    fill(1, 0, 0, 0.5)
    ellipse(120, 120, 200, 200)
    fill(0, 1, 0, 0.5)
    ellipse(170, 120, 200, 200)
    fill(0, 0, 1, 0.5) 
    ellipse(145, 160, 200, 200)
def draw(canvas):

    canvas.clear()

    # Apply a blur filter to the procedural image and draw it.
    image(blur(img, scale=canvas.mouse.relative_x), 20, 100)

    # Compare to the same shapes drawn directly to the canvas.
    # You may notice that the rendered image has jagged edges...
    # For now, there is nothing to be done about that - a soft blur can help.
    translate(300, 100)
    fill(1, 0, 0, 0.5)
    ellipse(120, 120, 200, 200)
    fill(0, 1, 0, 0.5)
    ellipse(170, 120, 200, 200)
    fill(0, 0, 1, 0.5)
    ellipse(145, 160, 200, 200)
#loads shader.py, there are some type issues that need to be fixed

# Load an image from file.
# For performance, it's a good idea to create images once, outside the draw() loop.
# NodeBox can then keep the image in graphics card memory so it displays faster.

img = Image("creature.png")

# A simple image effect is a drop shadow.
# We create a grayscale version of the image with the colorize() filter,
# by reducing the image's R,G,B channels to zero but keeping the alpha channel.
# Then we diffuse it with the blur() filter.
# We create the shadow outside the draw() loop for performance:
shadow = colorize(img, color=(0,0,0,1))
shadow = blur(shadow, amount=3, kernel=5)

def draw(canvas):
    
    canvas.clear()
    
    # Some simple mouse interaction to make it more interesting.
    # Moving the mouse up will move the creature up from the ground.
    dy = canvas.mouse.y
    
    # The origin point (0,0) of the canvas is in the lower left corner.
    # Transformations such as rotate() and scale() originate from (0,0).
    # We move (or "translate") the origin point to the center of the canvas,
    # and then draw the image a bit to the left and to the bottom of it.
    # This way, transformations will originate from the center.
    translate(canvas.width/2, canvas.height/2)
Beispiel #4
0
#loads shader.py, there are some type issues that need to be fixed

# Load an image from file.
# For performance, it's a good idea to create images once, outside the draw() loop.
# NodeBox can then keep the image in graphics card memory so it displays faster.

img = Image("creature.png")

# A simple image effect is a drop shadow.
# We create a grayscale version of the image with the colorize() filter,
# by reducing the image's R,G,B channels to zero but keeping the alpha channel.
# Then we diffuse it with the blur() filter.
# We create the shadow outside the draw() loop for performance:
shadow = colorize(img, color=(0, 0, 0, 1))
shadow = blur(shadow, amount=3, kernel=5)


def draw(canvas):

    canvas.clear()

    # Some simple mouse interaction to make it more interesting.
    # Moving the mouse up will move the creature up from the ground.
    dy = canvas.mouse.y

    # The origin point (0,0) of the canvas is in the lower left corner.
    # Transformations such as rotate() and scale() originate from (0,0).
    # We move (or "translate") the origin point to the center of the canvas,
    # and then draw the image a bit to the left and to the bottom of it.
    # This way, transformations will originate from the center.