lightbeam over lava

sample animation for elektra simulator

This animation uses 50 threads: 1 for launch, 4 for the lava background, and 45 for the lightbeam overlay. The lightbeam overlay has the highest z-order to make it topmost.

 Loading animation...

Glowscript:

// DEVICE (modify with care)

 

    // Elektra simulator

    device: name = 'simulator-elektra-20'

    device: type = 'sim'

    device: tickIntervalMillisecs = '50'     // increase to reduce CPU load.

    device: protocolVersion = '1.0'

    device: ledCount = '20'

    device: ramSpaceBytes = '25000'          // set an animation size limit in memory.

    device: romSpaceBytes = '200000'         // set an animation size limit on disk.

 

// DEFINES (modify as needed)

 

    // LED defines:

    define: innerLeds = '[1-4]'    // alias for inner-ring leds.

    define: outerLeds = '[5-12]'

    define: edgeLeds = '[13-20]'

    define: allLeds = '[1-20]'

 

    // Color defines:

    define: red = '(25,0,0,1)'

    define: green = '(0,25,0,1)'

    define: blue = '(0,0,25,1)'

    define: yellow = '(25,25,0,1)'

    define: white = '(10,10,10,2)'

    define: orange = '(25,16,0,1)'

    define: purple = '(25,0,25,1)'

    define: off = '(0,0,0,1)'

 

// CODE

 

// Simultaneously launches 2 functions then exits.

@start                                       // mandatory function name for code launch.

    callAsync: @funcLava (zOrder=1)          // launch function asynchronously.

    callAsync: @funcLightbeam (zOrder=2)     // launch function asynchronously (top animation).

 

// Asynchronously launches 3 functions at staggered intervals then exits.

@funcLava

    glowRamp: innerLeds off to red in 400ms  // transition led(s) color.

    callAsync: @funcLavaInnerRing            // launch function asynchronously.

    glowRamp: outerLeds off to red in 400ms  // transition led(s) color.

    callAsync: @funcLavaOuterRing            // launch function asynchronously.

    glowRamp: edgeLeds off to red in 400ms

    callAsync: @funcLavaEdgeRing

 

// Continuously cycles inner-ring colors.

@funcLavaInnerRing

    here: start_tag                               // set bookmark.

    glowRamp: innerLeds red to orange in 1s       // transition led(s) color.

    glowRamp: innerLeds orange to yellow in 1s

    glowRamp: innerLeds yellow to green in 1s

    glowRamp: innerLeds green to blue in 1s

    glowRamp: innerLeds blue to purple in 1s

    glowRamp: innerLeds purple to red in 1s

    goto: start_tag                               // loop back to bookmark.

 

// Continuously cycles outer-ring colors.

@funcLavaOuterRing

    here: start_tag                               // set bookmark.

    glowRamp: outerLeds red to orange in 1s       // transition led(s) color.

    glowRamp: outerLeds orange to yellow in 1s

    glowRamp: outerLeds yellow to green in 1s

    glowRamp: outerLeds green to blue in 1s

    glowRamp: outerLeds blue to purple in 1s

    glowRamp: outerLeds purple to red in 1s

    goto: start_tag                               // loop back to bookmark.

 

// Continuously cycles edge-ring colors.

@funcLavaEdgeRing

    here: start_tag                               // set bookmark.

    glowRamp: edgeLeds red to orange in 1s        // transition led(s) color.

    glowRamp: edgeLeds orange to yellow in 1s

    glowRamp: edgeLeds yellow to green in 1s

    glowRamp: edgeLeds green to blue in 1s

    glowRamp: edgeLeds blue to purple in 1s

    glowRamp: edgeLeds purple to red in 1s

    goto: start_tag                               // loop back to bookmark.

 

// Periodically runs the directional lightbeam animations.

@funcLightbeam

    here: start_tag                     // set bookmark.

    pause: 2s

    call: @funcVerticalLightbeam        // call function synchronously.

    pause: 2s

    call: @funcDiagonalRightLightbeam   // call function synchronously.

    pause: 2s

    call: @funcHorizontalLightbeam      // call function synchronously.

    pause: 2s

    call: @funcDiagonalLeftLightbeam    // call function synchronously.

    goto: start_tag                     // loop back to bookmark.

 

// Illuminates vertical lightbeam path then exits.

@funcVerticalLightbeam

    callAsync: @funcVerticalLightbeamStep1        // call function asynchronously.

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep2

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep3

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep4

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep5

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep6

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep7

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep8

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep9

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep10

    pause: 50ms

    callAsync: @funcVerticalLightbeamStep11

 

// Illuminates horizontal lightbeam path then exits.

@funcHorizontalLightbeam

    callAsync: @funcHorizontalLightbeamStep1      // call function asynchronously.

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep2

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep3

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep4

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep5

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep6

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep7

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep8

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep9

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep10

    pause: 50ms

    callAsync: @funcHorizontalLightbeamStep11

 

// Illuminates diagonalLeft lightbeam path then exits.

@funcDiagonalLeftLightbeam

    callAsync: @funcDiagonalLeftLightbeamStep1    // call function asynchronously.

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep2

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep3

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep4

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep5

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep6

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep7

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep8

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep9

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep10

    pause: 50ms

    callAsync: @funcDiagonalLeftLightbeamStep11

 

// Illuminates diagonalRight lightbeam path then exits.

@funcDiagonalRightLightbeam

    callAsync: @funcDiagonalRightLightbeamStep1   // call function asynchronously.

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep2

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep3

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep4

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep5

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep6

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep7

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep8

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep9

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep10

    pause: 50ms

    callAsync: @funcDiagonalRightLightbeamStep11

 

// Functions that pulse LED(s) along the vertical lightbeam path.

@funcVerticalLightbeamStep1

    glowRamp: [13,20] white to off in 50ms

@funcVerticalLightbeamStep2

    glowRamp: [12] white to off in 50ms

@funcVerticalLightbeamStep3

    glowRamp: [5,11] white to off in 50ms

@funcVerticalLightbeamStep4

    glowRamp: [14,19] white to off in 50ms

@funcVerticalLightbeamStep5

    glowRamp: [2,3] white to off in 50ms

@funcVerticalLightbeamStep6

    glowRamp: [6,10] white to off in 50ms

@funcVerticalLightbeamStep7

    glowRamp: [1,4] white to off in 50ms

@funcVerticalLightbeamStep8

    glowRamp: [15,18] white to off in 50ms

@funcVerticalLightbeamStep9

    glowRamp: [7,9] white to off in 50ms

@funcVerticalLightbeamStep10

    glowRamp: [8] white to off in 50ms

@funcVerticalLightbeamStep11

    glowRamp: [16,17] white to off in 50ms

 

// Functions that pulse LED(s) along the horizontal lightbeam path.

@funcHorizontalLightbeamStep1

    glowRamp: [14,15] white to off in 50ms

@funcHorizontalLightbeamStep2

    glowRamp: [6] white to off in 50ms

@funcHorizontalLightbeamStep3

    glowRamp: [5,7] white to off in 50ms

@funcHorizontalLightbeamStep4

    glowRamp: [13,16] white to off in 50ms

@funcHorizontalLightbeamStep5

    glowRamp: [3,4] white to off in 50ms

@funcHorizontalLightbeamStep6

    glowRamp: [8,12] white to off in 50ms

@funcHorizontalLightbeamStep7

    glowRamp: [1,2] white to off in 50ms

@funcHorizontalLightbeamStep8

    glowRamp: [17,20] white to off in 50ms

@funcHorizontalLightbeamStep9

    glowRamp: [9,11] white to off in 50ms

@funcHorizontalLightbeamStep10

    glowRamp: [10] white to off in 50ms

@funcHorizontalLightbeamStep11

    glowRamp: [18,19] white to off in 50ms

 

// Functions that pulse LED(s) along the diagonal-left lightbeam path.

@funcDiagonalLeftLightbeamStep1

    glowRamp: [15,16] white to off in 50ms

@funcDiagonalLeftLightbeamStep2

    glowRamp: [7] white to off in 50ms

@funcDiagonalLeftLightbeamStep3

    glowRamp: [6,8] white to off in 50ms

@funcDiagonalLeftLightbeamStep4

    glowRamp: [14,17] white to off in 50ms

@funcDiagonalLeftLightbeamStep5

    glowRamp: [4] white to off in 50ms

@funcDiagonalLeftLightbeamStep6

    glowRamp: [5,9,1,3] white to off in 50ms

@funcDiagonalLeftLightbeamStep7

    glowRamp: [2] white to off in 50ms

@funcDiagonalLeftLightbeamStep8

    glowRamp: [13,18] white to off in 50ms

@funcDiagonalLeftLightbeamStep9

    glowRamp: [10,12] white to off in 50ms

@funcDiagonalLeftLightbeamStep10

    glowRamp: [11] white to off in 50ms

@funcDiagonalLeftLightbeamStep11

    glowRamp: [19,20] white to off in 50ms

 

// Functions that pulse LED(s) along the diagonal-right lightbeam path.

@funcDiagonalRightLightbeamStep1

    glowRamp: [17,18] white to off in 50ms

@funcDiagonalRightLightbeamStep2

    glowRamp: [9] white to off in 50ms

@funcDiagonalRightLightbeamStep3

    glowRamp: [10,8] white to off in 50ms

@funcDiagonalRightLightbeamStep4

    glowRamp: [16,19] white to off in 50ms

@funcDiagonalRightLightbeamStep5

    glowRamp: [1] white to off in 50ms

@funcDiagonalRightLightbeamStep6

    glowRamp: [11,2,4,7] white to off in 50ms

@funcDiagonalRightLightbeamStep7

    glowRamp: [3] white to off in 50ms

@funcDiagonalRightLightbeamStep8

    glowRamp: [20,15] white to off in 50ms

@funcDiagonalRightLightbeamStep9

    glowRamp: [12,6] white to off in 50ms

@funcDiagonalRightLightbeamStep10

    glowRamp: [5] white to off in 50ms

@funcDiagonalRightLightbeamStep11

    glowRamp: [13,14] white to off in 50ms