spwn 0.0.6

A language for Geometry Dash triggers
Documentation
#[no_std, cache_output]

constants = import "constants.spwn"

extract constants.obj_props
extract import "control_flow.spwn"
extract import "util.spwn"
impl @color {

    _range_: #[desc("Implementation of the range operator (`..`) for colors") example("
for color in 1c..10c {
    -> color.set(0,0,0, 0.5)
}
    ")] create_range_macro(@color),
    set:
    #[desc("Implementation of the color trigger") example("BG.set(0, 0, 0, 0.5) // turns the background color black")]
    (
        self,
        #[desc("Red value of the target color")] r: @number,
        #[desc("Green value of the target color")] g: @number,
        #[desc("Blue value of the target color")] b: @number,
        #[desc("Duration of color change")] duration: @number = 0,
        #[desc("Opacity of target color")] opacity: @number = 1,
        #[desc("Toggle blending on target color")] blending: @bool = false
    ){
        $.add( trigger{
            OBJ_ID: 899,
            DURATION: duration,
            TRIGGER_RED: r,
            TRIGGER_GREEN: g,
            TRIGGER_BLUE: b,
            OPACITY: opacity,
            BLENDING: blending,
            TARGET_COLOR: self,
            36: 1,
        })
        wait(duration)
    }, //1,899,2,285,3,105,36,1,7,255,8,255,9,255,10,0.5,35,0;

    pulse: #[desc("Implementation of the pulse trigger for colors") example("BG.pulse(255, 0, 0, fade_out = 0.5) // pulses the background red")]
    (
        self,
        #[desc("Red value of pulse color (or hue if HSV is enabled)")] r: @number,
        #[desc("Green value of pulse color (or saturation if HSV is enabled)")] g: @number,
        #[desc("Blue value of pulse color (or brightness/value if HSV is enabled)")] b: @number,
        #[desc("Fade-in duration")] fade_in: @number = 0,
        #[desc("Duration to hold the color")] hold: @number = 0,
        #[desc("Fade-out duration")] fade_out: @number = 0,
        #[desc("Weather to prioritize this pulse over simultaneous pulses")] exclusive: @bool = false,
        #[desc("Toggle HSV mode")] hsv: @bool = false,
        #[desc("HSV specific: saturation checked")] s_checked: @bool = false,
        #[desc("HSV specific: brightness checked")] b_checked: @bool = false
    ) {
        if hsv {
            $.add( trigger{
                OBJ_ID: 1006,
                COPIED_COLOR_HVS:
                    r as @string + "a" + g as @string + "a" + b as @string + "a"
                     + s_checked as @number as @string + "a" + b_checked as @number as @string,
                EXCLUSIVE: exclusive,
                FADE_IN: fade_in,
                HOLD: hold,
                FADE_OUT: fade_out,
                TARGET: self,
                PULSE_HSV: hsv,

            })
        } else {
            $.add( trigger{
                OBJ_ID: 1006,
                TRIGGER_RED: r,
                TRIGGER_GREEN: g,
                TRIGGER_BLUE: b,
                EXCLUSIVE: exclusive,
                FADE_IN: fade_in,
                HOLD: hold,
                FADE_OUT: fade_out,
                TARGET: self,
                PULSE_HSV: hsv,

            })
        }
        wait(fade_in + hold + fade_out)
    }
}