コード例 #1
0
 public static void AreEqual(DefineShapeTag expected, DefineShapeTag actual)
 {
     Assert.AreEqual(expected.ShapeID, actual.ShapeID);
     AssertData.AreEqual(expected.ShapeBounds, actual.ShapeBounds, "ShapeBounds");
     Assert.AreEqual(expected.FillStyles.Count, actual.FillStyles.Count, "FillStyles.Count");
     for (var i = 0; i < expected.FillStyles.Count; i++)
     {
         var exp = expected.FillStyles[i];
         var act = actual.FillStyles[i];
         AssertFillStyles.AreEqual(exp, act, "FillStyles[" + i + "]");
     }
     Assert.AreEqual(expected.LineStyles.Count, actual.LineStyles.Count, "LineStyles.Count");
     for (var i = 0; i < expected.LineStyles.Count; i++)
     {
         var exp = expected.LineStyles[i];
         var act = actual.LineStyles[i];
         AssertShape.AreEqual(exp, act, "LineStyles[" + i + "]");
     }
     Assert.AreEqual(expected.ShapeRecords.Count, actual.ShapeRecords.Count, "ShapeRecords.Count");
     for (var i = 0; i < expected.ShapeRecords.Count; i++)
     {
         var exp = expected.ShapeRecords[i];
         var act = actual.ShapeRecords[i];
         AssertShape.AreEqual(exp, act, "ShapeRecords[" + i + "]");
     }
     Assert.AreEqual(expected.RestData, actual.RestData);
 }
コード例 #2
0
ファイル: DefineShapeTagTest.cs プロジェクト: shhadi/SwfLib
        public void Test1()
        {
            var tag = ReadTag <DefineShapeTag>("Sample - 1.swf", "0bc5103606398401fa8a9ed11bb0596c");

            Assert.IsNotNull(tag);
            Assert.AreEqual(517, tag.ShapeID);
            Assert.AreEqual(3, tag.ShapeBounds.XMin);
            Assert.AreEqual(75, tag.ShapeBounds.XMax);
            Assert.AreEqual(3, tag.ShapeBounds.YMin);
            Assert.AreEqual(71, tag.ShapeBounds.YMax);

            Assert.AreEqual(1, tag.FillStyles.Count);
            AssertFillStyles.AreEqual(new SolidFillStyleRGB {
                Color = new SwfRGB {
                    Red = 255, Green = 255, Blue = 255
                }
            }, tag.FillStyles[0], "FillStyles[0]");

            Assert.AreEqual(0, tag.LineStyles.Count);

            Assert.AreEqual(33, tag.ShapeRecords.Count);
            var firstShape = tag.ShapeRecords.First() as StyleChangeShapeRecord;
            var lastShape  = tag.ShapeRecords.Last() as EndShapeRecord;

            Assert.IsNotNull(firstShape);
            Assert.IsNotNull(lastShape);

            Assert.AreEqual(60, firstShape.MoveDeltaX);
            Assert.AreEqual(17, firstShape.MoveDeltaY);
            Assert.IsNull(firstShape.FillStyle0);
            Assert.IsNotNull(firstShape.FillStyle1);
            Assert.AreEqual(1, firstShape.FillStyle1.Value);

            var lineShape  = tag.ShapeRecords[6] as StraightEdgeShapeRecord;
            var curveShape = tag.ShapeRecords[7] as CurvedEdgeShapeRecord;

            Assert.IsNotNull(lineShape);
            Assert.IsNotNull(curveShape);

            Assert.AreEqual(-2, lineShape.DeltaX);
            Assert.AreEqual(10, lineShape.DeltaY);

            Assert.AreEqual(0, curveShape.ControlDeltaX);
            Assert.AreEqual(12, curveShape.ControlDeltaY);
            Assert.AreEqual(9, curveShape.AnchorDeltaX);
            Assert.AreEqual(8, curveShape.AnchorDeltaY);

            Assert.AreEqual("0bc5103606398401fa8a9ed11bb0596c", GetTagHash(tag));
        }
コード例 #3
0
ファイル: DefineShape3TagTest.cs プロジェクト: shhadi/SwfLib
        public void Test1()
        {
            var tag = ReadTag <DefineShape3Tag>("Sample - 1.swf", "a120edb8a47355bb3729d8330595ae84");

            Assert.IsNotNull(tag);
            Assert.AreEqual(5, tag.ShapeID);
            Assert.AreEqual(0, tag.ShapeBounds.XMin);
            Assert.AreEqual(14560, tag.ShapeBounds.XMax);
            Assert.AreEqual(0, tag.ShapeBounds.YMin);
            Assert.AreEqual(1800, tag.ShapeBounds.YMax);

            Assert.AreEqual(1, tag.FillStyles.Count);
            var fillStyle = tag.FillStyles[0];

            AssertFillStyles.AreEqual(new LinearGradientFillStyleRGBA {
                GradientMatrix =
                {
                    ScaleX      =                    0,
                    ScaleY      =                    0,
                    RotateSkew0 =  0.05499267578125000,
                    RotateSkew1 = -0.05493164062500000,
                    TranslateX  =                 7280,
                    TranslateY  = 900
                },
                Gradient = new GradientRGBA {
                    InterpolationMode = InterpolationMode.Normal,
                    GradientRecords   =
                    {
                        new GradientRecordRGBA {
                            Color = new SwfRGBA(0, 0, 0, 0), Ratio = 0
                        },
                        new GradientRecordRGBA {
                            Color = new SwfRGBA(0, 0, 0, 204), Ratio = 255
                        },
                    }
                }
            }, fillStyle, "FillStyles[0]");


            Assert.AreEqual(6, tag.ShapeRecords.Count);
            var firstShape = tag.ShapeRecords.First() as StyleChangeShapeRecord;
            var lastShape  = tag.ShapeRecords.Last() as EndShapeRecord;

            Assert.IsNotNull(firstShape);
            Assert.IsNotNull(lastShape);

            //Assert.AreEqual("a120edb8a47355bb3729d8330595ae84", GetTagHash(tag));
        }
コード例 #4
0
ファイル: DefineShapeTagTest.cs プロジェクト: shhadi/SwfLib
        public void Test2()
        {
            var tag = ReadTag <DefineShapeTag>("Sample - 1.swf", "1a542a04b0196e306aab90b755982e0d");

            Assert.IsNotNull(tag);
            Assert.AreEqual(511, tag.ShapeID);
            Assert.AreEqual(2, tag.ShapeBounds.XMin);
            Assert.AreEqual(41, tag.ShapeBounds.XMax);
            Assert.AreEqual(2, tag.ShapeBounds.YMin);
            Assert.AreEqual(38, tag.ShapeBounds.YMax);

            Assert.AreEqual(1, tag.FillStyles.Count);
            AssertFillStyles.AreEqual(new SolidFillStyleRGB {
                Color = new SwfRGB {
                    Red = 255, Green = 255, Blue = 255
                }
            }, tag.FillStyles[0], "FillStyles[0]");

            Assert.AreEqual(0, tag.LineStyles.Count);

            Assert.AreEqual(15, tag.ShapeRecords.Count);
            var firstShape = tag.ShapeRecords.First() as StyleChangeShapeRecord;
            var lastShape  = tag.ShapeRecords.Last() as EndShapeRecord;

            Assert.IsNotNull(firstShape);
            Assert.IsNotNull(lastShape);

            Assert.AreEqual(41, firstShape.MoveDeltaX);
            Assert.AreEqual(20, firstShape.MoveDeltaY);
            Assert.IsNull(firstShape.FillStyle0);
            Assert.IsNotNull(firstShape.FillStyle1);
            Assert.AreEqual(1, firstShape.FillStyle1.Value);

            var styleChange = tag.ShapeRecords[9] as StyleChangeShapeRecord;

            Assert.IsNotNull(styleChange);

            Assert.AreEqual(31, styleChange.MoveDeltaX);
            Assert.AreEqual(11, styleChange.MoveDeltaY);
            Assert.IsNull(styleChange.FillStyle0);
            Assert.IsNull(styleChange.FillStyle1);

            Assert.AreEqual("1a542a04b0196e306aab90b755982e0d", GetTagHash(tag));
        }