Exemplo n.º 1
0
        private void AreEqual_Distance(Ray2D ray, Circle2 circle, float expected = 0)
        {
            string message = string.Format(format, ray, circle);

            AreEqual(Distance.RayCircle(ray.origin, ray.direction, circle.center, circle.radius), expected, message);
        }
Exemplo n.º 2
0
 private void ClosestPoints_TwoPoints(Ray2D ray, Circle2 circle, Vector2 point1)
 {
     AreEqual_ClosestPoints(ray, circle, point1, point1);
 }
        private static void GetExternalPart(LineSegment3 segment, BuildingPrimitive primitive, List <LineSegment3> results)
        {
            var invTransform   = primitive.Transform.Invert();
            var transformedSeg = new LineSegment3(segment.Point1 * invTransform, segment.Point2 * invTransform);
            var seg            = new LineSegment2(transformedSeg.Point1.Xz, transformedSeg.Point2.Xz);

            if (primitive.Type == BuildingPrimitiveType.Rectangle)
            {
                var rect     = new AaRectangle2(Vector2.Zero, primitive.Scale.X, primitive.Scale.Z);
                var conains1 = rect.ContainsPoint(seg.Point1);
                var conains2 = rect.ContainsPoint(seg.Point2);
                if (conains1 && conains2)
                {
                    return;
                }
                if (!conains1 && !conains2)
                {
                    var p = Vector2.Zero;
                    int c = 0;
                    foreach (var rectSegment in rect.GetSegments())
                    {
                        var rsi = rectSegment.Intersect(seg);
                        if (rsi.HasValue)
                        {
                            p += rsi.Value;
                            c++;
                        }
                    }

                    if (c > 0)
                    {
                        var t = ((p / c) - seg.Point1).Length() / (seg.Point2 - seg.Point1).Length();
                        var m = segment.Point1 + (segment.Point2 - segment.Point1) * t;
                        GetExternalPart(new LineSegment3(segment.Point1, m), primitive, results);
                        GetExternalPart(new LineSegment3(m, segment.Point2), primitive, results);
                        return;
                    }

                    results.Add(segment);
                    return;
                }

                var swap = conains1;
                if (swap)
                {
                    CodingHelper.Swap(ref seg.Point1, ref seg.Point2);
                }
                var inter = seg.Intersect(new LineSegment2(
                                              new Vector2(-primitive.Scale.X, -primitive.Scale.Z),
                                              new Vector2(-primitive.Scale.X, primitive.Scale.Z)));
                if (inter.HasValue)
                {
                    var rs1 = To3(seg.Point1, inter.Value, primitive.Transform, swap);
                    results.Add(rs1);
                    return;
                }
                inter = seg.Intersect(new LineSegment2(
                                          new Vector2(primitive.Scale.X, -primitive.Scale.Z),
                                          new Vector2(primitive.Scale.X, primitive.Scale.Z)));
                if (inter.HasValue)
                {
                    var rs1 = To3(seg.Point1, inter.Value, primitive.Transform, swap);
                    results.Add(rs1);
                    return;
                }
                inter = seg.Intersect(new LineSegment2(
                                          new Vector2(-primitive.Scale.X, primitive.Scale.Z),
                                          new Vector2(primitive.Scale.X, primitive.Scale.Z)));
                if (inter.HasValue)
                {
                    var rs1 = To3(seg.Point1, inter.Value, primitive.Transform, swap);
                    results.Add(rs1);
                    return;
                }
                inter = seg.Intersect(new LineSegment2(
                                          new Vector2(-primitive.Scale.X, -primitive.Scale.Z),
                                          new Vector2(primitive.Scale.X, -primitive.Scale.Z)));
                if (inter.HasValue)
                {
                    var rs1 = To3(seg.Point1, inter.Value, primitive.Transform, swap);
                    results.Add(rs1);
                    return;
                }

                var rs2 = segment;
                results.Add(rs2);
                return;
            }
            else
            {
                var circle = new Circle2(Vector2.Zero, primitive.Scale.X);

                var conains1 = circle.Contains(seg.Point1);
                var conains2 = circle.Contains(seg.Point2);
                if (conains1 && conains2)
                {
                    return;
                }
                if (!conains1 && !conains2)
                {
                    var rs1 = segment;
                    results.Add(rs1);
                    return;
                }

                var swap = conains1;
                if (swap)
                {
                    CodingHelper.Swap(ref seg.Point1, ref seg.Point2);
                }

                var dpp   = seg.Point2 - seg.Point1;
                var dpc   = seg.Point1;
                var a     = dpp.LengthSquared();
                var b     = Vector2.Dot(dpp, dpc);
                var c     = dpc.LengthSquared() - circle.Radius.Sq();
                var discr = b * b - a * c;
                if (discr < 0)
                {
                    results.Add(segment);
                    return;
                }
                if (discr < MathHelper.Eps5)
                {
                    results.Add(segment);
                    return;
                    //var l = -b / a;
                    //if (0 <= l && l <= 1)
                }
                {
                    var sqrdscr = MathHelper.Sqrt(discr);
                    var l1      = (-b + sqrdscr) / a;
                    var l2      = (-b - sqrdscr) / a;
                    if (0 <= l1 && l1 <= 1)
                    {
                        var rs1 = To3(seg.Point1, Vector2.Lerp(seg.Point1, seg.Point2, l1), primitive.Transform, swap);
                        results.Add(rs1);
                    }

                    if (0 <= l2 && l2 <= 1)
                    {
                        var rs1 = To3(seg.Point1, Vector2.Lerp(seg.Point1, seg.Point2, l2), primitive.Transform, swap);
                        results.Add(rs1);
                    }
                }
            }
        }
Exemplo n.º 4
0
 VisualPoint(Circle2 point)
 {
     _point       = point;
     _visualPoint = new VisualCircle(_point);
 }
Exemplo n.º 5
0
 private void ClosestPoints_TwoPoints(Line2 line, Circle2 circle, Vector2 point1, Vector2 point2)
 {
     AreEqual_ClosestPoints(line, circle, point1, point1);
     line.direction = -line.direction;
     AreEqual_ClosestPoints(line, circle, point2, point2);
 }
Exemplo n.º 6
0
 private void False_Intersect(Line2 line, Circle2 circle)
 {
     Assert.False(Intersect.LineCircle(line.origin, line.direction, circle.center, circle.radius, out _), format, line, circle);
     Assert.False(Intersect.LineCircle(line.origin, -line.direction, circle.center, circle.radius, out _), format, line, circle);
 }
Exemplo n.º 7
0
        private static Circle2 ComputeMaximumInscribedCircle(PointCloud2 points, AutomationLibrary.Mathematics.Geometry.Voronoi.VoronoiDiagram voronoi, Circle2 mcc)
        {
            var candidateCenters = new List <Vector2>();

            candidateCenters.AddRange(voronoi.Vertices.Keys);
            // TODO: add intersections between voronoi edges and convex hull of points

            Circle2 incumbent = new Circle2(points.First(), 0);

            foreach (var candidate in candidateCenters)
            {
                foreach (var neighbor in voronoi.Vertices[candidate])
                {
                    var candidateRadius = Vector2.DistanceBetweenPoints(candidate, neighbor);

                    if (candidateRadius > incumbent.Radius && mcc.Contains(candidate))
                    {
                        incumbent = new Circle2(candidate, candidateRadius);
                    }
                }
            }

            return(incumbent);
        }
 private void AreEqual_Distance(Circle2 circleA, Circle2 circleB, float expected = 0)
 {
     AreEqual(Distance.CircleCircle(circleA, circleB), expected);
     AreEqual(Distance.CircleCircle(circleB, circleA), expected);
 }
 private void AreEqual_Distance(Circle2 circle, Vector2 point, float expected = 0)
 {
     AreEqual(Distance.PointCircle(point, circle), expected);
 }
        private void False_Intersect(Ray2D ray, Circle2 circle)
        {
            string message = string.Format(format, ray.ToString("F8"), circle);

            Assert.False(Intersect.RayCircle(ray.origin, ray.direction, circle.center, circle.radius, out IntersectionRayCircle intersection), message);
        }
 private void False_Intersect(Circle2 circle, Vector2 point)
 {
     Assert.False(Intersect.PointCircle(point, circle), format, circle, point.ToString("F8"));
 }
 private void AreEqual_ClosestPoint(Circle2 circle, Vector2 point, Vector2 expected)
 {
     AreEqual(Closest.PointCircle(point, circle), expected);
 }
 private void False_Intersect(Segment2 segment, Circle2 circle)
 {
     Assert.False(Intersect.SegmentCircle(segment.a, segment.b, circle.center, circle.radius, out _), format, segment, circle);
     Assert.False(Intersect.SegmentCircle(segment.b, segment.a, circle.center, circle.radius, out _), format, segment, circle);
 }
Exemplo n.º 14
0
 private void ClosestPoints_OnePoint(Ray2D ray, Circle2 circle, Vector2 expected)
 {
     AreEqual_ClosestPoints(ray, circle, expected, expected);
 }
Exemplo n.º 15
0
        public PolyCurve ToPolyCurve(double radius)
        {
            Circle2      circle2    = new Circle2(this.M, radius);
            PolyCurve    polyCurve1 = new PolyCurve();
            Circle       circle     = new Circle(new Point3d(this.M.x, this.M.y, 0.0), radius);
            double       num1       = double.NaN;
            double       num2       = double.NaN;
            List <Line2> line2List  = this.Edges();
            PolyCurve    polyCurve2;

            if (line2List.Count == 0)
            {
                polyCurve2 = (PolyCurve)null;
            }
            else
            {
                int num3 = line2List.Count - 1;
                for (int index = 0; index <= num3; ++index)
                {
                    double l0 = 0.0;
                    double l1 = 0.0;
                    double a0 = 0.0;
                    double a1 = 0.0;
                    switch (circle2.Intersect(line2List[index], ref l0, ref l1, ref a0, ref a1))
                    {
                    case LineCircleX.Secant:
                        Node2 node2_1 = line2List[index].PointAt(l0);
                        Node2 node2_2 = line2List[index].PointAt(l1);
                        if (l0 <= 1.0 && l1 >= 0.0)
                        {
                            if (l0 >= 0.0)
                            {
                                if (l0 < 1.0)
                                {
                                    if (double.IsNaN(num1))
                                    {
                                        num1 = a0;
                                    }
                                    if (!double.IsNaN(num2))
                                    {
                                        Node2 node2_3 = circle2.PointAt(num2);
                                        Node2 node2_4 = circle2.PointAt(a0);
                                        Vec2  vec2    = circle2.TangentAt(num2);
                                        Arc   arc     = new Arc(new Point3d(node2_3.x, node2_3.y, 0.0), new Vector3d(vec2.x, vec2.y, 0.0), new Point3d(node2_4.x, node2_4.y, 0.0));
                                        polyCurve1.Append(arc);
                                    }
                                    if (l1 > l0 && l1 <= 1.0)
                                    {
                                        polyCurve1.Append(new Line(new Point3d(node2_1.x, node2_1.y, 0.0), new Point3d(node2_2.x, node2_2.y, 0.0)));
                                        num2 = a1;
                                        break;
                                    }
                                    polyCurve1.Append(new Line(new Point3d(node2_1.x, node2_1.y, 0.0), new Point3d(line2List[index].Bx, line2List[index].By, 0.0)));
                                    num2 = double.NaN;
                                    break;
                                }
                                break;
                            }
                            if (l1 >= 0.0 && l1 <= 1.0)
                            {
                                polyCurve1.Append(new Line(new Point3d(line2List[index].Ax, line2List[index].Ay, 0.0), new Point3d(node2_2.x, node2_2.y, 0.0)));
                                num2 = a1;
                                break;
                            }
                            polyCurve1.Append(new Line(new Point3d(line2List[index].Ax, line2List[index].Ay, 0.0), new Point3d(line2List[index].Bx, line2List[index].By, 0.0)));
                            num2 = double.NaN;
                            break;
                        }
                        break;
                    }
                }
                if (!double.IsNaN(num2) && !double.IsNaN(num1))
                {
                    Node2 node2_1 = circle2.PointAt(num2);
                    Node2 node2_2 = circle2.PointAt(num1);
                    Vec2  vec2    = circle2.TangentAt(num2);
                    Arc   arc     = new Arc(new Point3d(node2_1.x, node2_1.y, 0.0), new Vector3d(vec2.x, vec2.y, 0.0), new Point3d(node2_2.x, node2_2.y, 0.0));
                    polyCurve1.Append(arc);
                }
                if (polyCurve1.SegmentCount == 0)
                {
                    polyCurve1.Append((Curve) new ArcCurve(new Circle(new Point3d(this.M.x, this.M.y, 0.0), radius)));
                }
                polyCurve2 = polyCurve1;
            }
            return(polyCurve2);
        }
Exemplo n.º 16
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            NameLabel.Content  = FileName;
            LoadingBar.Maximum = FileSize;

            SmallSize          = SetSmallSize(FileSize);
            BytesLabel.Content = "0 / " + SmallSize.ToString("0.00") + PostSize;

            Connection.SendMessage(new MessageClass(Connection.ID, UserID, Commands.FileOK, ID));
            LastTime = DateTime.Now;
            LastNow  = 0;

            Task.Run(() =>
            {
                Dispatcher.Invoke(() =>
                {
                    var opacityAnim            = new DoubleAnimation();
                    opacityAnim.From           = 0;
                    opacityAnim.To             = 1;
                    opacityAnim.Duration       = TimeSpan.FromSeconds(2);
                    opacityAnim.RepeatBehavior = RepeatBehavior.Forever;
                    Circle1.BeginAnimation(System.Windows.Shapes.Ellipse.OpacityProperty, opacityAnim);

                    var circleAnim            = new DoubleAnimation();
                    circleAnim.From           = 80;
                    circleAnim.To             = 20;
                    circleAnim.Duration       = TimeSpan.FromSeconds(2);
                    circleAnim.RepeatBehavior = RepeatBehavior.Forever;
                    Circle1.BeginAnimation(System.Windows.Shapes.Ellipse.WidthProperty, circleAnim);
                    Circle1.BeginAnimation(System.Windows.Shapes.Ellipse.HeightProperty, circleAnim);
                });

                Thread.Sleep(670);

                Dispatcher.Invoke(() =>
                {
                    var opacityAnim            = new DoubleAnimation();
                    opacityAnim.From           = 0;
                    opacityAnim.To             = 1;
                    opacityAnim.Duration       = TimeSpan.FromSeconds(2);
                    opacityAnim.RepeatBehavior = RepeatBehavior.Forever;
                    Circle2.BeginAnimation(System.Windows.Shapes.Ellipse.OpacityProperty, opacityAnim);

                    var circleAnim            = new DoubleAnimation();
                    circleAnim.From           = 80;
                    circleAnim.To             = 20;
                    circleAnim.Duration       = TimeSpan.FromSeconds(2);
                    circleAnim.RepeatBehavior = RepeatBehavior.Forever;
                    Circle2.BeginAnimation(System.Windows.Shapes.Ellipse.WidthProperty, circleAnim);
                    Circle2.BeginAnimation(System.Windows.Shapes.Ellipse.HeightProperty, circleAnim);
                });

                Thread.Sleep(670);

                Dispatcher.Invoke(() =>
                {
                    var opacityAnim            = new DoubleAnimation();
                    opacityAnim.From           = 0;
                    opacityAnim.To             = 1;
                    opacityAnim.Duration       = TimeSpan.FromSeconds(2);
                    opacityAnim.RepeatBehavior = RepeatBehavior.Forever;
                    Circle3.BeginAnimation(System.Windows.Shapes.Ellipse.OpacityProperty, opacityAnim);

                    var circleAnim            = new DoubleAnimation();
                    circleAnim.From           = 80;
                    circleAnim.To             = 20;
                    circleAnim.Duration       = TimeSpan.FromSeconds(2);
                    circleAnim.RepeatBehavior = RepeatBehavior.Forever;
                    Circle3.BeginAnimation(System.Windows.Shapes.Ellipse.WidthProperty, circleAnim);
                    Circle3.BeginAnimation(System.Windows.Shapes.Ellipse.HeightProperty, circleAnim);
                });

                /*
                 * while (true)
                 * {
                 *  try
                 *  {
                 *      Dispatcher.Invoke(() => Circle1.Width -= 1);
                 *      Dispatcher.Invoke(() => Circle1.Height -= 1);
                 *      Dispatcher.Invoke(() => Circle1.Opacity += 0.017);
                 *      if (Dispatcher.Invoke(() => Circle1.Opacity >= 1))
                 *      {
                 *          Dispatcher.Invoke(() => Circle1.Width = 79);
                 *          Dispatcher.Invoke(() => Circle1.Height = 79);
                 *          Dispatcher.Invoke(() => Circle1.Opacity = 0);
                 *      }
                 *      Dispatcher.Invoke(() => Circle2.Width -= 1);
                 *      Dispatcher.Invoke(() => Circle2.Height -= 1);
                 *      Dispatcher.Invoke(() => Circle2.Opacity += 0.017);
                 *      if (Dispatcher.Invoke(() => Circle2.Opacity >= 1))
                 *      {
                 *          Dispatcher.Invoke(() => Circle2.Width = 79);
                 *          Dispatcher.Invoke(() => Circle2.Height = 79);
                 *          Dispatcher.Invoke(() => Circle2.Opacity = 0);
                 *      }
                 *      Dispatcher.Invoke(() => Circle3.Width -= 1);
                 *      Dispatcher.Invoke(() => Circle3.Height -= 1);
                 *      Dispatcher.Invoke(() => Circle3.Opacity += 0.017);
                 *      if (Dispatcher.Invoke(() => Circle3.Opacity >= 1))
                 *      {
                 *          Dispatcher.Invoke(() => Circle3.Width = 79);
                 *          Dispatcher.Invoke(() => Circle3.Height = 79);
                 *          Dispatcher.Invoke(() => Circle3.Opacity = 0);
                 *      }
                 *
                 *      Thread.Sleep(36);
                 *  }
                 *  catch
                 *  {
                 *      break;
                 *  }
                 * }*/
            });
        }
 private void AreEqual_ClosestPoints(Segment2 segment, Circle2 circle, Vector2 expected)
 {
     AreEqual_ClosestPoints(segment, circle, expected, expected, expected);
 }
Exemplo n.º 18
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS()
            {
                Header = ass_in.Header, Events = new List <ASSEvent>()
            };

            double[] light_time_offset = { 3.5, 3.8, 5.9, 4.9, 3.5 };
            double   light_spd         = 400;

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                bool isJp = iEv <= 4;
                this.MaskStyle = isJp ?
                                 "Style: Default,DFGMaruGothic-Md,38,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,1,0,0,5,0,0,0,128" :
                                 "Style: Default,方正准圆_GBK,40,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,1,0,0,5,0,0,0,1";
                this.FontHeight = isJp ? 38 : 40;
                int jEv = isJp ? iEv : iEv - 5;
                //if (!isJp) continue;
                //if (jEv > 0) continue;
                ASSEvent        ev         = ass_in.Events[iEv];
                List <KElement> kelems     = ev.SplitK(true);
                int             totalWidth = GetTotalWidth(ev);
                int             x0         = (PlayResX - MarginRight - totalWidth - MarginLeft) / 2 + MarginLeft;
                int             y0         = (isJp) ? (PlayResY - MarginBottom - FontHeight) : MarginTop;
                int             kSum       = 0;
                int             x0_start   = x0;
                int             lastx0     = 0;
                string          outlines   = "";
                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    double sr = (double)iK / (double)(kelems.Count - 1);
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    KElement ke     = kelems[iK];
                    Size     sz     = GetSize(ke.KText);
                    double   kStart = ev.Start + kSum * 0.01;
                    double   kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    int x     = x0 + this.FontSpace + sz.Width / 2;
                    int y     = y0 + FontHeight / 2;
                    int x_an7 = x0;
                    int y_an7 = y0;
                    x0    += this.FontSpace + sz.Width;
                    lastx0 = x0;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }
                    StringMask mask    = GetMask(ke.KText, x, y);
                    string     evStyle = isJp ? "ed_jp" : "ed_cn";

                    if (ke.KText == "?")
                    {
                        x += 15;
                    }

                    string outlineFontname = isJp ? "DFGMaruGothic-Md" : "方正准圆_GBK";
                    int    outlineEncoding = isJp ? 128 : 1;
                    int    xoffset         = isJp ? 0 : -1;
                    if (isJp && ke.KText[0] == '中')
                    {
                        xoffset = -2;
                    }
                    string outlineString = GetOutline(x - sz.Width / 2 + xoffset, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, FontHeight, 0, 262);
                    outlines += outlineString;

                    double t0 = ev.Start - 0.5 + iK * 0.1;
                    double t1 = t0 + 0.5;
                    double t2 = kStart;
                    double t3 = t2 + 0.8;
                    double t4 = ev.End - 0.5 + iK * 0.1;
                    double t5 = t4 + 0.5;

                    string main_col  = "9699E3";
                    string main_col2 = main_col;
                    if (jEv == 0 || jEv == 1)
                    {
                        main_col  = Common.scaleColor("93CB4B", "E4B281", (sr - 0.2) / 0.8);
                        main_col2 = Common.scaleColor("E4B281", "93CB4B", (sr - 0.2) / 0.8);
                    }
                    if (jEv == 3 || jEv == 4)
                    {
                        main_col  = Common.scaleColor("9699E3", "9CCFD5", "B0CE6E", (sr - 0.2) / 0.8);
                        main_col2 = Common.scaleColor("B0CE6E", "9CCFD5", "9699E3", (sr - 0.2) / 0.8);
                    }

                    if (!isJp)
                    {
                        ass_out.AppendEvent(50, evStyle, t0, t5,
                                            pos(x, y) + a(1, "00") + c(1, main_col) + shad(1) + a(4, "33") + c(4, "FFFFFF") + a(3, "66") +
                                            fad(0.5, 0.5) + blur(2) + bord(2) +
                                            ke.KText);
                        continue;
                    }

                    double midt = (x0 - sz.Width - (x0_start - 20)) / light_spd + light_time_offset[iEv] + ev.Start - 0.6;
                    ass_out.AppendEvent(50, evStyle, t0, midt + 0.5,
                                        pos(x, y) + a(1, "00") + c(1, main_col) + shad(1) + a(4, "33") + c(4, "FFFFFF") + a(3, "66") +
                                        fad(0.5, 0.5) + blur(2) + bord(2) +
                                        ke.KText);
                    ass_out.AppendEvent(50, evStyle, midt, t5,
                                        pos(x, y) + a(1, "00") + c(1, main_col2) + shad(1) + a(4, "33") + c(4, "FFFFFF") + a(3, "66") +
                                        fad(0.5, 0.5) + blur(2) + bord(2) +
                                        ke.KText);

                    ass_out.AppendEvent(55, evStyle, t2, t3,
                                        pos(x, y) + a(1, "55") + c(1, "FFFFFF") + a(3, "55") + c(3, "FFFFFF") + blur(3) + bord(3) + fad(0, t3 - t2) +
                                        ke.KText);

                    if (iEv <= 2)
                    {
                        int tmpyy = Common.RandomInt(rnd, 0, 1);
                        for (int i = 0; i < Common.RandomInt(rnd, 1, 2); i++)
                        {
                            double ptt0 = t2 + Common.RandomDouble(rnd, 0, 0.1);
                            double ptx0 = Common.RandomDouble(rnd, x - sz.Width / 2, x + sz.Width / 2);
                            double yd   = Common.RandomDouble(rnd, 35, 50);
                            double pty0 = 0;
                            double pty1 = 0;
                            if ((tmpyy + i) % 2 == 0)
                            {
                                pty0 = y - yd;
                                pty1 = y + yd;
                            }
                            else
                            {
                                pty0 = y + yd;
                                pty1 = y - yd;
                            }
                            double spd   = 40;
                            string ptcol = (ptt0 < midt + 0.5) ? main_col : main_col2;
                            double ptt1  = ptt0 + Math.Abs(pty0 - pty1) / spd;
                            ass_out.AppendEvent(30, "pt", ptt0, ptt1,
                                                an(5) + move(ptx0, pty0, ptx0, pty1) + a(1, "00") + c(1, ptcol) +
                                                blur(5) + fs(30) + t(fsc(0, 0).t()) +
                                                '●');
                            ass_out.AppendEvent(31, "pt", ptt0, ptt1,
                                                an(5) + move(ptx0, pty0, ptx0, pty1) + a(1, "00") + c(1, Common.scaleColor("FFFFFF", ptcol, 0.7)) +
                                                blur(2.2) + fs(25) + t(fsc(0, 0).t()) +
                                                '●');
                            ass_out.AppendEvent(32, "pt", ptt0, ptt1,
                                                an(5) + move(ptx0, pty0, ptx0, pty1) + a(1, "00") +
                                                blur(1.8) + fs(12) + t(fsc(0, 0).t()) +
                                                '●');
                        }
                    }

                    if (iEv >= 3)
                    {
                        {
                            double           ptt0   = t2 - 0.4;
                            double           ptt1   = t2;
                            string           ptcol  = (ptt0 < midt + 0.5) ? main_col : main_col2;
                            double           theta1 = Common.RandomDouble(rnd, 0, Math.PI);
                            List <BaseCurve> curves = new List <BaseCurve>();
                            double           ra     = 30;
                            double           rb     = 7;
                            Circle2          cl     = new Circle2 {
                                NormTheta = false, X0 = x, Y0 = y, A = ra, B = rb, MinT = -Math.PI * 0.5, MaxT = Math.PI * 0.5, Theta = theta1, dTheta = 0
                            };
                            CompositeCurve cc = new CompositeCurve {
                                MinT = ptt0, MaxT = ptt1
                            };
                            cc.AddCurve(cc.MinT, cc.MaxT, cl);
                            curves.Add(cc);
                            cl = new Circle2 {
                                NormTheta = false, X0 = x, Y0 = y, A = ra, B = rb, MinT = -Math.PI * 0.5, MaxT = -Math.PI * 1.5, Theta = theta1, dTheta = 0
                            };
                            cc = new CompositeCurve {
                                MinT = ptt0, MaxT = ptt1
                            };
                            cc.AddCurve(cc.MinT, cc.MaxT, cl);
                            curves.Add(cc);
                            foreach (BaseCurve curve in curves)
                            {
                                foreach (ASSPointF pt in curve.GetPath_Dis(1, 1.1))
                                {
                                    ass_out.AppendEvent((pt.Theta >= 0 || pt.Theta <= -Math.PI) ? 100 : 0, "pt", pt.T, pt.T + 0.3,
                                                        an(5) + pos(pt.X, pt.Y) + a(1, "00") + c(1, "FFFFFF") + a(3, "77") + c(3, ptcol) +
                                                        bord(3) + blur(3) + fs(8) + t(fsc(0, 0).t() + bord(0).t()) +
                                                        '●');
                                }
                                foreach (ASSPointF pt in curve.GetPath_DT(0.03))
                                {
                                    ass_out.AppendEvent((pt.Theta >= 0 || pt.Theta <= -Math.PI) ? 101 : 1, "pt", pt.T, pt.T + 0.03,
                                                        an(5) + pos(pt.X, pt.Y) + a(1, "00") + c(1, "FFFFFF") +
                                                        blur(5) + fs(12) +
                                                        '●');
                                }
                            }
                            ass_out.AppendEvent(100, evStyle, ptt1, ptt1 + 0.5,
                                                pos(x, y) + a(1, "00") + a(3, "00") + bord(3) + blur(3) + fad(0, 0.3) +
                                                ke.KText);
                        }

                        for (int i = 0; i < 40; i++)
                        {
                            double ptt0  = t2 + Common.RandomDouble(rnd, 0, 0.1);
                            double ptx0  = x;
                            double pty0  = y;
                            double sc    = Common.RandomDouble(rnd, 2, 3);
                            double ptx1  = Common.RandomDouble(rnd, x - sz.Width * sc, x + sz.Width * sc);
                            double pty1  = Common.RandomDouble(rnd, y - sz.Width * sc, y + sz.Width * sc);
                            double spd   = 40;
                            string ptcol = (ptt0 < midt + 0.5) ? main_col : main_col2;
                            double ptt1  = ptt0 + Common.GetDistance(ptx0, pty0, ptx1, pty1) / spd;
                            ass_out.AppendEvent(30, "pt", ptt0, ptt1,
                                                an(5) + move(ptx0, pty0, ptx1, pty1) + a(1, "00") + c(1, ptcol) +
                                                blur(8) + fs(30) + t(fsc(0, 0).t()) +
                                                '●');
                            ass_out.AppendEvent(31, "pt", ptt0, ptt1,
                                                an(5) + move(ptx0, pty0, ptx1, pty1) + a(1, "00") + c(1, Common.scaleColor("FFFFFF", ptcol, 0.7)) +
                                                blur(2.2) + fs(25) + t(fsc(0, 0).t()) +
                                                '●');
                            ass_out.AppendEvent(32, "pt", ptt0, ptt1,
                                                an(5) + move(ptx0, pty0, ptx1, pty1) + a(1, "00") +
                                                blur(1.8) + fs(12) + t(fsc(0, 0).t()) +
                                                '●');
                        }
                    }
                }

                if (isJp)
                {
                    double ptt0 = ev.Start + light_time_offset[iEv] - 0.7;
                    double ptx0 = x0_start - 20;
                    double ptx1 = lastx0 + 20;
                    double ptt1 = ptt0 + (ptx1 - ptx0) / light_spd;
                    ass_out.AppendEvent(100, "pt", ptt0, ptt1,
                                        clip(4, outlines) + move(ptx0, y0 + FontHeight / 2, ptx1, y0 + FontHeight / 2) +
                                        a(1, "55") + frz(-45) + blur(8) + fscx(200) +
                                        p(1) + "m 10 -50 l 10 50 -10 50 -10 -50");
                }
            }

            Console.WriteLine(ass_out.Events.Count);
            ass_out.SaveFile(this.OutFileName);
        }
 private void AreEqual_ClosestPoints(Segment2 segment, Circle2 circle, Vector2 expectedSegmentA, Vector2 expectedSegmentB,
                                     Vector2 expectedCircle)
 {
     AreEqual_ClosestPoints(segment, circle, expectedSegmentA, expectedSegmentB, expectedCircle, expectedCircle);
 }
Exemplo n.º 20
0
 private void ClosestPoints_OnePoint(Line2 line, Circle2 circle, Vector2 expected)
 {
     AreEqual_ClosestPointsSwap(line, circle, expected, expected);
 }
Exemplo n.º 21
0
        private void SendButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            FileInfo file = null;

            if (File.Exists(FilePath))
            {
                file = new FileInfo(FilePath);
            }

            if (file != null && file.Length > 0)
            {
                Task.Run(() =>
                {
                    Dispatcher.Invoke(() => SetupPage.IsEnabled   = false);
                    Dispatcher.Invoke(() => SenderPage.IsEnabled  = true);
                    Dispatcher.Invoke(() => CloseButton.IsEnabled = true);
                    for (int i = 0; i < 10; i++)
                    {
                        Dispatcher.Invoke(() => SetupPage.Opacity   -= 0.1);
                        Dispatcher.Invoke(() => CloseButton.Opacity += 0.1);
                        Dispatcher.Invoke(() => MainBorder.Margin    = new Thickness(MainBorder.Margin.Left, MainBorder.Margin.Top, MainBorder.Margin.Right, MainBorder.Margin.Bottom + 12.5));
                        Dispatcher.Invoke(() => MainGrid.Margin      = new Thickness(MainGrid.Margin.Left, MainGrid.Margin.Top + 12.5, MainGrid.Margin.Right, MainGrid.Margin.Bottom));
                        Thread.Sleep(17);
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        Dispatcher.Invoke(() => SenderPage.Opacity += 0.1);
                        Thread.Sleep(17);
                    }

                    Connection.SendMessage(new MessageClass(Connection.ID, UserID, Commands.RFileSend, ID, System.IO.Path.GetFileName(FilePath)));

                    Dispatcher.Invoke(() =>
                    {
                        var opacityAnim            = new DoubleAnimation();
                        opacityAnim.From           = 1;
                        opacityAnim.To             = 0;
                        opacityAnim.Duration       = TimeSpan.FromSeconds(2);
                        opacityAnim.RepeatBehavior = RepeatBehavior.Forever;
                        Circle1.BeginAnimation(Ellipse.OpacityProperty, opacityAnim);

                        var circleAnim            = new DoubleAnimation();
                        circleAnim.From           = 20;
                        circleAnim.To             = 80;
                        circleAnim.Duration       = TimeSpan.FromSeconds(2);
                        circleAnim.RepeatBehavior = RepeatBehavior.Forever;
                        Circle1.BeginAnimation(Ellipse.WidthProperty, circleAnim);
                        Circle1.BeginAnimation(Ellipse.HeightProperty, circleAnim);
                    });

                    Thread.Sleep(670);

                    Dispatcher.Invoke(() =>
                    {
                        var opacityAnim            = new DoubleAnimation();
                        opacityAnim.From           = 1;
                        opacityAnim.To             = 0;
                        opacityAnim.Duration       = TimeSpan.FromSeconds(2);
                        opacityAnim.RepeatBehavior = RepeatBehavior.Forever;
                        Circle2.BeginAnimation(Ellipse.OpacityProperty, opacityAnim);

                        var circleAnim            = new DoubleAnimation();
                        circleAnim.From           = 20;
                        circleAnim.To             = 80;
                        circleAnim.Duration       = TimeSpan.FromSeconds(2);
                        circleAnim.RepeatBehavior = RepeatBehavior.Forever;
                        Circle2.BeginAnimation(Ellipse.WidthProperty, circleAnim);
                        Circle2.BeginAnimation(Ellipse.HeightProperty, circleAnim);
                    });

                    Thread.Sleep(670);

                    Dispatcher.Invoke(() =>
                    {
                        var opacityAnim            = new DoubleAnimation();
                        opacityAnim.From           = 1;
                        opacityAnim.To             = 0;
                        opacityAnim.Duration       = TimeSpan.FromSeconds(2);
                        opacityAnim.RepeatBehavior = RepeatBehavior.Forever;
                        Circle3.BeginAnimation(Ellipse.OpacityProperty, opacityAnim);

                        var circleAnim            = new DoubleAnimation();
                        circleAnim.From           = 20;
                        circleAnim.To             = 80;
                        circleAnim.Duration       = TimeSpan.FromSeconds(2);
                        circleAnim.RepeatBehavior = RepeatBehavior.Forever;
                        Circle3.BeginAnimation(Ellipse.WidthProperty, circleAnim);
                        Circle3.BeginAnimation(Ellipse.HeightProperty, circleAnim);
                    });

                    /*
                     * while (true)
                     * {
                     *  try
                     *  {
                     *      Dispatcher.Invoke(() => Circle1.Width += 1);
                     *      Dispatcher.Invoke(() => Circle1.Height += 1);
                     *      Dispatcher.Invoke(() => Circle1.Opacity -= 0.017);
                     *      if (Dispatcher.Invoke(() => Circle1.Opacity <= 0))
                     *      {
                     *          Dispatcher.Invoke(() => Circle1.Width = 20);
                     *          Dispatcher.Invoke(() => Circle1.Height = 20);
                     *          Dispatcher.Invoke(() => Circle1.Opacity = 1);
                     *      }
                     *      Dispatcher.Invoke(() => Circle2.Width += 1);
                     *      Dispatcher.Invoke(() => Circle2.Height += 1);
                     *      Dispatcher.Invoke(() => Circle2.Opacity -= 0.017);
                     *      if (Dispatcher.Invoke(() => Circle2.Opacity <= 0))
                     *      {
                     *          Dispatcher.Invoke(() => Circle2.Width = 20);
                     *          Dispatcher.Invoke(() => Circle2.Height = 20);
                     *          Dispatcher.Invoke(() => Circle2.Opacity = 1);
                     *      }
                     *      Dispatcher.Invoke(() => Circle3.Width += 1);
                     *      Dispatcher.Invoke(() => Circle3.Height += 1);
                     *      Dispatcher.Invoke(() => Circle3.Opacity -= 0.017);
                     *      if (Dispatcher.Invoke(() => Circle3.Opacity <= 0))
                     *      {
                     *          Dispatcher.Invoke(() => Circle3.Width = 20);
                     *          Dispatcher.Invoke(() => Circle3.Height = 20);
                     *          Dispatcher.Invoke(() => Circle3.Opacity = 1);
                     *      }
                     *
                     *      Thread.Sleep(36);
                     *  }
                     *  catch
                     *  {
                     *      break;
                     *  }
                     * }*/
                }
                         );
            }
            else
            {
                Task.Run(() =>
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Dispatcher.Invoke(() => PathLabel.Opacity -= 0.1);
                        Thread.Sleep(17);
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        Dispatcher.Invoke(() => ErrorLabel.Opacity += 0.1);
                        Thread.Sleep(17);
                    }
                    Thread.Sleep(500);
                    for (int i = 0; i < 10; i++)
                    {
                        Dispatcher.Invoke(() => ErrorLabel.Opacity -= 0.1);
                        Thread.Sleep(17);
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        Dispatcher.Invoke(() => PathLabel.Opacity += 0.1);
                        Thread.Sleep(17);
                    }
                }
                         );
            }
        }
        static void main(string[] args)
        {
            /*
             * Inheritance -
             * allows us to define a class based on another class. This makes creating and maintaining an application easy.
             * The class whose properties are inherited by another class is called the Base class. The class which inherits the properties is called the Derived class.
             * for example, Base class Animal can be used to derive Cat and Dog classes.
             * The derived class inherits all the features from the base class and can have its own additional features
             * example line(12)
             */
            Dog d = new Dog();

            Console.WriteLine(d.Legs); //output is 4
            d.Bark();                  //output Woof
            //A base clase can have multiple derived classes.
            //for example, a Cat class can inherit from Animal
            //Inheritance allows the derived class to reuse the code in the base class without having to rewrite it. Also the derive class can be customized by
            //adding more members. In this manner, the derived class extends the functionality of the base class.

            /*A derived class inherits all the members of the base class, including its methods
             * example line(30)
             *
             */
            Student s = new Student();

            s.Speak();          // output Hi there
                                //C# does not support multiple inheritance, so we cannot inherit from multiple classes, however, we can use interfaces to implement multiple inheritance



            /*
             * Protected -
             * This access modifier is very similar to private access modifier with one difference.
             * A Protected access modifier can be accessed in the derived classes. So a protected member is accessible only from derived classes
             * example line(43)
             */
            Student2 s2 = new Student2("Iykeman");

            s2.Speak();

            /*Sealed -
             * A class can prevent other classes from inheritig it, or any of its members by using the sealed modifier. example
             * sealed class Animal {
             *   //some code
             * }
             * class Dog : Animal {  }   // Error
             * The sealed keyword provides a level of protection to your class so that other classes cannot inherit from it
             */


            /*Derived Class Constructor and Destructor
             * Contructors are called when objects of a class are created. With inheritance, the base class constructor and destructor are not inherited, so we should
             * define constructors for the derived classes.
             * However, he base class constructor and destructor are being invoked automatically when an object of the derived class is created or derleted
             * consider example line(61)
             * Note that the base class constructor is called first and the derived class constructor is called next. When the object is destroyed, the derived class
             * destructor is invoked and then the base class destructor is invoked.
             * we can think of this as the following: the derived class needs its base class in order to work which is why the base class constructor is called first
             */
            Cow c = new Cow();


            /* Polymorphism -
             * this word means having many forms, it occurs when there is a hierarchy of classes and they are related through inheritance from a common base class.
             * Polymorphism means that a call to a member method will cause a different implementation to be executed depending on the type of object that invokes the method.
             * This simplt means that a single method can have a number of different implementations.
             * -Consider having a program that alllows users to draw different shapes.Each shape is drawn differently and you do not know which shape the user will choose,
             * Here, polymorphism can be leveraged to invoke the appropriate Draw method of any derived class. Such methods must be declared using the virtual keyword in the base class
             * example below and line(85)
             * class shape {
             *      public virtual void Draw() {
             *          Console.WriteLine("Base Draw");
             *      }
             * }
             * The virtual keyword allows methods to be overridden in derived classes.
             * Virtual methods enable us to work with groups of related objects in a uniform way.
             *
             * we can derive different shape classes that define their own Draw methods using the override keyword. example line (93).
             * The virtual Draw method in the Shape base class can be overridden in the derived classes. In this case, Circle and Rectangle have their own Draw methods.
             * we can create separate Shape objects for each derived type and then call their Draw methods
             */
            Shape cc = new Circle();

            cc.Draw();   // output "Circle Draw"
            Shape rt = new Rectangle();

            rt.Draw();  //output "Rectangle Draw"

            /*Polymorphism is useful in many cases, For example, we could create a game where we would have different player types with each player
             * having a separate behaviour for the Attack method.
             * In this case, Attack would be a virtual method of the base class Player and each derived class would override it.
             */


            /*Abstract Classes -
             * In situation where it is not meaningful for the virtual method(polymorphism) to have a separate definition in base class,
             * we defined this method with the abstract keyword and specify that the derived classes must define their method on their own.
             * we cannot create objects of a class containing an abstract method, which is why the class itself should be abstract
             * lets use abstract method in the shape class as in polymorphism case, example line (113)
             * The draw method on line 133 is abstract and thus has no body, we do not even need a curly brackets, just end the statement with a semicolon.
             * The Shape class itself must be declared abstract because it contains an abstract method. Abstract method declarations are only permitted in abstract classess
             * Members marked as abstract or included in an abstract class must be implemented by classes that derive from the abstract class.
             * An abstract class can have multiple abstract members
             * Ab abstract class is intended to be a base class of other classess. It acts like a template for its derived classes.
             * we can now define other classes and define their own Draw() method. example line(117)
             */
            Shape2 cc2 = new Circle2();

            cc.Draw();  // output "Circle Draw"
            Shape2 rt2 = new Rectangle2();

            rt.Draw(); //output "Rectangle Draw"

            /*Abstract class have the following features
             * An abstract class cannot be instantiated
             * An abstract class may contain abstract methods and accessors
             * A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors
             * Note that it is not possible to modify an abstract class with the sealed modifier because the two modifiers have opposite meanings.
             * The sealed modifier prevents a class from being inherited and the abstract modifier requires a class to be inherited
             */



            /* Interfaces -
             * An interface is a completely abstract class, which contains only abstract members. It is declared using the interface keyword,
             * Example -
             * public interface IShape
             * {
             *     void Draw();
             * }
             * All members of the interface are by default abstract, so no need to use the abstract keyword.
             * Also all members of an interface are always public, an no access modifiers can be applied to them.
             * It is common to use the capital letter I as the starting letter for an interface name.
             * Interfaces can contain properties, methods, etc but cannot contain fields (variables).
             *
             * When a class implements an interface, it must also implement, or define, all of its methods.
             * The term implementing an interface is used(opposed to the term "inheriting from") to describe the process of creating a class based on an
             * interface. The interface simply describes what a class should do. The class implementing the interface must define how to accomplish the behaviours.
             * The syntax to implement an interface is the same as that to derive a class.
             * example line (134)
             */
            IShape ca = new CircleA();

            ca.Draw();  //Output "Circle Draw"

            /*Note that the override keyword is not needed when you implement an interface
             * Why use interfaces rather than abstract classes?
             * A class can inherit from just one base class, but it can implement multiple interfaces!
             * Therefore, by using interfaces we can include behaviour from multiple sources in a class.
             * To implement multiple interfaces, use a comma separated list of interfaces when creating the class: Class A : IShape, IAnimal, etc
             */



            /*
             * Nested Classes
             * C# supports nested classes, a nested class is a class that is a member of another class. example below & line (148)
             * class Car {
             *      string name;
             *      public Car(string nm) {
             *          name = nm;
             *          Motor m = new Motor();
             *      }
             *      public class Motor {
             *          // some code
             *      }
             * }
             *
             * The Motor class is nested in the Car class and can be used similar to other members of the class.
             * A nested class acts as a member of the class, so it can have the same access modifiers as other members(public, private, protected).
             *
             * Just as in real life, objects can contain other objects. For example, a car, which has its own attributes(color, brand, etc) contains
             * a motor, which as a separate object, has its own attributes(volume, horsepower, etc).
             * Here, the Car class can have a nested Motor class as one of its members
             */



            /*Namespaces
             * when we create a blank project, it has the following structure:
             *
             * using System;
             * using System.Collections.Generic;
             * using System.Linq;
             * using.System.Text;
             * using System.Threading.Tasks;
             *
             * namespace SoloLearn {
             *    class Program {
             *        static void Main(string[] args) {
             *        }
             *    }
             * }
             *
             * Note that our whole program is inside a namespace. So, what are namespaces?
             * Namespaces declare a scope that contains a set of related objects. You can use a namespace to organize code elements.
             * You can define your own namespaces and use them in your program. The using keyword states that the rpogram is using a given namespace.
             * for example, we are using the System namespace in our programs, which is where the class Console is defined. Without the using
             * statement, we would have to specify the namespace whereever it is used like below
             * System.Console.WriteLine("Hello world");
             *
             * The .NET framework uses namespaces to organize its many classes. System is one example of a .NET framework namespaces. Declaring your
             * own namespaces can help you group your class and method names in larger programming projects
             *
             */
        }
Exemplo n.º 23
0
        public override void Run()
        {
            ASS ass_in  = ASS.FromFile(this.InFileName);
            ASS ass_out = new ASS()
            {
                Header = ass_in.Header, Events = new List <ASSEvent>()
            };

            for (int iEv = 0; iEv < ass_in.Events.Count; iEv++)
            {
                bool isJp = iEv <= 9;
                //if (iEv != 0) continue;
                //if (iEv != 9) continue;
                //if (!isJp) continue;
                //if (iEv != 5 && iEv != 6) continue;
                //if (iEv != 19 && iEv != 9) continue;
                //if (iEv < 20) continue;
                ASSEvent        ev     = ass_in.Events[iEv];
                List <KElement> kelems = ev.SplitK(!isJp);
                int             x0     = MarginLeft;
                int             y0     = (isJp || iEv >= 20) ? (PlayResY - MarginBottom - FontHeight) : MarginTop;
                int             kSum   = 0;

                /// 两句英文
                if (iEv >= 20)
                {
                    y0            -= 45;
                    x0            += 4;
                    this.MaskStyle = "Style: Default,DFMincho-UB,30,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128";
                    for (int iK = 0; iK < kelems.Count; iK++)
                    {
                        Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                        KElement ke     = kelems[iK];
                        Size     sz     = GetSize(ke.KText);
                        double   kStart = ev.Start + kSum * 0.01;
                        double   kEnd   = kStart + ke.KValue * 0.01;
                        kSum += ke.KValue;
                        int        x     = x0 + this.FontSpace + sz.Width / 2;
                        int        y     = y0 + FontHeight / 2;
                        int        x_an7 = x0 + 2;
                        int        y_an7 = y0;
                        StringMask mask  = GetMask(ke.KText, x, y);
                        x0 += this.FontSpace + sz.Width;
                        if (ke.KText.Trim().Length == 0)
                        {
                            x0 -= sz.Width / 2;
                        }
                        if (ke.KText.Trim().Length == 0)
                        {
                            continue;
                        }

                        double t0 = ev.Start - 0.5 + iK * 0.07;
                        double t1 = t0 + 0.35;
                        double t2 = kStart;
                        double t3 = kEnd;
                        double t4 = ev.End - 0.5 + iK * 0.07;
                        double t5 = t4 + 0.35;

                        Func <double, double> fPosX = h => (x + (h - ev.Start) * 20);

                        ass_out.AppendEvent(50, "en", t0, t4,
                                            move(fPosX(t0), y, fPosX(t4), y) + a(1, "00") +
                                            fsc(0, 0) + fad(0.1, 0) +
                                            t(0, 0.28, fsc(140, 140).t()) + t(0.28, 0.35, fsc(100, 100).t()) +
                                            ke.KText);
                        ass_out.AppendEvent(30, "en", t0, t4,
                                            fsc(0, 0) + fad(0.1, 0) +
                                            t(0, 0.28, fsc(140, 140).t()) + t(0.28, 0.35, fsc(100, 100).t()) +
                                            move(fPosX(t0), y, fPosX(t4), y) + a(3, "44") + bord(3) + blur(3) + c(3, "6888FF") +
                                            ke.KText);
                        ass_out.AppendEvent(50, "en", t4, t5,
                                            move(fPosX(t4), y, fPosX(t5), y) + a(1, "00") +
                                            fad(0, 0.1) +
                                            t(0, 0.07, fsc(140, 140).t()) + t(0.07, 0.35, fsc(0, 0).t()) +
                                            ke.KText);
                        ass_out.AppendEvent(30, "en", t4, t5,
                                            fad(0, 0.1) +
                                            t(0, 0.07, fsc(140, 140).t()) + t(0.07, 0.35, fsc(0, 0).t()) +
                                            move(fPosX(t4), y, fPosX(t5), y) + a(3, "44") + bord(3) + blur(3) + c(3, "6888FF") +
                                            ke.KText);

                        string ptcol = "FF68AD";
                        for (int i = 0; i < 50; i++)
                        {
                            double ptx0 = Common.RandomDouble_Gauss(rnd, x - 2, x + 2);
                            double pty0 = Common.RandomDouble_Gauss(rnd, y - 2, y + 2);
                            double ptag = Common.RandomDouble(rnd, 0, Math.PI * 2);
                            double ptr  = Common.RandomDouble_Gauss(rnd, 50, 75);
                            double ptx1 = ptx0 + Math.Cos(ptag) * ptr;
                            double pty1 = pty0 + Math.Sin(ptag) * ptr;
                            double ptt0 = Common.RandomDouble(rnd, t0, t0 + 0.2);
                            double ptt1 = ptt0 + Common.RandomDouble(rnd, 2, 3);

                            string tstr = "";
                            for (double tmpt = 0; tmpt <= ptt1 - ptt0; tmpt += 0.40)
                            {
                                tstr += t(tmpt, tmpt + 0.20, a(1, "FF").t() + a(3, "FF").t()) + t(tmpt + 0.20, tmpt + 0.40, a(1, "44").t() + a(3, "88").t());
                            }
                            ass_out.AppendEvent(0, "pt", ptt0, ptt1,
                                                move(ptx0, pty0, ptx1, pty1) + a(1, "44") + a(3, "88") + c(3, Common.RandomBool(rnd, 0.5) ? ptcol : "FFFFFF") +
                                                bord(1.5) + blur(1.5) + fsc(150, 150) + tstr +
                                                p(1) + "m 0 0 l 1 0 1 1 0 1");
                        }
                    }
                    continue;
                }

                for (int iK = 0; iK < kelems.Count; iK++)
                {
                    Console.WriteLine("{0} / {1} : {2} / {3}", iEv + 1, ass_in.Events.Count, iK + 1, kelems.Count);
                    if (iEv == 19)
                    {
                        isJp = iK <= 10;
                    }
                    this.MaskStyle = isJp ?
                                     "Style: Default,DFMincho-UB,38,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,0,0,0,0,100,100,0,0,0,0,0,5,0,0,0,128" :
                                     "Style: Default,汉仪粗宋繁,38,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&HFFFFFFFF,1,0,0,0,100,100,0,0,0,0,0,5,0,0,0,134";
                    string evStyle         = isJp ? "" : "cn";
                    string outlineFontname = isJp ? "DFMincho-UB" : "汉仪粗宋繁";
                    int    outlineEncoding = isJp ? 128 : 134;
                    isJp = iEv <= 9;
                    KElement ke = kelems[iK];
                    Size     sz = GetSize(ke.KText);
                    if (ke.KText[0] == 'く')
                    {
                        x0 += 2;
                    }
                    double kStart = ev.Start + kSum * 0.01;
                    double kEnd   = kStart + ke.KValue * 0.01;
                    kSum += ke.KValue;
                    int        x     = x0 + this.FontSpace + sz.Width / 2;
                    int        y     = y0 + FontHeight / 2;
                    int        x_an7 = x0 + 2;
                    int        y_an7 = y0;
                    StringMask mask  = GetMask(ke.KText, x, y);
                    x0 += this.FontSpace + sz.Width;
                    if (ke.KText.Trim().Length == 0)
                    {
                        continue;
                    }
                    string outlineString = GetOutline(x - FontHeight / 2, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, 38, 0, 262);

                    if (iEv == 9 && iK == 0)
                    {
                        outlineString = GetOutline(x - FontHeight / 2 + 10, y - FontHeight / 2, 'I', outlineFontname, outlineEncoding, 38, 0, 262);
                    }
                    if (iEv == 9 && iK == 2)
                    {
                        outlineString =
                            GetOutline(x - FontHeight / 2 - 29, y - FontHeight / 2, 'w', outlineFontname, outlineEncoding, 38, 0, 262) +
                            GetOutline(x - FontHeight / 2 - 29 + 30 - 12 + 1, y - FontHeight / 2, 'a', outlineFontname, outlineEncoding, 38, 0, 262) +
                            GetOutline(x - FontHeight / 2 - 29 + 60 - 20 - 2, y - FontHeight / 2, 'n', outlineFontname, outlineEncoding, 38, 0, 262) +
                            GetOutline(x - FontHeight / 2 - 29 + 90 - 34, y - FontHeight / 2, 'n', outlineFontname, outlineEncoding, 38, 0, 262) +
                            GetOutline(x - FontHeight / 2 - 29 + 120 - 44, y - FontHeight / 2, 'a', outlineFontname, outlineEncoding, 38, 0, 262);
                    }
                    if (iEv == 9 && iK == 4)
                    {
                        outlineString =
                            GetOutline(x - FontHeight / 2 - 29 - 11 + 30, y - FontHeight / 2, 's', outlineFontname, outlineEncoding, 38, 0, 262) +
                            GetOutline(x - FontHeight / 2 - 29 + 30 - 12 + 1 + 20, y - FontHeight / 2, 'a', outlineFontname, outlineEncoding, 38, 0, 262) +
                            GetOutline(x - FontHeight / 2 - 29 + 60 - 20 - 2 + 19, y - FontHeight / 2, 'y', outlineFontname, outlineEncoding, 38, 0, 262);
                    }

                    if (iEv == 19 && iK <= 10)
                    {
                        outlineString = GetOutline(x - FontHeight / 2 + 8, y - FontHeight / 2, ke.KText[0], outlineFontname, outlineEncoding, 38, 0, 262);
                    }

                    if (!isJp)
                    {
                        y += 2;
                    }

                    double t0 = ev.Start - 0.5 + iK * 0.07;
                    double t1 = t0 + 0.5;
                    double t2 = kStart;
                    double t3 = kEnd;
                    double t4 = ev.End - 0.6 + iK * 0.07;
                    double t5 = t4 + 0.5;

                    int lumsz = 12;
                    if (iEv == 9 && iK == 2)
                    {
                        lumsz = 18;
                    }
                    if (iEv == 1 || iEv == 2)
                    {
                        lumsz = 15;
                    }
                    ASSPointF[] lums = new ASSPointF[1];
                    for (int i = 0; i < lums.Length; i++)
                    {
                        lums[i] = new ASSPointF {
                            X = Common.RandomDouble(rnd, x_an7 - 2, x0), Y = Common.RandomDouble(rnd, y - 18, y + 18)
                        }
                    }
                    ;
                    string[] lumcols   = { "002BC8" };
                    string[] lumalphas = { "00" };

                    string shadCol1 = "000000";
                    if (!isJp)
                    {
                        shadCol1 = "FFFFFF";
                    }
                    string shadCol2 = "FFFFFF";

                    string lightCol = "6888FF";

                    if (isJp)
                    {
                        ass_out.AppendEvent(50, evStyle, t2 - 0.15, t3 - 0.15,
                                            pos(x + 1, y + 2) + fad(0.1, Common.Min(0.3, t3 - t2 - 0.2)) + fsc(150, 150) + t(fsc(100, 100).t()) +
                                            a(1, "00") + a(3, "66") + c(3, lumcols[0]) + bord(3) + blur(3) +
                                            ke.KText);
                        ass_out.AppendEvent(8, evStyle, t0, t2 + 0.8,
                                            pos(x + 2, y + 2) + fad(0.8, 0.8) +
                                            a(1, "77") + c(1, shadCol1) + blur(2) +
                                            ke.KText);
                        ass_out.AppendEvent(8, evStyle, t2, t5 - 0.5,
                                            pos(x + 2, y + 2) + fad(0.8, 0.8) +
                                            a(1, "00") + c(1, shadCol2) + blur(2) +
                                            ke.KText);
                    }
                    else
                    {
                        ass_out.AppendEvent(8, evStyle, t0, t5 - 0.5,
                                            pos(x + 2, y + 2) + fad(0.8, 0.8) +
                                            a(1, "00") + c(1, shadCol1) + blur(2) +
                                            ke.KText);
                    }

                    for (int iLum = 0; iLum < lums.Length; iLum++)
                    {
                        string col1   = lumcols[iLum];
                        double lum1_x = lums[iLum].X;
                        double lum1_y = lums[iLum].Y;
                        for (int i = 0; i < 2; i++)
                        {
                            ass_out.AppendEvent(20, "pt", t0, t1,
                                                an(5) +
                                                clip(4, outlineString) + pos(lum1_x, lum1_y) +
                                                a(1, lumalphas[iLum]) + a(3, "00") + c(1, col1) + c(3, col1) +
                                                t(bord(lumsz).t() + blur(lumsz).t()) +
                                                @"{\p1}m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(20, "pt", t1, t4,
                                                an(5) +
                                                clip(4, outlineString) + pos(lum1_x, lum1_y) +
                                                a(1, lumalphas[iLum]) + a(3, "00") + c(1, col1) + c(3, col1) +
                                                blur(lumsz) + bord(lumsz) +
                                                @"{\p1}m 0 0 l 1 0 1 1 0 1");
                            ass_out.AppendEvent(20, "pt", t4, t5,
                                                an(5) +
                                                clip(4, outlineString) + pos(lum1_x, lum1_y) +
                                                a(1, lumalphas[iLum]) + a(3, "00") + c(1, col1) + c(3, col1) +
                                                blur(lumsz) + bord(lumsz) +
                                                t(bord(0).t() + blur(0).t()) +
                                                @"{\p1}m 0 0 l 1 0 1 1 0 1");
                        }
                    }

                    if (!isJp)
                    {
                        continue;
                    }

                    /*if (iEv == 9)
                     * {
                     *  string strikeCol = "FF68AD";
                     *  for (int j = 0; j < 40; j++)
                     *  {
                     *      for (int i = 0; i < 20; i++)
                     *      {
                     *          double ptt0 = t2 - 0.3 + i * 0.01;
                     *          double ptt1 = ptt0 + 0.3;
                     *          string ptCol1 = Common.scaleColor(strikeCol, "FFFFFF", 1 - (double)i / 19.0 * 0.5);
                     *          string ptAlpha = "77";
                     *          if (i >= 17) ptAlpha = "00";
                     *          int ag1 = j * 9 + (int)(((double)i * 0.01) * 360);
                     *          int ag2 = ag1 + 360;
                     *          ass_out.AppendEvent(0 + i / 2, "pt", ptt0, ptt1,
                     *              move(x + 50, y, x + 50, y - 50) + org(x, y) + blur(2.3 - i * 0.07) + a(1, ptAlpha) + a(3, ptAlpha) + frz(-ag1) +
                     *              c(1, ptCol1) + c(3, ptCol1) + t(0, 0.1, fscx(250 - 10 * i).t()) + fscy(100 - i * 5) + t(frz(-ag2).t()) +
                     *              p(3) + "m 100 0 b 20 10 -20 10 -100 0 -20 -10 20 -10 100 0");
                     *      }
                     *  }
                     * }*/
                    if (iEv == 0)
                    {
                        foreach (ASSPoint pt in mask.Points)
                        {
                            double ag  = (double)(pt.Y - mask.Y0) / (double)mask.Height * 0.25;
                            int    iag = (int)(ag / Math.PI / 2 * 360);
                            ass_out.AppendEvent(70, "pt", t2 - 0.2, t5,
                                                pos(pt.X, pt.Y) + frz(iag) + t(fry(180).t()) + fad(0.1, 0.5) +
                                                a(1, "F4") + c(1, lightCol) + be(1) +
                                                @"{\p2}m 0 0 l -200 0 0 2");
                        }
                    }
                    if (iEv == 1 || iEv == 2)
                    {
                        double ptt0 = t2 - 0.2;
                        double ptt1 = t3 - 0.2;
                        double ptt2 = t3 + 2;
                        if (ptt2 > t4)
                        {
                            ptt2 = t4;
                        }
                        ass_out.AppendEvent(5, "pt", ptt0, ptt2,
                                            pos(x, y) + an(5) + blur(2) + bord(2) + fad(0.3, 0.5) +
                                            a(1, "00") + c(1, "FFFFFF") + fsc(50, 50) +
                                            t(0, 0.01, fsc(130, 130).t()) +
                                            t(ptt1 - ptt0 - 0.3, ptt1 - ptt0, fsc(70, 70).t() + a(1, "AA").t()) +
                                            a(3, "44") + c(3, "FF68AD") + t(frz((int)((ptt2 - ptt0) * ((((iEv + iK) % 2 == 1) ? 100 : -100)))).t()) +
                                            p(2) + "m 64 14 b 66 10 67 5 66 1 b 59 0 50 0 46 2 b 45 6 47 10 48 15 b 42 15 37 17 32 21 b 31 18 27 13 24 11 b 18 15 14 20 10 25 b 13 29 17 31 21 32 b 17 38 14 43 14 49 b 10 47 5 46 1 47 b 0 53 0 60 1 67 b 5 68 10 66 14 64 b 15 70 17 76 20 81 b 17 83 13 85 10 88 b 13 94 18 98 25 103 b 27 101 31 96 32 92 b 36 95 42 98 48 99 b 47 103 46 107 46 112 b 53 113 59 113 66 112 b 66 107 66 104 64 99 b 70 98 75 95 81 92 b 81 95 84 100 88 103 b 93 100 99 94 102 88 b 99 85 95 83 92 81 b 95 76 97 70 98 65 b 103 66 106 68 111 67 b 113 60 113 55 111 47 b 107 46 103 48 98 49 b 97 44 95 38 92 32 b 95 31 100 29 102 25 b 98 19 94 15 88 11 b 85 13 82 18 81 21 b 76 18 70 15 64 14 l 55 37 b 68 38 75 45 76 57 b 76 68 68 76 56 77 b 44 75 37 68 36 57 b 37 45 44 38 55 37 l 59 37 l 66 15 l 64 14");
                    }
                    if (iEv == 3 || iEv == 4)
                    {
                        string strikeCol = "FF68AD";
                        if (iEv == 3)
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                double ptt0    = t2 - 0.3 + i * 0.01;
                                double ptt1    = ptt0 + 0.3;
                                string ptCol1  = Common.scaleColor(strikeCol, "FFFFFF", (double)i / 19.0 * 0.8);
                                string ptCol2  = Common.scaleColor(strikeCol, "FFFFFF", (double)i / 19.0 * 0.5);
                                string ptAlpha = "77";
                                if (i >= 17)
                                {
                                    ptAlpha = "00";
                                }
                                ass_out.AppendEvent(15, "pt", ptt0, ptt1,
                                                    pos(x, y) + blur(2.3 - i * 0.07) + a(1, ptAlpha) + a(3, ptAlpha) + frz(90) +
                                                    c(1, ptCol1) + c(3, ptCol1) + t(0, 0.1, fscx(500 - 20 * i).t()) + fscy(100 - i * 5) +
                                                    p(3) + "m 100 0 b 20 10 -20 10 -100 0 -20 -10 20 -10 100 0");
                            }
                        }
                        else if (iEv == 4)
                        {
                            for (int j = 0; j < 4; j++)
                            {
                                if ((iEv + iK + (j / 2)) % 2 == 0)
                                {
                                    continue;
                                }
                                string ptStr = "m 100 0 b 20 10 -20 10 -100 0 -20 -10 20 -10 100 0";
                                if (j >= 2)
                                {
                                    ptStr = "m 0 -100 b 10 -20 10 20 0 100 -10 20 -10 -20 0 -100";
                                }
                                Func <double, ASSPointF> fpos = ti => new ASSPointF();
                                if (j == 2)
                                {
                                    fpos = ti => new ASSPointF {
                                        X = x - 20, Y = y + ti * 200
                                    }
                                }
                                ;
                                else if (j == 3)
                                {
                                    fpos = ti => new ASSPointF {
                                        X = x + 20, Y = y - ti * 200
                                    }
                                }
                                ;
                                else if (j == 0)
                                {
                                    fpos = ti => new ASSPointF {
                                        X = x + ti * 200, Y = y - 20
                                    }
                                }
                                ;
                                else if (j == 1)
                                {
                                    fpos = ti => new ASSPointF {
                                        X = x - ti * 200, Y = y + 20
                                    }
                                }
                                ;
                                for (int i = 0; i < 20; i++)
                                {
                                    double ptt0    = t2 - 0.3 + i * 0.01;
                                    double ptt1    = ptt0 + 0.3;
                                    string ptCol1  = Common.scaleColor(strikeCol, "FFFFFF", (double)i / 19.0 * 0.8);
                                    string ptCol2  = Common.scaleColor(strikeCol, "FFFFFF", (double)i / 19.0 * 0.5);
                                    string ptAlpha = "77";
                                    if (i >= 17)
                                    {
                                        ptAlpha = "00";
                                    }
                                    ass_out.AppendEvent(15, "pt", ptt0, ptt1,
                                                        move(fpos(ptt0 - t2 + 0.3 - 0.3), fpos(ptt1 - t2 + 0.3)) + blur(2.3 - i * 0.07) + a(1, ptAlpha) + a(3, ptAlpha) +
                                                        c(1, ptCol1) + c(3, ptCol1) + ((j <= 1) ? (t(0, 0.1, fscx(500 - 20 * i).t()) + fscy(100 - i * 5)) : (t(0, 0.1, fscy(500 - 20 * i).t()) + fscx(100 - i * 5))) +
                                                        p(3) + ptStr);
                                }
                            }
                        }
                        {
                            double ptt0 = t2 - 0.2;
                            double ptt1 = t3 - 0.2;
                            double ptt2 = t3 + 2;
                            if (ptt2 > t4)
                            {
                                ptt2 = t4;
                            }
                            ass_out.AppendEvent(5, "pt", ptt0, ptt2,
                                                pos(x, y + 15) + an(5) + blur(2) + bord(2) + fad(0.3, 0.5) +
                                                a(1, "00") + c(1, "FFFFFF") + fsc(50, 50) + frx(60) +
                                                t(0, 0.01, fsc(130, 130).t()) +
                                                t(ptt1 - ptt0 - 0.3, ptt1 - ptt0, fsc(70, 70).t() + a(1, "77").t()) +
                                                a(3, "44") + c(3, "FF68AD") + t(frz((int)((ptt2 - ptt0) * ((((iEv + iK) % 2 == 1) ? 100 : -100)))).t()) +
                                                p(2) + "m 64 14 b 66 10 67 5 66 1 b 59 0 50 0 46 2 b 45 6 47 10 48 15 b 42 15 37 17 32 21 b 31 18 27 13 24 11 b 18 15 14 20 10 25 b 13 29 17 31 21 32 b 17 38 14 43 14 49 b 10 47 5 46 1 47 b 0 53 0 60 1 67 b 5 68 10 66 14 64 b 15 70 17 76 20 81 b 17 83 13 85 10 88 b 13 94 18 98 25 103 b 27 101 31 96 32 92 b 36 95 42 98 48 99 b 47 103 46 107 46 112 b 53 113 59 113 66 112 b 66 107 66 104 64 99 b 70 98 75 95 81 92 b 81 95 84 100 88 103 b 93 100 99 94 102 88 b 99 85 95 83 92 81 b 95 76 97 70 98 65 b 103 66 106 68 111 67 b 113 60 113 55 111 47 b 107 46 103 48 98 49 b 97 44 95 38 92 32 b 95 31 100 29 102 25 b 98 19 94 15 88 11 b 85 13 82 18 81 21 b 76 18 70 15 64 14 l 55 37 b 68 38 75 45 76 57 b 76 68 68 76 56 77 b 44 75 37 68 36 57 b 37 45 44 38 55 37 l 59 37 l 66 15 l 64 14");
                        }
                    }
                    if (iEv >= 5 && iEv <= 9)
                    {
                        string strikeCol = "FF68AD";
                        double ptt0      = t2 - 0.3;
                        double ptt1      = t3 - 0.2 - 0.1;
                        if (ptt1 > t4)
                        {
                            ptt1 = t4;
                        }
                        double           theta1 = Common.RandomDouble(rnd, 0, Math.PI);
                        List <BaseCurve> curves = new List <BaseCurve>();
                        Circle2          cl     = new Circle2 {
                            X0 = x, Y0 = y, A = 60, B = 27, MinT = 0 + ptt0 * 4, MaxT = (ptt1 - ptt0) * Math.PI * 2 + ptt0 * 4, Theta = theta1, dTheta = 0
                        };
                        CompositeCurve cc = new CompositeCurve {
                            MinT = ptt0, MaxT = ptt1
                        };
                        cc.AddCurve(cc.MinT, cc.MaxT, cl);
                        curves.Add(cc);
                        cl = new Circle2 {
                            X0 = x, Y0 = y, A = 60, B = 27, MinT = 0 + ptt0 * 4 + Math.PI, MaxT = Math.PI + (ptt1 - ptt0) * Math.PI * 2 + ptt0 * 4, Theta = theta1, dTheta = 0
                        };
                        cc = new CompositeCurve {
                            MinT = ptt0, MaxT = ptt1
                        };
                        cc.AddCurve(cc.MinT, cc.MaxT, cl);
                        curves.Add(cc);
                        for (int i = 0; i < curves.Count; i++)
                        {
                            BaseCurve        curve      = curves[i];
                            List <ASSPointF> path       = curve.GetPath_Dis(6, 7);
                            string           strikeCol2 = Common.scaleColor(strikeCol, "FFFFFF", 0.5);
                            foreach (ASSPointF pt in path)
                            {
                                ass_out.AppendEvent((pt.Theta < Math.PI) ? 0 : 100, "pt", pt.T, pt.T + 0.3,
                                                    pos(pt.X, pt.Y) + a(1, "44") + a(3, "77") + c(1, "FFFFFF") + c(3, "FFFFFF") +
                                                    bord(8) + blur(8) +
                                                    t(0, 0.04, c(1, strikeCol2).t() + c(3, strikeCol2).t() + bord(4).t() + blur(4).t()) +
                                                    t(0.04, 0.3, c(1, strikeCol).t() + c(3, strikeCol).t() + bord(2).t() + blur(2).t()) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                                ass_out.AppendEvent((pt.Theta < Math.PI) ? 0 : 100, "pt", pt.T, pt.T + 0.3,
                                                    pos(pt.X, pt.Y) + a(1, "44") + a(3, "44") + c(1, "FFFFFF") + c(3, "FFFFFF") +
                                                    bord(4) + blur(4) +
                                                    t(0, 0.04, bord(2.5).t() + blur(2.5).t()) +
                                                    t(0.04, 0.3, bord(1.3).t() + blur(1.3).t()) +
                                                    p(1) + "m 0 0 l 1 0 1 1 0 1");
                            }
                        }
                        for (int j = 0; j < 10; j++)
                        {
                            double             dz    = Common.RandomDouble(rnd, -30, 30);
                            Func <double, int> fz    = ti => (int)((theta1 + Math.PI * 0.5) / Math.PI / 2.0 * 360.0 + dz * (ptt1 - ti) / (ptt1 - ptt0));
                            string             ptStr = "m 100 0 b 20 10 -20 10 -100 0 -20 -10 20 -10 100 0";
                            for (int i = 0; i < 20; i++)
                            {
                                double pttt0   = ptt0 + i * 0.01;
                                double pttt1   = ptt1;
                                string ptCol1  = Common.scaleColor(strikeCol, "FFFFFF", (double)i / 19.0 * 0.8);
                                string ptCol2  = Common.scaleColor(strikeCol, "FFFFFF", (double)i / 19.0 * 0.5);
                                string ptAlpha = "77";
                                if (i >= 17)
                                {
                                    ptAlpha = "00";
                                }
                                ass_out.AppendEvent(0 + i, "pt", pttt0, pttt1,
                                                    fad(0, 0.5) + pos(x, y) + blur(2.3 - i * 0.07) + a(1, ptAlpha) + a(3, ptAlpha) + frz(fz(pttt0)) +
                                                    c(1, ptCol1) + c(3, ptCol1) + t(0, 0.1, fscx(500 - 20 * i).t()) + fscy(100 - i * 5) + t(0, (pttt1 - pttt0) * 0.9, frz(fz(pttt1)).t()) +
                                                    p(3) + ptStr);
                            }
                        }
                    }
                }
            }

            Console.WriteLine(ass_out.Events.Count);
            ass_out.SaveFile(this.OutFileName);
        }
    }
}
Exemplo n.º 24
0
 public VisualCircle(Circle2 circle)
 {
     _circle = circle;
 }
Exemplo n.º 25
0
        private static void Main(string[] args)
        {
            // Factory Method
            // ------------------- Develop
            Console.WriteLine("------------------- Develop");

            Developer dev1   = new DeveloperPanel("ООО ПанельСтрой");
            House     house1 = dev1.Create();

            Developer dev2   = new DeveloperWood("ООО Опушка");
            House     house2 = dev2.Create();

            Developer dev3   = new DeveloperBrick("ООО КирпичСтрой");
            House     house3 = dev3.Create();

            // List

            var developArray = new List <Developer>
            {
                new DeveloperPanel("ООО ПанельСтрой"),
                new DeveloperWood("ООО Опушка"),
                new DeveloperBrick("ООО КирпичСтрой")
            };

            foreach (var dev in developArray)
            {
                dev.Create();
            }

            // ------------------- Money
            Console.WriteLine("------------------- Money");

            // Устанавливаем кодировку чтобы корректно отобразился символ рубля.
            Console.OutputEncoding = Encoding.Unicode;

            // Создаем коллекцию устройств для печати денег.
            // Обратите внимание, что мы можем хранить их все в одной коллекции.
            var machines = new List <CashMachineBase>
            {
                new RubleCashMachine(),
                new DollarCashMachine(),
                new EuroCashMachine()
            };

            // Создаем коллекцию для хранения денег.
            // Опять таки здесь могут храниться любые классы, унаследованные от MoneyBase.
            var money = new List <MoneyBase>();

            // Генератор случайных числе.
            var rnd = new Random();

            // По очереди запускаем устройства для печати денег.
            foreach (var machine in machines)
            {
                // Случайное количество листов для разнообразия.
                var pageCount = rnd.Next(1, 3);

                // Вызываем фабричный метод для создания валюты.
                var newMoney = machine.Create(pageCount);

                // Добавляем созданную валюту в общую коллекцию.
                money.AddRange(newMoney);
            }

            // Выводим данные о деньгах на экран.
            foreach (var note in money)
            {
                Console.WriteLine(note);
            }

            //Console.ReadLine();

            // Template method
            // ------------------- Pie
            Console.WriteLine("------------------- Pie");

            PieBase applePie = new ApplePie();
            PieBase meatPie  = new MeatPie();

            // Готовим мясной пирог.
            Console.WriteLine(meatPie);
            meatPie.Cook();
            // Console.ReadLine();

            // Готовим яблочный пирог.
            Console.WriteLine(applePie);
            applePie.Cook();
            // Console.ReadLine();

            Console.WriteLine("------------------- School");

            School     school     = new School();
            University university = new University();
            College    college    = new College();

            school.Learn();
            university.Learn();
            college.Learn();

            // Adapter
            // ------------------- Travel
            Console.WriteLine("------------------- Travel");

            // Путешественник
            Driver driver = new Driver();

            // Машина
            Auto auto = new Auto();

            // Отправляемся в путешествие
            driver.Travel(auto);

            // Встретились пески, надо использовать верблюда
            Camel camel = new Camel();

            // Используем адаптер
            ITransport camelToTransportAdapter = new CamelToTransportAdapter(camel);

            // Продолжаем путь по пескам пустыни
            driver.Travel(camelToTransportAdapter);

            // Iterator
            // ------------------- Iterator
            Console.WriteLine("------------------- Iterator");

            Aggregate aggregate = new ConcreteAggregate();

            Iterator iterator = aggregate.CreateIterator();

            /*
             * object item = iterator.First();
             * while(!iterator.IsDone())
             * {
             *  item = iterator.Next();
             * }
             */

            Console.WriteLine("------------------- Iterator Books");

            var library = new Library();
            var reader  = new Reader();

            reader.SeeBooks(library);

            Console.WriteLine("------------------- Iterator Words");

            // Клиентский код может знать или не знать о Конкретном Итераторе
            // или классах Коллекций, в зависимости от уровня косвенности,
            // который вы хотите сохранить в своей программе.
            var collection = new BehavioralPatterns.Iterator.Words.WordsCollection();

            collection.AddItem("First");
            collection.AddItem("Second");
            collection.AddItem("Third");

            Console.WriteLine("Straight traversal:");

            foreach (var element in collection)
            {
                Console.WriteLine(element);
            }

            Console.WriteLine("\nReverse traversal:");

            collection.ReverseDirection();

            foreach (var element in collection)
            {
                Console.WriteLine(element);
            }

            // State
            // ------------------- State
            Console.WriteLine("------------------- State");

            var context = new Context(new StateA());

            context.Request(); // Переход в состояние StateB
            context.Request(); // Переход в состояние StateA

            var water = new Water(new LiquidWaterState());

            water.Heat();
            water.Frost();
            water.Frost();

            // Prototype
            // ------------------- Prototype
            Console.WriteLine("------------------- Prototype");

            Prototype prototype = new ConcretePrototype1(5);
            Prototype clone     = prototype.Clone();

            prototype = new ConcretePrototype2(7);
            clone     = prototype.Clone();

            // --- Circle
            IFigure rectangle                = new Rectangle(100, 300);
            IFigure rectangleClone           = rectangle.Clone();
            IFigure rectangleMemberwiseClone = rectangle.CloneMemberwise();

            rectangleMemberwiseClone.GetInfo();
            rectangle.GetInfo();
            rectangleClone.GetInfo();

            IFigure circle      = new Circle(152);
            IFigure circleClone = circle.Clone();

            circle.GetInfo();
            circleClone.GetInfo();

            // Shallow Copy
            Console.WriteLine("--- Shallow Copy");
            var figure      = new Circle2(30, 50, 60);
            var cloneFigure = figure.CloneMemberwise() as Circle2;

            figure.Point.X = 100;
            figure.GetInfo();
            cloneFigure.GetInfo();

            // Deep Copy
            Console.WriteLine("--- Deep Copy");
            var figure2      = new Circle2(30, 50, 60);
            var cloneFigure2 = figure2.DeepCopy() as Circle2;

            figure2.Point.X = 100;
            figure2.GetInfo();
            cloneFigure2.GetInfo();

            // Proxy
            // ------------------- Proxy
            Console.WriteLine("------------------- Proxy");

            var client = new BehavioralPatterns.Proxy.RealProxy.Client();

            Console.WriteLine("Client: Executing the client code with a real subject:");
            var realSubject = new BehavioralPatterns.Proxy.RealProxy.RealSubject();

            client.ClientCode(realSubject);

            Console.WriteLine();
            Console.WriteLine("Client: Executing the same client code with a proxy:");
            var proxy = new BehavioralPatterns.Proxy.RealProxy.Proxy(realSubject);

            client.ClientCode(proxy);
        }