<commit_before>function getPropType(prop) {
    if( prop.propertyValueType === PropertyValueType.ThreeD_SPATIAL ||
        prop.propertyValueType === PropertyValueType.ThreeD ) {
        return 3;
    } else
    if( prop.propertyValueType === PropertyValueType.TwoD_SPATIAL ||
        prop.propertyValueType === PropertyValueType.TwoD ) {
        return 2;
    } else
    if( prop.propertyValueType === PropertyValueType.OneD ) {
        return 1;
    } else
    if( prop.propertyValueType === PropertyValueType.COLOR ) {
        return 4;
    }
    return [ prop.propertyValueType ];
}

function getProps(prop) {
    var output = "";
    var total = prop.numProperties;
    for(var i = 1; i <= total; ++i) {
        output += prop.property(i).name;
        if(i < total) output += ", ";
    }
    return output;
}

function testProp(prop) {
    var i, total = prop.numKeys;
    for(i = 1; 1 < total; ++i) {
        var n     = i + 1;
        var _inA  = prop.keyInTemporalEase(i)[0].influence.toString()  + ", " + prop.keyInTemporalEase(i)[0].speed.toString();
        var _outA = (prop.keyOutTemporalEase(i)[0].influence / 100).toString() + ", " + prop.keyOutTemporalEase(i)[0].speed.toString();
        var _inB  = (prop.keyInTemporalEase(n)[0].influence  / 100).toString() + ", " + (1-prop.keyInTemporalEase(n)[0].speed).toString();
        var _outB = prop.keyOutTemporalEase(n)[0].influence.toString() + ", " + prop.keyOutTemporalEase(n)[0].speed.toString();
        alert("Duration: " + (prop.keyTime(n) - prop.keyTime(i)).toFixed(2));
        // alert(_inA);  // 0.01, 0
        alert(_outA); // 75, 0 (key in)
        alert(_inB);  // 50, 0 (key out)
        // alert(_outB); // 0.01, 0
        // alert("In: "  + t1.toFixed(2) + " : " + (prop.keyInTemporalEase(i)[_i].influence).toString() + ", " + (prop.keyOutTemporalEase(i)[_i].speed).toString());
        // alert("Out: " + t2.toFixed(2) + " : " + (prop.keyInTemporalEase(n)[_i].influence).toString() + ", " + (prop.keyOutTemporalEase(n)[_i].speed).toString());
    }
}

function bezierKeyframes(prop, pName, options) {
    var keys = [];
    if(prop.numKeys <= 1) {
        return keys;
    }
    //
    var i, total = prop.numKeys;
    for(i = 1; i < total; ++i) {
        var n    = i + 1;
        var t1   = prop.keyTime(i);
        var t2   = prop.keyTime(n);
        var val1 = prop.keyValue(i);
        var val2 = prop.keyValue(n);
        if(t1 < options.duration) {
            var x1 = 0;
            var x2 = 0;
            var y1 = 0;
            var y2 = 0;
            var key  = {
                "type":     "bezier",
                "value":    val1,
                "target":   val2,
                "start":    t1,
                "duration": t2 - t1,
                "x0":       x1,
                "y0":       y1,
                "x1":       x2,
                "y1":       y2
            };
            //
            if(prop.propertyValueType !== PropertyValueType.OneD) {
                if(val1[0] !== val2[0]) {
                    val1 = val1[0];
                    val2 = val2[0];
                } else if(val1[1] !== val2[1]) {
                    val1 = val1[1];
                    val2 = val2[1];
                } else if(val1[2] !== val2[2]) {
                    val1 = val1[2];
                    val2 = val2[2];
                }
            }
            //
            var _min = Math.min(val1, val2);
            var _max = Math.max(val1, val2);
            var _range = _max - _min;
            //
            var delta_t = t2-t1;
            var delta   = val2-val1;
            var avSpeed = Math.abs(delta) / delta_t;
            x1 = prop.keyOutTemporalEase(i)[0].influence /100;
            
            if( prop.keyOutInterpolationType(i) === KeyframeInterpolationType.HOLD ) {
                // Hold
                x1 = y1 = 1/6;
                x2 = y2 = 1 - x1;
                key.type = "hold";
            } else {
                // Ease
                if( prop.keyOutInterpolationType(i) === KeyframeInterpolationType.LINEAR ) {
                    x1 = y1 = 1/6;
                }
                if( prop.keyInInterpolationType(n) === KeyframeInterpolationType.LINEAR ) {
                    x2 = y2 = 1 - (1/6);
                }
                
                if( prop.keyOutInterpolationType(i) === KeyframeInterpolationType.LINEAR &&
                    prop.keyInInterpolationType(n)  === KeyframeInterpolationType.LINEAR ) {
                    x1 = y1 = 1/6;
                    x2 = y2 = 1 - x1;
                    key.type = "linear";
                } else {
                    if (val1<val2){//, this should reproduce your website:     
                        y1 = Math.abs( x1*prop.keyOutTemporalEase(i)[0].speed / avSpeed );
                        x2 = 1-prop.keyInTemporalEase(n)[0].influence /100;
                        y2 = 1-(1-x2)*(prop.keyInTemporalEase(n)[0].speed / avSpeed);
                    } else if (val2<val1){//, to get a curve starting from point [0,1] going to point [1,0], it would be:
                        y1 = Math.abs( (-x1)*prop.keyOutTemporalEase(i)[0].speed / avSpeed );
                        x2 = prop.keyInTemporalEase(n)[0].influence /100;
                        y2 = 1+x2*(prop.keyInTemporalEase(n)[0].speed / avSpeed);
                        if(y2 > 1) y2 = 2 - y2;
                        x2 = 1-x2;
                    } else if (val1==val2){
                        x1 = prop.keyOutTemporalEase(i)[0].influence /100;  
                        y1 = Math.abs( (-x1)*prop.keyOutTemporalEase(i)[0].speed / (_range/(t2-t1)) );
                        x2 = prop.keyInTemporalEase(n)[0].influence /100;
                        y2 = 1+x2*(prop.keyInTemporalEase(n)[0].speed / (_range/(t2-t1)));
                        x2 = 1-x2;
                    }
                }
            }
            //
            key.x0 = x1;
            key.y0 = y1;
            key.x1 = x2;
            key.y1 = y2;
            keys.push( key );
        }
    }
    return {
        "name": pName,
        "keys": keys
    };
}

function textKeyframes(prop, pName, options) {
    var keys = [];
    if(prop.numKeys <= 1) {
        return keys;
    }
    //
    var i, total = prop.numKeys;
    var ease = 1/6;
    for(i = 1; i < total; ++i) {
        var n    = i + 1;
        var t1   = prop.keyTime(i);
        var t2   = prop.keyTime(n);
        var val1 = prop.keyValue(i);
        var val2 = prop.keyValue(n);
        if(val1 !== val2 && t1 < options.duration) {<commit_msg>animation bug fixed<commit_after>function getPropType(prop) {
    if( prop.propertyValueType === PropertyValueType.ThreeD_SPATIAL ||
        prop.propertyValueType === PropertyValueType.ThreeD ) {
        return 3;
    } else
    if( prop.propertyValueType === PropertyValueType.TwoD_SPATIAL ||
        prop.propertyValueType === PropertyValueType.TwoD ) {
        return 2;
    } else
    if( prop.propertyValueType === PropertyValueType.OneD ) {
        return 1;
    } else
    if( prop.propertyValueType === PropertyValueType.COLOR ) {
        return 4;
    }
    return [ prop.propertyValueType ];
}

function getProps(prop) {
    var output = "";
    var total = prop.numProperties;
    for(var i = 1; i <= total; ++i) {
        output += prop.property(i).name;
        if(i < total) output += ", ";
    }
    return output;
}

function testProp(prop) {
    var i, total = prop.numKeys;
    for(i = 1; 1 < total; ++i) {
        var n     = i + 1;
        var _inA  = prop.keyInTemporalEase(i)[0].influence.toString()  + ", " + prop.keyInTemporalEase(i)[0].speed.toString();
        var _outA = (prop.keyOutTemporalEase(i)[0].influence / 100).toString() + ", " + prop.keyOutTemporalEase(i)[0].speed.toString();
        var _inB  = (prop.keyInTemporalEase(n)[0].influence  / 100).toString() + ", " + (1-prop.keyInTemporalEase(n)[0].speed).toString();
        var _outB = prop.keyOutTemporalEase(n)[0].influence.toString() + ", " + prop.keyOutTemporalEase(n)[0].speed.toString();
        alert("Duration: " + (prop.keyTime(n) - prop.keyTime(i)).toFixed(2));
        // alert(_inA);  // 0.01, 0
        alert(_outA); // 75, 0 (key in)
        alert(_inB);  // 50, 0 (key out)
        // alert(_outB); // 0.01, 0
        // alert("In: "  + t1.toFixed(2) + " : " + (prop.keyInTemporalEase(i)[_i].influence).toString() + ", " + (prop.keyOutTemporalEase(i)[_i].speed).toString());
        // alert("Out: " + t2.toFixed(2) + " : " + (prop.keyInTemporalEase(n)[_i].influence).toString() + ", " + (prop.keyOutTemporalEase(n)[_i].speed).toString());
    }
}

function bezierKeyframes(prop, pName, options) {
    var keys = [];
    if (prop.numKeys > 1) {
        var i, total = prop.numKeys;
        for(i = 1; i < total; ++i) {
            var n    = i + 1;
            var t1   = prop.keyTime(i);
            var t2   = prop.keyTime(n);
            var val1 = prop.keyValue(i);
            var val2 = prop.keyValue(n);
            if(t1 < options.duration) {
                var x1 = 0;
                var x2 = 0;
                var y1 = 0;
                var y2 = 0;
                var key  = {
                    "type":     "bezier",
                    "value":    val1,
                    "target":   val2,
                    "start":    t1,
                    "duration": t2 - t1,
                    "x0":       x1,
                    "y0":       y1,
                    "x1":       x2,
                    "y1":       y2
                };
                //
                if(prop.propertyValueType !== PropertyValueType.OneD) {
                    if(val1[0] !== val2[0]) {
                        val1 = val1[0];
                        val2 = val2[0];
                    } else if(val1[1] !== val2[1]) {
                        val1 = val1[1];
                        val2 = val2[1];
                    } else if(val1[2] !== val2[2]) {
                        val1 = val1[2];
                        val2 = val2[2];
                    }
                }
                //
                var _min = Math.min(val1, val2);
                var _max = Math.max(val1, val2);
                var _range = _max - _min;
                //
                var delta_t = t2-t1;
                var delta   = val2-val1;
                var avSpeed = Math.abs(delta) / delta_t;
                x1 = prop.keyOutTemporalEase(i)[0].influence /100;
                
                if( prop.keyOutInterpolationType(i) === KeyframeInterpolationType.HOLD ) {
                    // Hold
                    x1 = y1 = 1/6;
                    x2 = y2 = 1 - x1;
                    key.type = "hold";
                } else {
                    // Ease
                    if( prop.keyOutInterpolationType(i) === KeyframeInterpolationType.LINEAR ) {
                        x1 = y1 = 1/6;
                    }
                    if( prop.keyInInterpolationType(n) === KeyframeInterpolationType.LINEAR ) {
                        x2 = y2 = 1 - (1/6);
                    }
                    
                    if( prop.keyOutInterpolationType(i) === KeyframeInterpolationType.LINEAR &&
                        prop.keyInInterpolationType(n)  === KeyframeInterpolationType.LINEAR ) {
                        x1 = y1 = 1/6;
                        x2 = y2 = 1 - x1;
                        key.type = "linear";
                    } else {
                        if (val1<val2){//, this should reproduce your website:     
                            y1 = Math.abs( x1*prop.keyOutTemporalEase(i)[0].speed / avSpeed );
                            x2 = 1-prop.keyInTemporalEase(n)[0].influence /100;
                            y2 = 1-(1-x2)*(prop.keyInTemporalEase(n)[0].speed / avSpeed);
                        } else if (val2<val1){//, to get a curve starting from point [0,1] going to point [1,0], it would be:
                            y1 = Math.abs( (-x1)*prop.keyOutTemporalEase(i)[0].speed / avSpeed );
                            x2 = prop.keyInTemporalEase(n)[0].influence /100;
                            y2 = 1+x2*(prop.keyInTemporalEase(n)[0].speed / avSpeed);
                            if(y2 > 1) y2 = 2 - y2;
                            x2 = 1-x2;
                        } else if (val1==val2){
                            x1 = prop.keyOutTemporalEase(i)[0].influence /100;  
                            y1 = Math.abs( (-x1)*prop.keyOutTemporalEase(i)[0].speed / (_range/(t2-t1)) );
                            x2 = prop.keyInTemporalEase(n)[0].influence /100;
                            y2 = 1+x2*(prop.keyInTemporalEase(n)[0].speed / (_range/(t2-t1)));
                            x2 = 1-x2;
                        }
                    }
                }
                //
                key.x0 = x1;
                key.y0 = y1;
                key.x1 = x2;
                key.y1 = y2;
                keys.push( key );
            }
        }
    }
    return {
        "name": pName,
        "keys": keys
    };
}

function textKeyframes(prop, pName, options) {
    var keys = [];
    if(prop.numKeys <= 1) {
        return keys;
    }
    //
    var i, total = prop.numKeys;
    var ease = 1/6;
    for(i = 1; i < total; ++i) {
        var n    = i + 1;
        var t1   = prop.keyTime(i);
        var t2   = prop.keyTime(n);
        var val1 = prop.keyValue(i);
        var val2 = prop.keyValue(n);
        if(val1 !== val2 && t1 < options.duration) {
{'fraction_non_alphanumeric': 0.14394164930038703, 'fraction_numerical': 0.03378981839833284, 'mean_word_length': 1.2981015905592612, 'pattern_counts': {'":': 22, '<': 24, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4198964', 'n_tokens_mistral': 4603, 'n_tokens_neox': 4307, 'n_words': 797}