Ejemplo n.º 1
0
        SpriteSet MakeOuterRing(int s, int e, Vector2 position, float patternRadius, float scale)
        {
            var   bitmap        = GetMapsetBitmap(Sprites.Triangle);
            float triangleWidth = bitmap.Width;

            var       hexagon   = Patterns.Circle2D(position, patternRadius, (float)-Math.PI / 3, 5 * (float)Math.PI / 6);
            SpriteSet triangles = layer.CreateSpriteSet(Sprites.Triangle, _ => OsbOrigin.Centre, hexagon, 6);

            triangles.Fade(s, e, 1.0, 1.0);
            triangles.Rotate(i => - Math.PI / 3 + i * Math.PI / 3);
            triangles.Scale(patternRadius / triangleWidth * scale);
            return(triangles);
        }
Ejemplo n.º 2
0
        SpriteSet MakeInnerRing(int s, int e, Vector2 position, float patternRadius, float scale)
        {
            var   bitmap        = GetMapsetBitmap(Sprites.Triangle);
            var   bitmap2       = GetMapsetBitmap(Sprites.Circle);
            float triangleWidth = bitmap.Width;
            float circleWidth   = bitmap2.Width;

            var       hexagon2 = Patterns.Circle2D(position, patternRadius, (float)-Math.PI / 3, 5 * (float)Math.PI / 6);
            SpriteSet circles  = layer.CreateSpriteSet(Sprites.Circle, _ => OsbOrigin.Centre, hexagon2, 6);

            circles.Fade(s, e, 1.0, 1.0);
            circles.Scale(patternRadius / circleWidth * scale * 0.8f);

            float dist = 0.36f;
            Func <int, Vector2> hexagon3       = (int i) => Vector2.Lerp(hexagon2(i), hexagon2(i + 1), i < 6 ? dist : 1 - dist);
            SpriteSet           smallTriangles = layer.CreateSpriteSet(Sprites.Triangle, _ => OsbOrigin.Centre, hexagon3, 12);

            smallTriangles.Fade(s, e, 1.0, 1.0);
            smallTriangles.Scale(patternRadius / triangleWidth * scale * 0.3f);
            smallTriangles.Rotate(i => hexagon3(i).rotationTo(hexagon3(i + 6)), 0, 6);
            smallTriangles.Rotate(i => hexagon3(i).rotationTo(hexagon3(i - 6)), 6, 6);

            return(circles + smallTriangles);
        }
Ejemplo n.º 3
0
        void Section4_1()
        {
            // circle
            int   s    = 62840;
            int   e    = 63468;
            float fade = 1;

            layer      = GetLayer("");
            maskLayer  = GetLayer("masks");
            maskLayer2 = GetLayer("masks2");
            var downwardsMovement = new Movement(OsbEasing.OutExpo, s, e, Vectors.Centre + Vectors.up(100), Vectors.Centre);

            var ring1     = maskLayer2.CreateSprite(Sprites.Circle, OsbOrigin.Centre, downwardsMovement.StartPosition);
            var ring1Mask = maskLayer2.CreateSprite(Sprites.Circle, OsbOrigin.Centre, downwardsMovement.StartPosition);

            int   circleWidth   = GetMapsetBitmap(Sprites.Circle).Width;
            float width         = 350.0f;
            float width2        = 250.0f;
            float scale         = width / circleWidth;
            float thickness     = 10;
            float lineThickness = thickness * 0.71f;
            float maskScale     = (width - thickness * 2) / circleWidth / scale;

            ring1.Fade(s, e, fade, fade);
            ring1.Scale(OsbEasing.OutExpo, s, e - Timing.beat(s), scale, scale / width * width2);
            ring1.Move(downwardsMovement);

            ring1Mask.Fade(s, e, 1, 1);
            ring1Mask.Color(s, Color4.Black); ring1Mask.Scale(OsbEasing.OutExpo, s, e - Timing.beat(s), scale * maskScale, scale * maskScale / width * width2);
            ring1Mask.Move(downwardsMovement);

            // 3d ring
            float startOfRotation = e - 1.25f * (float)Timing.beat(s);
            var   inOutExpo       = OsbEasing.InOutExpo.ToEasingFunction();
            var   outExpo         = OsbEasing.OutExpo.ToEasingFunction();
            Func <float, float, Vector3> moving3DCircle = (float t, float time) =>
            {
                float   tilt   = time < startOfRotation ? 0 : (float)inOutExpo((time - startOfRotation) / (e - startOfRotation));
                Vector3 centre = downwardsMovement.PositionAtTime(time).withZ(0);
                float   radius = (MathHelper.Clamp(
                                      InterpolatingFunctions.Float(width, width2, outExpo((time - s) / (e - Timing.beat(s) - s))),
                                      width2, width
                                      ) - thickness) / 2;

                Vector3 rot1 = new Vector3(
                    5 * (float)Math.PI / 16,
                    (float)Math.PI / 2,
                    0
                    );

                Vector3 rot2 = new Vector3(
                    5 * (float)Math.PI / 16,
                    (float)Math.PI / 4,
                    0
                    );

                Vector3 rot = Vector3.Lerp(rot1, rot2, tilt);

                var res = radius * new Vector3(
                    (float)Math.Cos(-t),
                    (float)Math.Sin(-t),
                    0
                    ).rotateX(rot.X).rotateY(rot.Y).rotateZ(rot.Z) + centre;
                return(res);
            };

            int   count    = 200;
            float dotScale = lineThickness / circleWidth;

            for (int i = 0; i < count; i++)
            {
                var sprite = layer.CreateSprite(Sprites.Circle, OsbOrigin.Centre);
                sprite.Fade(s, e, 1, 1);
                for (float t = s; t < e; t += delta)
                {
                    float t2 = t + delta < e ? t + delta : e;

                    Vector3 p1 = moving3DCircle(
                        i * 2 * (float)Math.PI / count,
                        t
                        );

                    Vector3 p2 = moving3DCircle(
                        i * 2 * (float)Math.PI / count,
                        t2
                        );

                    sprite.Move3D(
                        OsbEasing.None,
                        t, t2,
                        p1, p2,
                        FOV,
                        (_sprite, _p1, _p2) =>
                    {
                        float scale1 = dotScale / _p1.normalisedVector.Length;
                        float scale2 = dotScale / _p2.normalisedVector.Length;
                        if (scale1 != scale2)
                        {
                            _sprite.Scale(t, t2, scale1, scale2);
                        }
                    }
                        );
                }
            }

            // dotted line through the sphere
            count = 35;
            float opacity             = 1;
            float lineAppearStart     = s + (float)Timing.beat(s) / 3;
            float appearDelay         = (float)Timing.beat(s) / 2 / count;
            float length              = width2 + 2 * 70;
            float dottedLineThickness = 1.2f;

            SpriteSet axisDottedLine = maskLayer.CreateSpriteSet(
                Sprites.Pixel,
                _ => OsbOrigin.TopCentre,
                Patterns.Line2D(Vectors.Centre + Vectors.up(length / 2), Vectors.Centre + Vectors.down(length / 2), count),
                count
                );

            var dotMovement = new Movement(OsbEasing.OutQuint, s + Timing.beat(s) / 3, e, Vectors.Centre + Vectors.up(100), Vectors.Centre);

            axisDottedLine.MoveRelative(dotMovement - Vectors.Centre);
            axisDottedLine.ScaleVec((int)lineAppearStart, new Vector2(dottedLineThickness, length / count / 2));

            axisDottedLine.Fade(
                OsbEasing.None,
                i => lineAppearStart + i * appearDelay,
                i => lineAppearStart + i * appearDelay + 100,
                0, opacity
                );
            axisDottedLine.Fade(e, 0);

            SpriteSet gradientMask = maskLayer.CreateSpriteSet(Sprites.TransparentGradient, _ => OsbOrigin.CentreRight, 2);

            gradientMask.Rotate(lineAppearStart, i => Math.PI / 2 + i * Math.PI);
            float gradientWidth = GetMapsetBitmap(Sprites.TransparentGradient).Width;

            gradientMask.ScaleVec(lineAppearStart, new Vector2(length / 2 / gradientWidth, dottedLineThickness));
            gradientMask.AddSprites(
                Sprites.Pixel,
                i => (i % 2 == 0 ? OsbOrigin.BottomCentre : OsbOrigin.TopCentre),
                i => Vectors.Centre + (i % 2 == 0 ? 1 : -1) * Vectors.up(length / 2),
                2
                );
            float gradientExtension = Vectors.Centre.Y - length / 2;

            gradientMask.ScaleVec(lineAppearStart, new Vector2(dottedLineThickness, gradientExtension), 2);
            gradientMask.Color(lineAppearStart, Color4.Black);
            gradientMask.Fade(lineAppearStart, e, 1.0, 1.0);

            SpriteSet cover = maskLayer.CreateSpriteSet(Sprites.Pixel, 2);

            cover.Move(i => downwardsMovement.ResampledSection(lineAppearStart, e, delta)
                       + Vectors.up((width2 - lineThickness) / 2) * (i % 2 == 0 ? 1 : -1));
            cover.Fade(lineAppearStart, e, 1.0, 1.0);
            cover.ScaleVec(lineAppearStart, new Vector2(dottedLineThickness, lineThickness));

            // point cloud
            count = 50;
            float pointScale = 0.2f;
            var   pattern    = Patterns.PointCloudGlobe(Vectors.Centre.withZ(0), 500, new Random(RandomSeed));
            var   points     = new List <Vector3>();

            for (int i = 0; i < count; i++)
            {
                points.Add(pattern(i));
            }
            SpriteSet pointCloud = layer.CreateSpriteSet(
                Sprites.Particle,
                _ => OsbOrigin.Centre,
                i => points[i].project(Vectors.ScreenSize, Vectors.Centre, FOV).screenSpaceVector,
                count
                );

            pointCloud.Fade(startOfRotation, startOfRotation + Timing.beat(s) / 2, 0, 0.6);
            pointCloud.Fade(e, 0);
            pointCloud.Scale(startOfRotation, 5);
            for (float t = startOfRotation; t < e; t += delta)
            {
                float t2     = t + delta < e ? t + delta : e;
                float angle  = (float)(-Math.PI / 4 * inOutExpo((t - startOfRotation) / (e - startOfRotation)));
                float angle2 = (float)(-Math.PI / 4 * inOutExpo((t2 - startOfRotation) / (e - startOfRotation)));
                pointCloud.Move3D(
                    OsbEasing.None,
                    t, t2,
                    i => points[i].rotateY(angle, Vectors.Centre3D),
                    i => points[i].rotateY(angle2, Vectors.Centre3D),
                    FOV,
                    (_sprite, _p1, _p2) =>
                {
                    float scale1 = pointScale / _p1.normalisedVector.Length;
                    float scale2 = pointScale / _p2.normalisedVector.Length;
                    if (scale1 != scale2)
                    {
                        _sprite.Scale(t, t2, scale1, scale2);
                    }
                }
                    );
            }
            foreach (var sprite in pointCloud.Sprites)
            {
                SpriteSet trail = Effects.Trail(layer, sprite, startOfRotation, e, 1000.0 / 60, 0, 0, 150, true);
                trail.UseScaleOf(sprite);
            }
        }
Ejemplo n.º 4
0
        private void Grid(int s, int e)
        {
            int   count    = 16 * 14;
            float scale    = 1.3f;
            float rotation = (float)-Math.PI / 6;
            Func <int, Vector2> pattern = (int i) => {
                return(Patterns.Grid2D(
                           Vectors.ScreenTopLeft.scaled(scale),
                           Vectors.ScreenBottomRight.scaled(scale),
                           16, 9)(i)
                       .up(100).rotated(rotation).scaled(1.2));
            };
            var sprites = new SpriteSet(
                layer,
                i => BlurredSquareOutline,
                i => OsbOrigin.Centre,
                i => pattern(i)
                , count
                );
            float fade = 0.4f;
            //sprites.Fade(s, s + 200, 0.0f, fade);
            double wavelength = 0.4f;
            double duration   = 5000;

            double[] shifts = new double[count];
            for (int i = 0; i < count; i++)
            {
                shifts[i] = 1000 * (sprites.Get(i).InitialPosition - Vectors.Centre.left(Vectors.ScreenSize.X / 2)).Length
                            / Vectors.ScreenSize.X / wavelength;
            }
            for (double t = s + 200; t < e - 200; t += duration)
            {
                int i = 0;
                foreach (var sprite in sprites.Sprites)
                {
                    sprite.Fade(OsbEasing.InOutSine, t + shifts[i], t + duration / 2 + shifts[i], 0.02f, fade);
                    sprite.Fade(OsbEasing.InOutSine, t + duration / 2 + shifts[i], t + duration + shifts[i], fade, 0.02f);
                    i++;
                }
            }
            //sprites.Fade(e - 200, e, fade, 0.0);
            sprites.Scale(.7 * 1 / .7);
            sprites.Rotate(rotation);
            Vector2 d = Vectors.polar(rotation, 50);

            sprites.MoveRelative(OsbEasing.None, s, e, d, -d);

            var flashes = new SpriteSet(
                layer,
                i => BlurredSquareFilled,
                i => OsbOrigin.Centre,
                i => pattern(i),
                count
                );
            float flashFade = 0.7f;

            flashes.MoveRelative(OsbEasing.None, s, e, d, -d);
            flashes.UseScalesOf(sprites);
            flashes.UseRotationsOf(sprites);
            flashes.Fade(s, 0);
            double[] prevTimes = new double[count];
            for (int i = 0; i < count; i++)
            {
                prevTimes[i] = s;
            }
            for (double t = s; t < e; t += 50)
            {
                while (true)
                {
                    int   index      = Random(0, count);
                    float flashFade2 = flashFade * sprites.Get(index).OpacityAt(t) / fade;
                    if (prevTimes[index] <= t)
                    {
                        flashes.Fade(OsbEasing.OutExpo, t, t + 100, 0, flashFade2, index, 1);
                        flashes.Fade(OsbEasing.Out, t + 100, t + 2000, flashFade2, 0, index, 1);
                        prevTimes[index] = t + 2000;
                        break;
                    }
                }
            }
            flashes.Additive();
        }