<commit_before>//
// Flump - Copyright 2012 Three Rings Design

package flump.xfl {

import flash.geom.Matrix;

import flump.MatrixUtil;

public class XflKeyframe extends XflComponent
{
    use namespace xflns;

    public var index :int;

    /** The length of this keyframe in frames. */
    public var duration :Number;

    /** The name of the libraryItem in this keyframe, or null if there is no libraryItem. */
    public var libraryItem :String;

    /** The name of the symbol in this keyframe, or null if there is no symbol. */
    public var symbol :String;

    /**
     * The id by which this keyframe's texture can be found. Either the libraryItem for normal
     * keyframes, or a constructed name for flipbook frames. Since the libraryItem can be null, this
     * can also be null.
     */
    public var id :String;

    /** The label on this keyframe, or null if there isn't one */
    public var label :String;

    /** Exploded values from matrix */
    public var x :Number = 0.0, y :Number = 0.0, scaleX :Number = 1.0, scaleY :Number = 1.0,
        rotation :Number = 0.0;

    /** Transformation point */
    public var pivotX :Number = 0.0, pivotY :Number = 0.0;

    public var alpha :Number = 1;

    public var visible :Boolean = true;

    public var ease :Number = 0;

    public function XflKeyframe (baseLocation :String, xml :XML, errors :Vector.<ParseError>,
        flipbook :Boolean) {
        const converter :XmlConverter = new XmlConverter(xml);
        index = converter.getIntAttr("index");
        super(baseLocation + ":" + index, errors);
        duration = converter.getNumberAttr("duration", 1);
        label = converter.getStringAttr("name", null);
        ease = converter.getNumberAttr("acceleration", 0) / 100;

        if (flipbook) return;
        var symbolXml :XML;
        for each (var frameEl :XML in xml.elements.elements()) {
            if (frameEl.name().localName == "DOMSymbolInstance") {
                if (symbolXml != null)  {
                    addError(ParseError.CRIT, "There can be only one symbol instance at " +
                        "a time in a keyframe.");
                } else symbolXml = frameEl;
            } else {
                addError(ParseError.CRIT, "Non-symbols may not be in exported movie " +
                    "layers");
            }
        }

        if (symbolXml == null) return; // Purely labelled frame

        if (xml.tweens != null) {
            addError(ParseError.WARN, "Custom easing is not supported");
        }

        var symbolConverter :XmlConverter = new XmlConverter(symbolXml);
        id = libraryItem = symbolConverter.getStringAttr("libraryItemName");
        visible = symbolConverter.getBooleanAttr("isVisible", true);

        var matrix :Matrix = new Matrix();

        // Read the matrix transform
        if (symbolXml.matrix != null) {
            const matrixXml :XML = symbolXml.matrix.Matrix[0];
            const matrixConverter :XmlConverter =
                matrixXml == null ? null : new XmlConverter(matrixXml);
            function m (name :String, def :Number) :Number {
                return matrixConverter == null ? def : matrixConverter.getNumberAttr(name, def);
            }
            matrix = new Matrix(m("a", 1), m("b", 0), m("c", 0), m("d", 1), m("tx", 0), m("ty", 0));

            // handle "motionTweenRotate" (in this case, the rotation is not embedded in the matrix)
            if (converter.hasAttr("motionTweenRotateTimes") && duration > 1) {
                rotation = converter.getNumberAttr("motionTweenRotateTimes") * Math.PI * 2;
                if (converter.getStringAttr("motionTweenRotate", null) == "clockwise") {
                    rotation *= -1;
                }

                MatrixUtil.setRotation(matrix, rotation);
            } else {
                rotation = MatrixUtil.rotation(matrix);
            }

            scaleX = MatrixUtil.scaleX(matrix);
            scaleY = MatrixUtil.scaleY(matrix);
        }

        // Read the pivot point
        if (symbolXml.transformationPoint != null) {
            var pivotXml :XML = symbolXml.transformationPoint.Point[0];
            if (pivotXml != null) {<commit_msg>Require both motionTweenRotate and motionTweenRotateTimes to do anything here.<commit_after>//
// Flump - Copyright 2012 Three Rings Design

package flump.xfl {

import flash.geom.Matrix;

import flump.MatrixUtil;

public class XflKeyframe extends XflComponent
{
    use namespace xflns;

    public var index :int;

    /** The length of this keyframe in frames. */
    public var duration :Number;

    /** The name of the libraryItem in this keyframe, or null if there is no libraryItem. */
    public var libraryItem :String;

    /** The name of the symbol in this keyframe, or null if there is no symbol. */
    public var symbol :String;

    /**
     * The id by which this keyframe's texture can be found. Either the libraryItem for normal
     * keyframes, or a constructed name for flipbook frames. Since the libraryItem can be null, this
     * can also be null.
     */
    public var id :String;

    /** The label on this keyframe, or null if there isn't one */
    public var label :String;

    /** Exploded values from matrix */
    public var x :Number = 0.0, y :Number = 0.0, scaleX :Number = 1.0, scaleY :Number = 1.0,
        rotation :Number = 0.0;

    /** Transformation point */
    public var pivotX :Number = 0.0, pivotY :Number = 0.0;

    public var alpha :Number = 1;

    public var visible :Boolean = true;

    public var ease :Number = 0;

    public function XflKeyframe (baseLocation :String, xml :XML, errors :Vector.<ParseError>,
        flipbook :Boolean) {
        const converter :XmlConverter = new XmlConverter(xml);
        index = converter.getIntAttr("index");
        super(baseLocation + ":" + index, errors);
        duration = converter.getNumberAttr("duration", 1);
        label = converter.getStringAttr("name", null);
        ease = converter.getNumberAttr("acceleration", 0) / 100;

        if (flipbook) return;
        var symbolXml :XML;
        for each (var frameEl :XML in xml.elements.elements()) {
            if (frameEl.name().localName == "DOMSymbolInstance") {
                if (symbolXml != null)  {
                    addError(ParseError.CRIT, "There can be only one symbol instance at " +
                        "a time in a keyframe.");
                } else symbolXml = frameEl;
            } else {
                addError(ParseError.CRIT, "Non-symbols may not be in exported movie " +
                    "layers");
            }
        }

        if (symbolXml == null) return; // Purely labelled frame

        if (xml.tweens != null) {
            addError(ParseError.WARN, "Custom easing is not supported");
        }

        var symbolConverter :XmlConverter = new XmlConverter(symbolXml);
        id = libraryItem = symbolConverter.getStringAttr("libraryItemName");
        visible = symbolConverter.getBooleanAttr("isVisible", true);

        var matrix :Matrix = new Matrix();

        // Read the matrix transform
        if (symbolXml.matrix != null) {
            const matrixXml :XML = symbolXml.matrix.Matrix[0];
            const matrixConverter :XmlConverter =
                matrixXml == null ? null : new XmlConverter(matrixXml);
            function m (name :String, def :Number) :Number {
                return matrixConverter == null ? def : matrixConverter.getNumberAttr(name, def);
            }
            matrix = new Matrix(m("a", 1), m("b", 0), m("c", 0), m("d", 1), m("tx", 0), m("ty", 0));

            // handle "motionTweenRotate" (in this case, the rotation is not embedded in the matrix)
            if (converter.hasAttr("motionTweenRotateTimes") &&
                    converter.hasAttr("motionTweenRotate") && duration > 1) {
                rotation = converter.getNumberAttr("motionTweenRotateTimes") * Math.PI * 2;
                if (converter.getStringAttr("motionTweenRotate") == "clockwise") {
                    rotation *= -1;
                }

                MatrixUtil.setRotation(matrix, rotation);
            } else {
                rotation = MatrixUtil.rotation(matrix);
            }

            scaleX = MatrixUtil.scaleX(matrix);
            scaleY = MatrixUtil.scaleY(matrix);
        }

        // Read the pivot point
        if (symbolXml.transformationPoint != null) {
            var pivotXml :XML = symbolXml.transformationPoint.Point[0];
            if (pivotXml != null) {
{'fraction_non_alphanumeric': 0.10655257296917126, 'fraction_numerical': 0.008439807759934357, 'mean_word_length': 2.1788375558867363, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '7239626', 'n_tokens_mistral': 2419, 'n_tokens_neox': 2242, 'n_words': 764}