Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Capabilities"/> class.
 /// </summary>
 /// <param name="supportsAnsi">Whether or not ANSI escape sequences are supported.</param>
 /// <param name="colorSystem">The color system that is supported.</param>
 /// <param name="legacyConsole">Whether or not this is a legacy console.</param>
 /// <param name="supportsInteraction">Whether or not the console supports interaction.</param>
 public Capabilities(bool supportsAnsi, ColorSystem colorSystem, bool legacyConsole, bool supportsInteraction)
 {
     SupportsAnsi        = supportsAnsi;
     ColorSystem         = colorSystem;
     LegacyConsole       = legacyConsole;
     SupportsInteraction = supportsInteraction;
 }
Exemplo n.º 2
0
        public FakeAnsiConsole(
            ColorSystem colors,
            AnsiSupport ansi = AnsiSupport.Yes,
            int width        = 80)
        {
            _exclusivityLock = new FakeExclusivityMode();
            _writer          = new StringWriter();

            var factory = new AnsiConsoleFactory();

            _console = factory.Create(new AnsiConsoleSettings
            {
                Ansi        = ansi,
                ColorSystem = (ColorSystemSupport)colors,
                Out         = _writer,
                Enrichment  = new ProfileEnrichment
                {
                    UseDefaultEnrichers = false,
                },
            });

            _console.Profile.Width = width;
            _console.Profile.Capabilities.Unicode = true;

            Input = new FakeConsoleInput();
        }
        /*                          GAMMA_CORRECT_RGB
         *
         *  Transform linear RGB values to nonlinear RGB values. Rec.
         *  709 is ITU-R Recommendation BT. 709 (1990) ``Basic
         *  Parameter Values for the HDTV Standard for the Studio and
         *  for International Programme Exchange'', formerly CCIR Rec.
         *  709. For details see
         *
         *     http://www.poynton.com/ColorFAQ.html
         *     http://www.poynton.com/GammaFAQ.html
         */

        public void gamma_correct(ColorSystem cs, ref float c)
        {
            float gamma;

            gamma = cs.gamma;

            if (gamma == GAMMA_REC709)
            {
                /* Rec. 709 gamma correction. */
                float cc = 0.018f;

                if (c < cc)
                {
                    c *= ((1.099f * Mathf.Pow(cc, 0.45f)) - 0.099f) / cc;
                }
                else
                {
                    c = (1.099f * Mathf.Pow(c, 0.45f)) - 0.099f;
                }
            }
            else
            {
                /* Nonlinear colour = (Linear colour)^(1/gamma) */
                c = Mathf.Pow(c, 1.0f / gamma);
            }
        }
        public void Should_Be_Analog_To_ColorSystemSupport(ColorSystem colors, ColorSystemSupport support)
        {
            // Given, When
            var result = (int)colors;

            // Then
            result.ShouldBe((int)support);
        }
Exemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     colorSystem              = FindObjectOfType <ColorSystem>().GetComponent <ColorSystem>();
     speedControl             = FindObjectOfType <SoccerSpeedControl>().GetComponent <SoccerSpeedControl>();
     controllPoint            = FindObjectOfType <ControlPoint>().GetComponent <ControlPoint>();
     colorSystem.movingObject = gameObject;
     rb = gameObject.GetComponent <Rigidbody>();
 }
Exemplo n.º 6
0
        private RenderContext(ColorSystem colorSystem, IReadOnlyCapabilities capabilities, Justify?justification = null, bool singleLine = false)
        {
            _capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));

            ColorSystem   = colorSystem;
            Justification = justification;
            SingleLine    = singleLine;
        }
Exemplo n.º 7
0
        public AnsiConsoleRenderer(TextWriter @out, ColorSystem system, bool legacyConsole)
        {
            _out    = @out ?? throw new ArgumentNullException(nameof(@out));
            _system = system;

            Capabilities = new Capabilities(true, system, legacyConsole);
            Encoding     = @out.IsStandardOut() ? System.Console.OutputEncoding : Encoding.UTF8;
            Foreground   = Color.Default;
            Background   = Color.Default;
            Decoration   = Decoration.None;
        }
Exemplo n.º 8
0
 public static IEnumerable <byte> GetAnsiCodes(ColorSystem system, Color color, bool foreground)
 {
     return(system switch
     {
         ColorSystem.NoColors => Array.Empty <byte>(),             // No colors
         ColorSystem.TrueColor => GetTrueColor(color, foreground), // 24-bit
         ColorSystem.EightBit => GetEightBit(color, foreground),   // 8-bit
         ColorSystem.Standard => GetFourBit(color, foreground),    // 4-bit
         ColorSystem.Legacy => GetThreeBit(color, foreground),     // 3-bit
         _ => throw new InvalidOperationException("Could not determine ANSI color."),
     });
Exemplo n.º 9
0
 public PlainConsole(
     int width          = 80, int height = 9000, Encoding encoding = null,
     bool supportsAnsi  = true, ColorSystem colorSystem = ColorSystem.Standard,
     bool legacyConsole = false)
 {
     Capabilities = new Capabilities(supportsAnsi, colorSystem, legacyConsole);
     Encoding     = encoding ?? Encoding.UTF8;
     Width        = width;
     Height       = height;
     Writer       = new StringWriter();
 }
Exemplo n.º 10
0
        public AnsiConsoleFixture(ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes, int width = 80)
        {
            _writer = new StringWriter();

            Console = new ConsoleWithWidth(
                AnsiConsole.Create(new AnsiConsoleSettings
            {
                Ansi        = ansi,
                ColorSystem = (ColorSystemSupport)system,
                Out         = _writer,
            }), width);
        }
Exemplo n.º 11
0
        public MarkupConsoleFixture(ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes, int width = 80)
        {
            _writer  = new StringWriter();
            _console = AnsiConsole.Create(new AnsiConsoleSettings
            {
                Ansi                  = ansi,
                ColorSystem           = (ColorSystemSupport)system,
                Out                   = _writer,
                LinkIdentityGenerator = new TestLinkIdentityGenerator(),
            });

            Width = width;
        }
Exemplo n.º 12
0
 public FakeConsole(
     int width = 80, int height = 9000, Encoding encoding = null,
     bool supportsAnsi = true, ColorSystem colorSystem = ColorSystem.Standard,
     bool legacyConsole = false, bool interactive = true)
 {
     Capabilities = new Capabilities(supportsAnsi, colorSystem, legacyConsole, interactive);
     Encoding = encoding ?? Encoding.UTF8;
     Width = width;
     Height = height;
     Writer = new StringWriter();
     Input = new FakeConsoleInput();
     Pipeline = new RenderPipeline();
 }
Exemplo n.º 13
0
 public ColorManager(Corel.Interop.VGCore.Palette palette)
 {
     if (palette == null)
     {
         return;
     }
     PaletteName = palette.Name;
     colorArray  = new ColorSystem[palette.ColorCount];
     for (int i = 1; i < palette.ColorCount; i++)
     {
         Corel.Interop.VGCore.Color color = palette.Color[i];
         colorArray[i - 1] = new ColorSystem(color.HexValue, color.Name, color);
     }
 }
Exemplo n.º 14
0
        private static Color Closest(ColorSystem system, Color color)
        {
            if (system == ColorSystem.TrueColor)
            {
                return(color);
            }

            var palette = system switch
            {
                ColorSystem.Legacy => Legacy,
                ColorSystem.Standard => Standard,
                ColorSystem.EightBit => EightBit,
                _ => throw new NotSupportedException(),
            };
    void Awake()
    {
        nodeManager      = GetComponent <NodeManager>();
        gridSys          = GetComponent <GridSystem>();
        coverObjManager  = GetComponent <CoverObjectManager>();
        colorSys         = GetComponent <ColorSystem>();
        inputSys         = GetComponent <InputSystem>();
        scoreSys         = GetComponent <Score>();
        moveSys          = GetComponent <MoveSystem>();
        bombSys          = GetComponent <BombSystem>();
        explosionManager = GetComponent <ExplosionManager>();
        uiManager        = GetComponent <UIManager>();

        instance = this;
    }
Exemplo n.º 16
0
 // Start is called before the first frame update
 void Start()
 {
     // Initial variables assignment
     instance = this;
     // Initialize color dictionary
     colorsDict = new Dictionary <string, GameObject>()
     {
         { "", colors[0] },              //None
         { "n", colors[1] },             //Black
         { "b", colors[2] },             //Blue
         { "y", colors[3] },             //Yellow
         { "r", colors[4] },             //Red
         { "by", colors[5] },            //Green
         { "yb", colors[5] },            //Green
         { "yr", colors[6] },            //Orange
         { "ry", colors[6] },            //Orange
         { "br", colors[7] },            //Violet
         { "rb", colors[7] },            //Violet
         { "bbr", colors[8] },           //Blue-Violet
         { "brb", colors[8] },           //Blue-Violet
         { "rbb", colors[8] },           //Blue-Violet
         { "yrbbr", colors[9] },         //Brown
         { "yrbrb", colors[9] },         //Brown
         { "yrrbb", colors[9] },         //Brown
         { "rybbr", colors[9] },         //Brown
         { "rybrb", colors[9] },         //Brown
         { "ryrbb", colors[9] },         //Brown
         { "byr", colors[10] },          //White
         { "bry", colors[10] },          //White
         { "ybr", colors[10] },          //White
         { "rby", colors[10] },          //White
         { "ryb", colors[10] },          //White
         { "nbyr", colors[11] },
         { "nbry", colors[11] },
         { "nybr", colors[11] },
         { "nrby", colors[11] },
         { "nryb", colors[11] },
         { "byrn", colors[11] },
         { "bryn", colors[11] },
         { "ybrn", colors[11] },
         { "rbyn", colors[11] },
         { "rybn", colors[11] }
     };
     // Set black as default color
     currentSearch = "";
 }
Exemplo n.º 17
0
        public FakeConsole(
            int width          = 80, int height = 9000, Encoding encoding = null,
            bool supportsAnsi  = true, ColorSystem colorSystem = ColorSystem.Standard,
            bool legacyConsole = false, bool interactive       = true)
        {
            Input    = new FakeConsoleInput();
            Pipeline = new RenderPipeline();

            Profile                          = new Profile(new StringWriter(), encoding ?? Encoding.UTF8);
            Profile.Width                    = width;
            Profile.Height                   = height;
            Profile.ColorSystem              = colorSystem;
            Profile.Capabilities.Ansi        = supportsAnsi;
            Profile.Capabilities.Legacy      = legacyConsole;
            Profile.Capabilities.Interactive = interactive;
            Profile.Capabilities.Links       = true;
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        ColorSystem targett = (ColorSystem)target;

        if (targett.colorsSc != null)
        {
            count = targett.colorsSc.Colorz.Count;

            EditorGUILayout.BeginHorizontal();

            count = EditorGUILayout.IntField("Color Count : ", count);
            EditorGUILayout.EndHorizontal();
            if (count != targett.colorsSc.Colorz.Count)
            {
                int ccc;
                if (count > targett.colorsSc.Colorz.Count)
                {
                    if (targett.colorsSc.Colorz.Count == 0)
                    {
                        targett.colorsSc.Colorz.Add(Color.black);
                    }
                    ccc = (count - targett.colorsSc.Colorz.Count);
                    for (int i = 0; i < ccc; i++)
                    {
                        targett.colorsSc.Colorz.Add(targett.colorsSc.Colorz[targett.colorsSc.Colorz.Count - 1]);
                    }
                }
                else
                {
                    ccc = (targett.colorsSc.Colorz.Count - count);
                    for (int i = 0; i < ccc; i++)
                    {
                        targett.colorsSc.Colorz.RemoveAt(targett.colorsSc.Colorz.Count - 1);
                    }
                }
            }
            for (int i = 0; i < targett.colorsSc.Colorz.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                targett.colorsSc.Colorz[i] = EditorGUILayout.ColorField("Color " + i.ToString() + ": ", targett.colorsSc.Colorz[i]);
                EditorGUILayout.EndHorizontal();
            }
        }
        EditorUtility.SetDirty(targett.colorsSc);
    }
Exemplo n.º 19
0
        public FallbackBackend(TextWriter @out, Capabilities capabilities)
        {
            if (capabilities == null)
            {
                throw new ArgumentNullException(nameof(capabilities));
            }

            _system = capabilities.ColorSystem;
            _cursor = new FallbackCursor();

            if (@out != System.Console.Out)
            {
                System.Console.SetOut(@out ?? throw new ArgumentNullException(nameof(@out)));
            }

            Encoding     = System.Console.OutputEncoding;
            Capabilities = capabilities;
        }
Exemplo n.º 20
0
        public FakeAnsiConsole(
            ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes,
            InteractionSupport interaction       = InteractionSupport.Yes,
            int width = 80)
        {
            _writer  = new StringWriter();
            _console = AnsiConsole.Create(new AnsiConsoleSettings
            {
                Ansi                  = ansi,
                ColorSystem           = (ColorSystemSupport)system,
                Interactive           = interaction,
                Out                   = _writer,
                LinkIdentityGenerator = new FakeLinkIdentityGenerator(1024),
            });

            Width = width;
            Input = new FakeConsoleInput();
        }
Exemplo n.º 21
0
    // Update is called once per frame
    void Update()
    {
        try
        {
            change = FindObjectOfType <ColorSystem>().GetComponent <ColorSystem>();
            player = change.newSelect.gameObject.GetComponent <Rigidbody>();
            this.gameObject.transform.position = player.position;
            //If Clicked mouse button
            if (Input.GetMouseButton(0))
            {
                //Get mouse click start position . If it is (0,0,0) . Don't show line .
                //Need to click on the object to drag and release.
                if (change.newSelect.tag == "Player" || change.newSelect.tag == "Enemy")
                {
                    if (change.newSelect.tag == "Player")
                    {
                        line.gameObject.GetComponent <LineRenderer>().colorGradient = blueTeamColor;
                    }
                    else if (change.newSelect.tag == "Enemy")
                    {
                        line.gameObject.GetComponent <LineRenderer>().colorGradient = redTeamColor;
                    }

                    MousePosition();
                    line.gameObject.SetActive(true);
                    line.SetPosition(0, transform.position);
                    //Maximum the Line Length from 5 to 27 to avoid too short or too long.
                    line.SetPosition(1, transform.position + transform.forward * Mathf.Clamp(lineLength, 5, 20));
                    //Debug.LogWarning("Line Length : " + lineLength);
                }
                else
                {
                    line.gameObject.SetActive(false);
                    return;
                }
            }
        }
        catch
        {
            //Debug uses
        }
    }
Exemplo n.º 22
0
        private static Color?Exact(ColorSystem system, Color color)
        {
            if (system == ColorSystem.TrueColor)
            {
                return(color);
            }

            var palette = system switch
            {
                ColorSystem.Legacy => Legacy,
                ColorSystem.Standard => Standard,
                ColorSystem.EightBit => EightBit,
                _ => throw new NotSupportedException(),
            };

            return(palette
                   .Where(c => c.Equals(color))
                   .Cast <Color?>()
                   .FirstOrDefault());
        }
        /*                             XYZ_TO_RGB
         *
         *  Given an additive tricolour system CS, defined by the CIE x
         *  and y chromaticities of its three primaries (z is derived
         *  trivially as 1-(x+y)), and a desired chromaticity (XC, YC,
         *  ZC) in CIE space, determine the contribution of each
         *  primary in a linear combination which sums to the desired
         *  chromaticity.  If the  requested chromaticity falls outside
         *  the Maxwell  triangle (colour gamut) formed by the three
         *  primaries, one of the r, g, or b weights will be negative.
         *
         *  Caller can use constrain_rgb() to desaturate an
         *  outside-gamut colour to the closest representation within
         *  the available gamut and/or norm_rgb to normalise the RGB
         *  components so the largest nonzero component has value 1.
         *
         */

        public void xyz_to_rgb(
            ColorSystem cs,
            float xc, float yc, float zc,
            out float r, out float g, out float b)
        {
            float xr, yr, zr, xg, yg, zg, xb, yb, zb;
            float xw, yw, zw;
            float rx, ry, rz, gx, gy, gz, bx, by, bz;
            float rw, gw, bw;

            xr = cs.xRed; yr = cs.yRed; zr = 1 - (xr + yr);
            xg = cs.xGreen; yg = cs.yGreen; zg = 1 - (xg + yg);
            xb = cs.xBlue; yb = cs.yBlue; zb = 1 - (xb + yb);

            xw = cs.xWhite; yw = cs.yWhite; zw = 1 - (xw + yw);

            /* xyz -> rgb matrix, before scaling to white. */

            rx = (yg * zb) - (yb * zg); ry = (xb * zg) - (xg * zb); rz = (xg * yb) - (xb * yg);
            gx = (yb * zr) - (yr * zb); gy = (xr * zb) - (xb * zr); gz = (xb * yr) - (xr * yb);
            bx = (yr * zg) - (yg * zr); by = (xg * zr) - (xr * zg); bz = (xr * yg) - (xg * yr);

            /* White scaling factors.
             * Dividing by yw scales the white luminance to unity, as conventional. */

            rw = ((rx * xw) + (ry * yw) + (rz * zw)) / yw;
            gw = ((gx * xw) + (gy * yw) + (gz * zw)) / yw;
            bw = ((bx * xw) + (by * yw) + (bz * zw)) / yw;

            /* xyz -> rgb matrix, correctly scaled to white. */

            rx = rx / rw; ry = ry / rw; rz = rz / rw;
            gx = gx / gw; gy = gy / gw; gz = gz / gw;
            bx = bx / bw; by = by / bw; bz = bz / bw;

            /* rgb of the desired point */

            r = (rx * xc) + (ry * yc) + (rz * zc);
            g = (gx * xc) + (gy * yc) + (gz * zc);
            b = (bx * xc) + (by * yc) + (bz * zc);
        }
Exemplo n.º 24
0
        public FallbackConsoleRenderer(TextWriter @out, Capabilities capabilities)
        {
            if (capabilities == null)
            {
                throw new ArgumentNullException(nameof(capabilities));
            }

            _out    = @out ?? throw new ArgumentNullException(nameof(@out));
            _system = capabilities.ColorSystem;

            if (_out.IsStandardOut())
            {
                Encoding = System.Console.OutputEncoding;
            }
            else
            {
                Encoding = Encoding.UTF8;
            }

            Capabilities = capabilities;
        }
Exemplo n.º 25
0
        public static string GetAnsi(
            ColorSystem system,
            string text,
            Decoration decoration,
            Color foreground,
            Color background)
        {
            var codes = AnsiDecorationBuilder.GetAnsiCodes(decoration);

            // Got foreground?
            if (foreground != Color.Default)
            {
                codes = codes.Concat(AnsiColorBuilder.GetAnsiCodes(system, foreground, foreground: true));
            }

            // Got background?
            if (background != Color.Default)
            {
                codes = codes.Concat(AnsiColorBuilder.GetAnsiCodes(system, background, foreground: false));
            }

            var result = codes.ToArray();

            if (result.Length == 0)
            {
                return(text);
            }

            var lol = string.Concat(
                "\u001b[",
                string.Join(";", result),
                "m",
                text,
                "\u001b[0m");

            return(lol);
        }
Exemplo n.º 26
0
        public FakeAnsiConsole(
            ColorSystem system,
            AnsiSupport ansi = AnsiSupport.Yes,
            int width        = 80)
        {
            _writer = new StringWriter();

            var factory = new AnsiConsoleFactory();

            _console = factory.Create(new AnsiConsoleSettings
            {
                Ansi        = ansi,
                ColorSystem = (ColorSystemSupport)system,
                Out         = _writer,
                Enrichment  = new ProfileEnrichment
                {
                    UseDefaultEnrichers = false,
                },
            });

            _console.Profile.Width = width;

            Input = new FakeConsoleInput();
        }
 public void gamma_correct_rgb(ColorSystem cs, ref float r, ref float g, ref float b)
 {
     gamma_correct(cs, ref r);
     gamma_correct(cs, ref g);
     gamma_correct(cs, ref b);
 }
Exemplo n.º 28
0
 private void SetSelectedColor(ColorSystem color)
 {
     SelectedColor = color;
 }
    public void Should_Create_Console_With_Requested_ColorSystem(ColorSystemSupport requested, ColorSystem expected)
    {
        // Given, When
        var console = AnsiConsole.Create(new AnsiConsoleSettings
        {
            ColorSystem = requested,
            Out         = new AnsiConsoleOutput(new StringWriter()),
        });

        // Then
        console.Profile.Capabilities.ColorSystem.ShouldBe(expected);
    }
Exemplo n.º 30
0
 /// <summary>
 /// Checks whether the current capabilities supports
 /// the specified color system.
 /// </summary>
 /// <param name="colorSystem">The color system to check.</param>
 /// <returns><c>true</c> if the color system is supported, otherwise <c>false</c>.</returns>
 public bool Supports(ColorSystem colorSystem)
 {
     return((int)colorSystem <= (int)ColorSystem);
 }