import webbrowser

from bibliopixel.drivers.SimPixel import DriverSimPixel
from bibliopixel import LEDMatrix

SIMPIXEL_URL = 'http://beta.simpixel.io'
IMPORT_ERROR_TEXT = """
Please install the BiblioPixelAnimations library from here:

https://github.com/ManiacalLabs/BiblioPixelAnimations

"""


def run(args):
    try:
        from BiblioPixelAnimations.matrix.bloom import Bloom
    except ImportError:
        raise ValueError(IMPORT_ERROR_TEXT)

    driver = DriverSimPixel(args.x * args.y)
    led = LEDMatrix(driver, width=args.x, height=args.y)
    anim = Bloom(led)

    webbrowser.open(SIMPIXEL_URL, new=0, autoraise=True)
    anim.run()


def set_parser(parser):
    parser.set_defaults(run=run)
    parser.add_argument('-name', default='bloom')
    parser.add_argument('-x', default=32, type=int)
    parser.add_argument('-y', default=32, type=int)

@@ -95,22 +95,41 @@
 port LED
-Matrix
+Circle, LEDMatrix, layout
 %0A%0ASIMPIX
@@ -313,19 +313,21 @@
 %22%0A%0A%0Adef 
-run
+bloom
 (args):%0A
@@ -334,21 +334,129 @@
     
-try:%0A     
+driver = DriverSimPixel(args.width * args.height)%0A    led = LEDMatrix(driver, width=args.width, height=args.height)%0A%0A
    
+ 
 from
@@ -512,198 +512,830 @@
     
-except ImportError:%0A        raise ValueError(IMPORT_ERROR_TEXT)%0A%0A    driver = DriverSimPixel(args.x * args.y)%0A    led = LEDMatrix(driver, width=args.x, height=args.y)%0A    anim = Bloom(led)%0A%0A
+return Bloom(led)%0A%0A%0Adef circle(args):%0A    pixels_per = %5B1, 4, 8, 12, 18, 24, 32, 40, 52, 64%5D%0A    rings, steps = layout.gen_circle(pixels_per=pixels_per)%0A    points = layout.layout_from_rings(rings, origin=(200, 200, 0), z_diff=8)%0A    driver = DriverSimPixel(sum(pixels_per), layout=points)%0A    led = LEDCircle(driver, rings=rings, maxAngleDiff=0)%0A%0A    from BiblioPixelAnimations.circle.bloom import Bloom%0A    return Bloom(led)%0A%0A%0ADEMO_TABLE = %7Bf.__name__: f for f in (bloom, circle, )%7D%0A%0A%0Adef run(args):%0A    try:%0A        demo = DEMO_TABLE%5Bargs.name%5D%0A    except KeyError:%0A        raise KeyError('Unknown command %25s' %25 args.name)%0A    try:%0A        anim = demo(args)%0A    except ImportError as e:%0A        if 'BiblioPixelAnimations' in e.msg:%0A            e.msg += IMPORT_ERROR_TEXT%0A        raise%0A%0A    if not args.no_simpixel:%0A    
     
@@ -1387,16 +1387,17 @@
 e=True)%0A
+%0A
     anim
@@ -1538,17 +1538,21 @@
 ument('-
-x
+width
 ', defau
@@ -1594,17 +1594,22 @@
 ument('-
-y
+height
 ', defau
@@ -1605,28 +1605,89 @@
 ght', default=32, type=int)%0A
+    parser.add_argument('-no_simpixel', action='store_true')%0A

Add a second demo.