Пример #1
0
        public MovinShapeSlave(MovinShape master, BodymovinShapePath path, float strokeWidth = 1f)
        {
            this.master = master;
            this.path   = path;
            Transform parent = master.transform.parent;


            /* SHAPE PROPS */

            points    = (BodyPoint[])path.points.Clone();
            motionSet = path.animSets;
            closed    = path.closed;


            /* ANIM SETUP */

            MotionSetup(ref animated, ref motion, motionSet);


            /* GAMEOBJECT */

            transform = new RectTransform();
            transform.SetParent(parent, false);
            transform.localPosition = master.transform.localPosition;


            /* SETUP VECTOR */

            fill = master.content.fillHidden || master.content.fillColor == null
                ? null
                : new SolidFill()
            {
                Color = master.fill.Color
            };
            stroke = master.content.strokeHidden || master.content.strokeColor == null
                ? null
                : new Stroke()
            {
                Color = master.stroke.Color, HalfThickness = master.content.strokeWidth * strokeWidth
            };
            props = new PathProperties()
            {
                Stroke = stroke
            };

            shape = new Shape()
            {
                Fill          = fill,
                PathProps     = props,
                FillTransform = Matrix3.I()
            };

            UpdateMesh();
        }
Пример #2
0
        public MovinShape(MovinLayer layer, BodymovinShape content)
        {
            this.content = content;
            if (content.paths == null || content.paths.Length < 1)
            {
                Debug.Log("DON'T DRAW SHAPE -> NO PTS");
                return;
            }

            this.layer = layer;
            movin      = layer.movin;
            Transform parent = layer.transform;


            /* FIRST SHAPE PROPS */

            points    = (BodyPoint[])content.paths[0].points.Clone();
            motionSet = content.paths[0].animSets;
            closed    = content.paths[0].closed;


            /* ANIM SETUP */

            MotionSetup(ref animated, ref motion, motionSet);
            MotionSetup(ref strokeColorAnimated, ref mstrokec, content.strokeColorSets);
            MotionSetup(ref fillColorAnimated, ref mfillc, content.fillColorSets);


            /* GAMEOBJECT, MESH, MATERIAL */
            transform = new RectTransform();
            transform.SetParent(parent, false);
            transform.localPosition = -layer.content.anchorPoint;


            /* SETUP VECTOR */

            Color stClr = (content.strokeColor == null)
                ? new Color(1, 1, 1)
                : new Color(content.strokeColor[0], content.strokeColor[1], content.strokeColor[2]);
            Color flClr = (content.fillColor == null)
                ? new Color(1, 1, 1)
                : new Color(content.fillColor[0], content.fillColor[1], content.fillColor[2]);

            currentStrokeColor = new Vector3(stClr.r, stClr.g, stClr.b);
            currentFillColor   = new Vector3(flClr.r, flClr.g, flClr.b);

            fill = content.fillHidden || content.fillColor == null ? null : new SolidFill()
            {
                Color = flClr
            };
            stroke = content.strokeHidden || content.strokeColor == null
                ? null
                : new Stroke()
            {
                Color = stClr, HalfThickness = content.strokeWidth * movin.strokeWidth
            };
            props = new PathProperties()
            {
                Stroke = stroke
            };

            shape = new Shape()
            {
                Fill          = fill,
                PathProps     = props,
                FillTransform = Matrix3.I()
            };

            UpdateMesh();


            // ADDITIONAL SHAPE PATHS

            slaves = new MovinShapeSlave[content.paths.Length - 1];
            for (int i = 1; i <= slaves.Length; i++)
            {
                slaves[i - 1] = new MovinShapeSlave(this, content.paths[i], movin.strokeWidth);
            }
        }