Search Results for

    Show / Hide Table of Contents

    API Documentation

    DMath

    The DMK.DMath.Functions namespace contains all the functions usable in math code in scripts.

    Math functions may be present in one of two forms:

    • Functions that return expressions. These are in the classes that start with ExM.
    • Functions that return functions that return expressions. These are in all other classes.

    The reasons that two forms exist is because the first form is much simpler to write and test, but the second form is a necessary base structure for features like aliasing.

    Within script code, the difference is irrelevant, as the reflection code makes these types interoperable. However, while reading the documentation, keep in mind these type equivalencies:

    TEx<float> = tfloat; can be converted to ExBPY; compiles to BPY or GCXF<float>
    TEx<float> = tfloat; can be converted to ExFXY; compiles to FXY
    TEx<bool> = tbool; can be converted to ExPred; compiles to Pred or GCXF<bool>
    TEx<Vector2> = tv2; can be converted to ExTP; compiles to TP or GCXF<Vector2>
    TEx<Vector3> = tv3; can be converted to ExTP3; compiles to TP3 or GCXF<Vector3>
    TEx<Vector4> = tv4; can be converted to ExTP4; compiles to TP4 or GCXF<Vector4>
    TEx<V2RV2> = trv2; can be converted to ExBPRV2; compiles to BPRV2 or GCXF<V2RV2>
    
    t?/TEx<?> is an expression type.
    Ex? is an expression function type.
    ?/GCXF<?> is a compiled function type.
    

    GCXF<T> is a type used in StateMachine functions and repeater objects which is an automatically-configured wrapper around the corresponding expression function types. Unlike the normal functions, GCXF<T> has access to bound variables within the GenCtx. The equivalencies are as follows:

    GCXF<float> = BPY
    GCXF<bool> = Pred
    GCXF<Vector2> = TP
    GCXF<Vector3> = TP3
    GCXF<Vector4> = TP4
    GCXF<V2RV2> = BPRV2
    

    Two Time Models

    The engine has two different models of time: frames and seconds. Each second is 120 frames (this is a fixed constant). The only major places that use frames are GenCtxProperties (which is used primarily in patterning code), since these usages often require firing with intervals that are much smaller than one second. Almost all other locations use seconds.

    Style Combinations

    Consider this code:

    pattern
    phase 0
    	paction 0
    		async star-** <> gcrepeat {
    			wait(60)
    			times(_)
    			rv2incr(<5h>)
                color { purple orange }
            } gsrepeat {
    			times(72)
    			circle
                color { /w /b }
            } simple(rvelocity(cx(2)), {
    			dir(starrotb2())
    		})
    

    This will result in repeatedly firing rings of randomly-rotating stars, where the rings switch between the colors purple and orange, and the stars in each ring switch between the normal and inverted color styles.

    This is possible due to how colors are merged. When you set the color of a fire via a color command, or anything similar, in repeater functions, it tries to replace the first wildcard in the existing color with the provided color. Only if no wildcard is found will it completely replace the color.

    • Improve this Doc
    In This Article
    Back to top Generated by DocFX