Ilysa by Example: Light - Fan

The transform package comes with many transformers you can use to construct light ID sequences. One such transformer is transform.Fan().

transform.Fan() accepts an integer argument groupCount. It then creates groupCount groups and allocates each light ID to a successive group until it reaches the groupCountth group. This process is repeated until all light IDs are allocated.

package main
import (
    "github.com/shasderias/ilysa"
    "github.com/shasderias/ilysa/beatsaber"
    "github.com/shasderias/ilysa/context"
    "github.com/shasderias/ilysa/evt"
    "github.com/shasderias/ilysa/light"
    "github.com/shasderias/ilysa/timer"
    "github.com/shasderias/ilysa/transform"
)
func main() {
    m, _ := beatsaber.NewMockMap(beatsaber.EnvironmentFitBeat, 120, "[]")
    p := ilysa.New(m)

1 - [1,2,3 ... 30]

    fbRing := transform.Light(
        light.NewBasic(p, evt.BackLasers),

1 - [1,3,5 ... 29]
2 - [2,4,6 ... 30]

        transform.Fan(2),

1 - [1,3,5 ... 29,2,4,6 ... 30]

        transform.Flatten(),

1 - [1]
2 - [3]
3 - [5]

29 - [28]
30 - [30]

        transform.DivideSingle(),
    )
    p.Sequence(timer.Beat(0), func(ctx context.Context) {
        ctx.Light(fbRing, func(ctx context.LightContext) {
            ctx.NewRGBLighting(evt.WithLight(evt.LightType(evt.LightRedOn)))
        })
    })
    p.Dump()
}
$ go run light-fan.go
[
    {"_customData":{"_lightID":1},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":3},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":5},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":7},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":9},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":11},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":13},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":15},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":17},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":19},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":21},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":23},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":25},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":27},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":29},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":2},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":4},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":6},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":8},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":10},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":12},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":14},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":16},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":18},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":20},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":22},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":24},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":26},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":28},"_time":0,"_type":5,"_value":5},
    {"_customData":{"_lightID":30},"_time":0,"_type":5,"_value":5}
]

Next example: Light - Gradient.