public void ColorLinearGradient(int startTime, int duration, CommandColor colorA, CommandColor colorB, bool isVertical)
        {
            // Colors triangles in a gradient from colorA to colorB.
            // Decide whether to make the gradient transition vertically or horizontally
            // using the Boolean. (horizontal=0, vertical=1)

            var difference = new Vector3((colorB.R - colorA.R),
                                         (colorB.G - colorA.G),
                                         (colorB.B - colorA.B));         // The difference between colorA and colorB

            var colorVector = new Vector3(colorA.R, colorA.G, colorA.B); // Ideally the goal is a linear dist from this to colorB

            var limiter = (isVertical) ? GridWidth : GridHeight;         // How many points to split for the linear distribution

            var step = Vector3.Divide(difference, limiter);

            // var step = new Vector3( difference.X / limiter, difference.Y / limiter, difference.Z / limiter ); // The step...

            // Now comes the loop:
            for (int a = 0; a < limiter; a++)
            {
                var decColorVector = Vector3.Divide(colorVector, 255);
                ColorRowCol(startTime, duration, a, new CommandColor(decColorVector), !isVertical);
                colorVector += step;
            }
        }
Esempio n. 2
0
        private void convertToCommands(OsbSprite sprite, double?startTime, double?endTime, double timeOffset, bool loopable)
        {
            var startStateTime = loopable ? (startTime ?? StartState.Time) + timeOffset : (double?)null;
            var endStateTime   = loopable ? (endTime ?? EndState.Time) + timeOffset : (double?)null;

            finalPositions.ForEachPair((start, end) => sprite.Move(start.Time, end.Time, start.Value, end.Value), new Vector2(320, 240),
                                       p => new Vector2((float)Math.Round(p.X, PositionDecimals), (float)Math.Round(p.Y, PositionDecimals)), startStateTime, loopable: loopable);
            var useVectorScaling = finalScales.Any(k => k.Value.X != k.Value.Y);

            finalScales.ForEachPair((start, end) =>
            {
                if (useVectorScaling)
                {
                    sprite.ScaleVec(start.Time, end.Time, start.Value, end.Value);
                }
                else
                {
                    sprite.Scale(start.Time, end.Time, start.Value.X, end.Value.X);
                }
            }, Vector2.One, s => new Vector2((float)Math.Round(s.X, ScaleDecimals), (float)Math.Round(s.Y, ScaleDecimals)), startStateTime, loopable: loopable);
            finalRotations.ForEachPair((start, end) => sprite.Rotate(start.Time, end.Time, start.Value, end.Value), 0,
                                       r => (float)Math.Round(r, RotationDecimals), startStateTime, loopable: loopable);
            finalColors.ForEachPair((start, end) => sprite.Color(start.Time, end.Time, start.Value, end.Value), CommandColor.White,
                                    c => CommandColor.FromRgb(c.R, c.G, c.B), startStateTime, loopable: loopable);
            finalOpacities.ForEachPair((start, end) => sprite.Fade(start.Time, end.Time, start.Value, end.Value), -1,
                                       o => (float)Math.Round(o, OpacityDecimals), startStateTime, endStateTime, loopable: loopable);

            flipH.ForEachFlag((fromTime, toTime) => sprite.FlipH(fromTime, toTime));
            flipV.ForEachFlag((fromTime, toTime) => sprite.FlipV(fromTime, toTime));
            additive.ForEachFlag((fromTime, toTime) => sprite.Additive(fromTime, toTime));
        }
        public void GuitarSolo()
        {
            // This is the triangle behavior for the guitar solo portion.
            // The idea is to colorize the entire triangle area as motherf'in evil, and then the ones that aren't go through some cool flip effects.
            var bigPoints = new Vector2[16] {
                new Vector2(8, 0),
                new Vector2(9, 0),
                new Vector2(10, 0),
                new Vector2(7, 1),
                new Vector2(11, 1),
                new Vector2(4, 2),
                new Vector2(5, 2),
                new Vector2(6, 2),
                new Vector2(12, 2),
                new Vector2(13, 2),
                new Vector2(14, 2),
                new Vector2(5, 3),
                new Vector2(9, 3),
                new Vector2(13, 3),
                new Vector2(4, 4),
                new Vector2(14, 4)
            };

            // Now let's create a topography color based off that.
            CommandColor hotColor  = new CommandColor(0.8, 0.1, 0.1);
            CommandColor coldColor = new CommandColor(0.1, 0.1, 0.1);

            ColorTopography(StartTime, 0, hotColor, coldColor, 3, bigPoints);

            var beatDuration = 4 * (60000) / Beatmap.GetTimingPointAt((int)StartTime).Bpm;

            // The goal is to have the central non-hotspot flip on and off with backgrounds.
            executeSprite flipOff = delegate(OsbSprite s, float startTime, float duration) { s.StartLoopGroup(startTime, 4);
                                                                                             s.ScaleVec(OsbEasing.OutCubic, 0, duration, new CommandScale(1, 1), new CommandScale(1, 0));
                                                                                             s.ScaleVec(OsbEasing.InCubic, beatDuration - duration, beatDuration, new CommandScale(1, 0), new CommandScale(1, 1));
                                                                                             s.Fade(beatDuration * 2, 1);
                                                                                             s.EndGroup(); };

            executeSprite shockColor = delegate(OsbSprite s, float st, float step) { s.StartLoopGroup(st, 8);
                                                                                     s.Color(OsbEasing.OutQuint, 0, step, new CommandColor(1, 0, 0), s.ColorAt(st));
                                                                                     s.Fade(beatDuration, 1);
                                                                                     s.EndGroup(); };

            // Query for the wall being the hotColor
            querySprite colorWall = delegate(OsbSprite s, float queryTime) { return(s.ColorAt(queryTime) == hotColor); };

            // Wonder if this works. Let's try having a loop with the shockwaves.
            ShockwaveFill(StartTime, 600, 150, bigPoints[12] - new Vector2(0, 1), bigPoints[12], new bool[GridWidth, GridHeight], flipOff, colorWall);

            // Left/right shockwave flashes?
            ShockwaveFill(StartTime, 300, 75 / 2, new Vector2(0, 0), bigPoints[12], new bool[GridWidth, GridHeight], shockColor, colorWall);
            ShockwaveFill(StartTime, 300, 75 / 2, new Vector2(GridWidth - 1, 0), bigPoints[12], new bool[GridWidth, GridHeight], shockColor, colorWall);


            // HARD VALUES BAD
            ScaleXYFlip(120645 - 600, 600, true, false);
        }
 public void ColorAllTriangles(int startTime, int duration, CommandColor newColor)
 {
     // Colors all the triangles as... THE SAME COLOR.
     // To instantly change color, just set duration to 0.
     foreach (var s in grid)
     {
         s.Color(0, startTime, startTime + duration, s.ColorAt(startTime), newColor);
     }
 }
        public Vector3 ToHSB(CommandColor c)
        {
            // Converts RGB color from c to HSB
            // Assumes rgb are 0..1
            // Probably will be obsolete once an actual
            // conversion or data struct is added for HSB

            var R = (float)c.R / 255;
            var G = (float)c.G / 255;
            var B = (float)c.B / 255;

            var cMax = Math.Max(R, G);

            cMax = Math.Max(cMax, B);
            var cMin = Math.Min(R, G);

            cMin = Math.Min(cMin, G);

            var delta = cMax - cMin;

            float h, s, b;

            // huehuehue
            if (delta == 0)
            {
                h = 0;
            }
            else if (cMax == R)
            {
                h = 60 * (((G - B) / delta) % 6);
            }
            else if (cMax == G)
            {
                h = 60 * (((B - R) / delta) + 2);
            }
            else
            {
                h = 60 * (((R - G) / delta) + 4);
            }

            // saturation
            if (cMax == 0)
            {
                s = 0;
            }
            else
            {
                s = delta / cMax;
            }

            // value
            b = cMax;

            return(new Vector3(h, s, b));
        }
        public void ColorRowCol(int startTime, int duration, int coord, CommandColor newColor, bool isCol)
        {
            // Colors a row or column.
            // Select the row/col to fill with coord to newColor.
            // isCol bool: row=0, col=1

            // OOB check
            if (coord < 0 ||
                coord > ((isCol) ? GridHeight : GridWidth))
            {
                return;
            }

            // Now get ready to fill that baby in.
            for (var b = 0; b < ((isCol) ? GridWidth : GridHeight); b++)
            {
                var s = (isCol) ? grid[b, coord] : grid[coord, b];
                s.Color(0, startTime, startTime + duration, s.ColorAt(startTime), newColor);
            }
        }
        public void ColorTriangle(int startTime, int duration, Vector2 coord, CommandColor newColor)
        {
            // Colors a single triangle at startTime for duration.
            // Select the triangle using the coord command.
            // It'll change to newColor.
            // To instantly change color, just set duration to 0.

            // Don't color if it's OOB.
            if (coord.X >= GridWidth ||
                coord.X < 0 ||
                coord.Y >= GridHeight ||
                coord.Y < 0)
            {
                return;
            }

            // But you made it here, so let's color.
            var s = grid[(int)coord.X, (int)coord.Y];

            s.Color(0, startTime, startTime + duration, s.ColorAt(startTime), newColor);
        }
Esempio n. 8
0
 public void ColorHsb(OsbEasing easing, double startTime, double endTime, double startHue, double startSaturation, double startBrightness, double endHue, double endSaturation, double endBrightness) => Color(easing, startTime, endTime, CommandColor.FromHsb(startHue, startSaturation, startBrightness), CommandColor.FromHsb(endHue, endSaturation, endBrightness));
Esempio n. 9
0
 public void Color(double time, CommandColor color) => Color(OsbEasing.None, time, time, color, color);
Esempio n. 10
0
 public void Color(double startTime, double endTime, CommandColor startColor, double endRed, double endGreen, double endBlue) => Color(OsbEasing.None, startTime, endTime, startColor, endRed, endGreen, endBlue);
Esempio n. 11
0
 public void Color(double startTime, double endTime, CommandColor startColor, CommandColor endColor) => Color(OsbEasing.None, startTime, endTime, startColor, endColor);
Esempio n. 12
0
 public void Color(OsbEasing easing, double startTime, double endTime, CommandColor startColor, double endRed, double endGreen, double endBlue) => Color(easing, startTime, endTime, startColor, new CommandColor(endRed, endGreen, endBlue));
Esempio n. 13
0
 public void Color(OsbEasing easing, double startTime, double endTime, CommandColor startColor, CommandColor endColor) => addCommand(new ColorCommand(easing, startTime, endTime, startColor, endColor));
        public void ShockwaveColor(float startTime, float stepTime, float delayTime, Vector2 target, CommandColor newColor, CommandColor ignoreColor, bool executeAsLoop)
        {
            // Creates a shockwave color point beginning at startTime.
            // The triangle closest to target becomes the first-point to flash from newColor -> baseColor.
            // Remaining triangles will flash as well after delayTime passes for each subsequent hit.
            // The triangles' order is based on the manhattan distance.
            // Also, we can set an ignoreColor that acts as a hard wall that the shockwave can't penetrate through.
            // We can also execute it as a loop, where it will execute the alt. shockcolor method. (but this is hacky, don't do it other than darenimo3)

            // Initialize the flags array, all as unmarked triangles.
            var flags = new bool [GridWidth, GridHeight];

            // What triangle in the grid would be closest to the target vector's coordinates?
            var closestX = 0;
            var closestY = 0;
            var closestD = float.MaxValue;

            for (int x = 0; x < GridWidth; x++)
            {
                for (int y = 0; y < GridHeight; y++)
                {
                    var curD = Distance(grid[x, y].PositionAt(startTime), target);
                    if (curD < closestD)
                    {
                        closestX = x; // New minimum found, so update the high score.
                        closestY = y;
                        closestD = curD;
                    }
                }
            }

            executeSprite shockColor     = delegate(OsbSprite s, float st, float step) { s.Color(0, st, st + step, newColor, s.ColorAt(st)); };
            executeSprite shockColorLoop = delegate(OsbSprite s, float st, float step) { s.StartLoopGroup(st, 4);
                                                                                         s.Color(OsbEasing.InBack, 0, step, newColor, s.ColorAt(st));
                                                                                         s.Fade(2400, 1);
                                                                                         s.EndGroup(); };
            querySprite shockWall = delegate(OsbSprite s, float st) { return(s.ColorAt(st) == ignoreColor); };

            // After this point, we should have found the best point to begin the shockwave. So let's do it!
            var startPoint = new Vector2(closestX, closestY);

            ShockwaveFill(startTime, stepTime, delayTime, startPoint, startPoint, flags, (executeAsLoop ? shockColorLoop : shockColor), shockWall);
        }
Esempio n. 15
0
 public Object3dState(Matrix4 worldTransform, CommandColor color, float opacity)
 {
     WorldTransform = worldTransform;
     Color          = color;
     Opacity        = opacity;
 }
Esempio n. 16
0
 public void ColorHsb(double startTime, double endTime, CommandColor startColor, double endHue, double endSaturation, double endBrightness) => ColorHsb(OsbEasing.None, startTime, endTime, startColor, endHue, endSaturation, endBrightness);
        public void ColorTopography(int startTime, int duration, CommandColor colorA, CommandColor colorB, int steps, Vector2 [] hotspot)
        {
            // Colors the hotspot areas with colorA,
            // and for every tile that isn't in the hotspot array,
            // color them towards colorB depending on the minimum Manhattan Distance
            // (i.e. the closest point)
            // Set duration to 0 for instant colorization
            // Ignore entries that are OOB. (Because they aren't in the grid when we are iterating anyway!)
            // However, we can do cool things like have partial colorations, so all is not lost.

            var difference = new Vector3((colorB.R - colorA.R),
                                         (colorB.G - colorA.G),
                                         (colorB.B - colorA.B));        // The difference between colorA and colorB
            var step = Vector3.Divide(difference, steps);               // Gives us the linear distribution per step

            for (int x = 0; x < GridWidth; x++)
            {
                for (int y = 0; y < GridHeight; y++)
                {
                    var curSpot = new Vector2(x, y);
                    if (Array.IndexOf(hotspot, curSpot) != -1)
                    {
                        // Is found in the hotspot array
                        // So that means we color that with colorA!
                        ColorTriangle(startTime, duration, curSpot, colorA);
                    }
                    else
                    {
                        // So we could not find it. Therefore, it'll be in some limbo or to colorB.
                        // Find the difference and have a vector that represents one step (similar to gradient)
                        // So first we need to figure out the minimum manhattan distance.
                        int minManhattan = int.MaxValue;

                        foreach (var point in hotspot)
                        {
                            var candidate = ManhattanDistance(curSpot, point);
                            if (candidate < minManhattan)
                            {
                                minManhattan = (int)candidate;
                            }
                        }

                        // Next up, calculate the color based on how many steps away...
                        var limboColor = new Vector3();
                        if (minManhattan >= steps)
                        {
                            limboColor = new Vector3(colorB.R, colorB.G, colorB.B);   // so far that it's pretty much colorB
                        }
                        else
                        {
                            limboColor = new Vector3(colorA.R, colorA.G, colorA.B) + Vector3.Multiply(step, minManhattan);
                        }

                        limboColor = Vector3.Divide(limboColor, 255);

                        // Finally, we can issue the color.
                        ColorTriangle(startTime, duration, curSpot, new CommandColor(limboColor));
                    }
                }
            }
        }
        public void VerseBackground()
        {
            // Goes for any of the verse sections.
            // Expects a triangle grid the size of... 40x10.
            // There are 8 measures of the verse, so every other measure we change colors.
            // Color change is random.
            // In the meantime, maybe a light light glitter.

            // Coolors are COOOOOL.
            var colorList = new CommandColor[5] {
                new CommandColor(39.0 / 255, 40.0 / 255, 56.0 / 255),
                new CommandColor(93.0 / 255, 83.0 / 255, 107.0 / 255),
                new CommandColor(125.0 / 255, 107.0 / 255, 145.0 / 255),
                new CommandColor(165.0 / 255, 148.0 / 255, 249.0 / 255),
                new CommandColor(52.0 / 255, 127.0 / 255, 196.0 / 255)
            };

            var hotSpots = new List <Vector2>();

            // Time to assign the hotspots that will actually be killed off.
            for (int i = GridWidth / 2 - GridWidth / 10; i < (GridWidth / 2 + GridWidth / 10) - 1; i++)
            {
                for (int j = GridHeight / 5; j < (GridHeight / 5) * 3; j++)
                {
                    hotSpots.Add(new Vector2(i - 2, j));
                }
            }

            var colorMarker       = Random(0, 4);
            var topographicPoints = 8;
            var greyMarker        = new Vector3((float)0.4, (float)0.4, (float)0.4);

            // Shockwave to kill off the hotspots.
            executeSprite killMe      = delegate(OsbSprite s, float st, float d) { s.ScaleVec(OsbEasing.OutBounce, st, st + d, s.ScaleAt(st), new CommandScale(0, (float)TriangleSize / baseSize)); };
            querySprite   isntHotSpot = delegate(OsbSprite s, float st) { return(s.ColorAt(st) != colorList[colorMarker]); };

            // OK so let's make the initial topography.
            ColorTopography(StartTime, 0, colorList[colorMarker], new CommandColor(greyMarker), topographicPoints, hotSpots.ToArray());
            Glitter(StartTime + 1, 600, 3);
            ScaleXYFlip(StartTime, 600, false, false);

            // Till death do you part.
            // TODO: Maybe get this to work or something.
            ShockwaveFill(StartTime + 600, 600, 75, hotSpots[0], new Vector2(320, 240), new bool[GridWidth, GridHeight], killMe, isntHotSpot);

            // Assign different colors.
            for (int i = 1; i < 4; i++)
            {
                // Update stuff
                colorMarker = (colorMarker + Random(1, 4)) % 5;
                greyMarker -= new Vector3((float)0.1, (float)0.1, (float)0.1);
                topographicPoints++;
                // And execute!
                ColorTopography(StartTime + (Duration / 4) * i - 600, 600, colorList[colorMarker], new CommandColor(greyMarker), topographicPoints, hotSpots.ToArray());
                Glitter(StartTime + (Duration / 4) * i, 600, 3);
            }


            // Bye bye.
            ScaleXYFlip(StartTime + Duration - 600, 600, true, false);
        }
Esempio n. 19
0
        //constructor
        public Browser()
        {
            InitializeComponent();

            //set up browser options from config file
            grip       = options.borderThickness;
            gripCorner = grip * 4;

            //create container for chromium browser
            container = new Container
            {
                Dock      = DockStyle.Fill,
                Padding   = Grip,
                BackColor = options.borderColor
            };
            Controls.Add(container);

            //create draggable toolbar
            toolbar = new Panel()
            {
                Dock      = DockStyle.Top,
                BackColor = options.toolbar.backgroundColor,
                ForeColor = options.toolbar.fontColor,
                Height    = options.toolbar.height
            };
            toolbar.DoubleClick += Toolbar_DoubleClick;
            toolbar.MouseDown   += Toolbar_MouseDown;
            toolbar.MouseMove   += Toolbar_MouseMove;
            toolbar.MouseUp     += Toolbar_MouseUp;
            Controls.Add(toolbar);

            //create controls for toolbar
            title           = new Label();
            title.Dock      = DockStyle.Left;
            title.TextAlign = ContentAlignment.MiddleLeft;
            title.Height    = options.toolbar.height;
            title.Padding   = options.toolbar.padding;
            title.Text      = options.title;
            title.Font      = new Font(options.toolbar.fontFamily, options.toolbar.fontSize, FontStyle.Regular);
            title.AutoSize  = true;
            toolbar.Controls.Add(title);

            //create maximize button
            buttonMinimize        = new MenuButton(ButtonType.minimize, options.button);
            buttonMinimize.Width  = options.button.width;
            buttonMinimize.Height = options.button.height;
            buttonMinimize.Dock   = DockStyle.Right;
            buttonMinimize.UpdateColors(options.button);
            buttonMinimize.Click += ButtonMinimize_Click;
            toolbar.Controls.Add(buttonMinimize);

            //create maximize button
            buttonMaximize        = new MenuButton(ButtonType.maximize, options.button);
            buttonMaximize.Width  = options.button.width;
            buttonMaximize.Height = options.button.height;
            buttonMaximize.Dock   = DockStyle.Right;
            buttonMaximize.UpdateColors(options.button);
            buttonMaximize.Click += ButtonMaximize_Click;
            toolbar.Controls.Add(buttonMaximize);

            //create close button
            buttonClose        = new MenuButton(ButtonType.close, options.button);
            buttonClose.Width  = options.button.width;
            buttonClose.Height = options.button.height;
            buttonClose.Dock   = DockStyle.Right;
            buttonClose.UpdateColors(options.button);
            buttonClose.Click += ButtonClose_Click;
            toolbar.Controls.Add(buttonClose);

            //load default theme
            DefaultTheme();

            //set up browser settings
            var paths    = Application.LocalUserAppDataPath.Split('\\');
            var dataPath = string.Join("\\", paths.Take(paths.Length - 1)) + "\\";
            var settings = new CefSettings()
            {
                CachePath   = dataPath + "Profile\\",
                LogSeverity = LogSeverity.Disable
            };
            var browserSettings = new BrowserSettings()
            {
                BackgroundColor = Utility.ColorToUInt(Color.FromArgb(35, 35, 35))
            };

            //delete cache (optional)
            if (Utility.IsDebugMode == true && Directory.Exists(dataPath + "Profile\\Cache"))
            {
                FileSystem.DeleteDirectory(dataPath + "Profile\\Cache");
            }

            //add command line arguments when creating web browser
            var cmdArgs = settings.CefCommandLineArgs;

            cmdArgs.Add("disable-plugin-discovery", "1");
            cmdArgs.Add("disable-direct-write", "1");

            Cef.Initialize(settings);
            Cef.EnableHighDPISupport();
            browser = new ChromiumWebBrowser(options.url)
            {
                Dock        = DockStyle.Fill,
                BackColor   = options.borderColor,
                MenuHandler = new CustomMenuHandler()
            };
            browser.BrowserSettings = browserSettings;
            container.Controls.Add(browser);

            //set up browser internal events
            browser.IsBrowserInitializedChanged += (object sender, IsBrowserInitializedChangedEventArgs e) =>
            {
                if (e.IsBrowserInitialized == true)
                {
                    //show DevTools
                    if (options.showDevTools == true)
                    {
                        browser.ShowDevTools();
                    }
                }
            };
            browser.TitleChanged += (object sender, TitleChangedEventArgs e) =>
            {
                Invoke(changeTitle, e.Title);
            };

            //set up form window
            events         = new JsEvents();
            DoubleBuffered = true;
            SetStyle(ControlStyles.ResizeRedraw, true);

            //bind delegates for cross-thread purposes
            maximize            = new Command(MaximizeWindow);
            normalize           = new Command(NormalizeWindow);
            minimize            = new Command(MinimizeWindow);
            drag                = new Command(DragWindow);
            borderColor         = new CommandColor(BorderColor);
            toolbarColor        = new CommandColor(ToolbarColor);
            toolbarFontColor    = new CommandColor(ToolbarFontColor);
            toolbarButtonColors = new CommandButtonColors(ToolbarButtonColors);
            changeGripSize      = new CommandInt(ChangeGripSize);
            newwindow           = new Command(NewWindow);
            exit                = new Command(Exit);
            defaultTheme        = new Command(DefaultTheme);
            changeTitle         = new CommandStr(ChangeTitle);

            //bind JsEvents instance to JavaScript
            browser.JavascriptObjectRepository.Register("Rhino", events, false);
        }