def draw(canvas):

    # It takes some juggling with the contrast of the colors to avoid artefacts.
    colorplane(0, 0, canvas.width, canvas.height,
               lighter(color(0.14, 0.13, 0.18)), color(0.07, 0.06, 0.14),
               color(0.14, 0.20, 0.18), color(0.07, 0.06, 0.14))

    global plant
    plant = grow(plant)

    # Draw each root in the offscreen texture.
    # The texture already contains whatever was drawn in it previous frame.
    buffer.push()
    for root in plant:
        root.draw()
        root.step = canvas.mouse.relative_x * 60
        root.radius = canvas.mouse.relative_y * 30
    buffer.pop()

    # Every few frames, make the buffered image more transparent,
    # so that old content fades away.
    if canvas.frame % 2 == 0 and not canvas.mouse.pressed:
        buffer.texture = transparent(buffer.texture, 0.9).texture

    # Scale up the buffered image to the screen size.
    # Draw the image with a dropshadow effect.
    # Since the offscreen buffer is scaled, the edges will look rough.
    # Apply a small blur effect to smoothen them.
    img = buffer.texture
    #img = mirror(img, vertical=True, dx=0.35, dy=0) # Interesting patterns.
    image(dropshadow(img, alpha=1.0, amount=1),
          0,
          -50,
          width=canvas.width,
          height=canvas.height + 50)
    # Hypnotizing breathing effect:
    img = stretch(img,
                  0.2,
                  0.1,
                  radius=0.75,
                  zoom=0.4 - cos(canvas.frame * 0.01) * 0.4)
    image(
        img,
        0,
        0,
        width=canvas.width,
        height=canvas.height,
    )  #filter = blurred(scale=0.75))
def draw(canvas):
    
    # It takes some juggling with the contrast of the colors to avoid artefacts.
    colorplane(0, 0, canvas.width, canvas.height, 
        lighter(color(0.14, 0.13, 0.18)), 
                color(0.07, 0.06, 0.14), 
                color(0.14, 0.20, 0.18), 
                color(0.07, 0.06, 0.14))

    global plant
    plant = grow(plant)
    
    # Draw each root in the offscreen texture.
    # The texture already contains whatever was drawn in it previous frame.
    buffer.push()
    for root in plant:
        root.draw()
        root.step = canvas.mouse.relative_x * 60
        root.radius = canvas.mouse.relative_y * 30
    buffer.pop()
    
    # Every few frames, make the buffered image more transparent,
    # so that old content fades away.
    if canvas.frame % 2 == 0 and not canvas.mouse.pressed:
        buffer.texture = transparent(buffer.texture, 0.9).texture
        
    # Scale up the buffered image to the screen size.
    # Draw the image with a dropshadow effect.
    # Since the offscreen buffer is scaled, the edges will look rough.
    # Apply a small blur effect to smoothen them.    
    img = buffer.texture
    #img = mirror(img, vertical=True, dx=0.35, dy=0) # Interesting patterns.
    image(dropshadow(img, alpha=1.0, amount=1), 0, -50, 
         width = canvas.width, 
        height = canvas.height+50)
    # Hypnotizing breathing effect:
    img = stretch(img, 0.2, 0.1, radius=0.75, zoom=0.4-cos(canvas.frame*0.01)*0.4)
    image(img, 0, 0,
         width = canvas.width, 
        height = canvas.height,
        )#filter = blurred(scale=0.75))
import os, sys
sys.path.insert(0, os.path.join("..",".."))

from nodebox.graphics.context import *
from nodebox.graphics import *

from nodebox.graphics.geometry import coordinates
from nodebox.graphics.shader   import dropshadow, OffscreenBuffer, transparent, stretch

from time import time

flower = Image("cell.png")
shadow = dropshadow(flower, alpha=1.0) # = image(blur(flower), color=(0,0,0,1))
# Each "flower" is drawn with a shadow underneath to add some depth.
# The global shadow layer is at the bottom of the plant.
# Ideally, each growing root would have its own shadow,
# but it is faster this way using only one offscreen buffer for all global shadows
# and a pre-rendered shadow image for each individual flower. 

class Root:
    
    def __init__(self, x, y, angle=90, radius=20, step=60, time=1.0, color=Color(0)):
        self.x      = x
        self.y      = y
        self.angle  = angle
        self.radius = radius # Segment length.
        self.step   = step   # Maximum left or right rotation from current angle.
        self.time   = time
        self.color  = color
        
    def copy(self):
import os, sys
sys.path.insert(0, os.path.join("..", ".."))

from nodebox.graphics.context import *
from nodebox.graphics import *

from nodebox.graphics.geometry import coordinates
from nodebox.graphics.shader import dropshadow, OffscreenBuffer, transparent, stretch

from time import time

flower = Image("cell.png")
shadow = dropshadow(flower,
                    alpha=1.0)  # = image(blur(flower), color=(0,0,0,1))
# Each "flower" is drawn with a shadow underneath to add some depth.
# The global shadow layer is at the bottom of the plant.
# Ideally, each growing root would have its own shadow,
# but it is faster this way using only one offscreen buffer for all global shadows
# and a pre-rendered shadow image for each individual flower.


class Root:
    def __init__(self,
                 x,
                 y,
                 angle=90,
                 radius=20,
                 step=60,
                 time=1.0,
                 color=Color(0)):
        self.x = x