 
 M: bubble-chamber pref-dim* ( gadget -- dim ) size>> ;
 
-M: bubble-chamber ungraft* ( bubble-chamber -- ) t >>paused drop ;
-
 : iterate-particle ( particle -- ) move ;
 
 M:: bubble-chamber update-frame-buffer ( BUBBLE-CHAMBER -- )


: iterate-system ( bubble-chamber -- ) drop ;

:: start-bubble-chamber-thread ( GADGET -- )
    GADGET f >>paused drop [
        [
            GADGET paused>>
            [ f ]
            [ GADGET iterate-system GADGET relayout-1 1 milliseconds sleep t ]
            if
        ] loop
    ] in-thread ;

: <bubble-chamber> ( -- bubble-chamber )
    bubble-chamber new
    { 1000 1000 } >>size
    randomize-collision-theta ;

: bubble-chamber-window ( -- bubble-chamber )
    <bubble-chamber>
    dup start-bubble-chamber-thread
    dup "Bubble Chamber" open-window ;

:: add-particle ( BUBBLE-CHAMBER PARTICLE -- bubble-chamber )
    PARTICLE BUBBLE-CHAMBER >>bubble-chamber drop

USING: accessors arrays ascii calendar colors colors.gray
combinators.short-circuit frame-buffer fry kernel locals math
math.constants math.functions math.libm math.order math.points
math.ranges math.vectors namespaces opengl processing.shapes
quotations random sequences splitting threads timers ui
ui.gadgets ui.gadgets.borders ui.gadgets.buttons
ui.gadgets.packs ui.gestures ;

IN: bubble-chamber

