コード例 #1
0
 protected Figure(TColor color, int[,] body, TetrisGameBoard board)
 {
     Color           = color;
     _body           = (int[, ])body.Clone();
     Board           = board;
     _correctionTurn = 0;
 }
コード例 #2
0
ファイル: OctreeQuantizer.cs プロジェクト: xjlonly/ImageSharp
            /// <summary>
            /// Add a given color value to the Octree
            /// </summary>
            /// <param name="pixel">
            /// The <see cref="TColor"/>containing color information to add.
            /// </param>
            public void AddColor(TColor pixel)
            {
                TPacked packed = pixel.PackedValue;

                // Check if this request is for the same color as the last
                if (this.previousColor.Equals(packed))
                {
                    // If so, check if I have a previous node setup. This will only occur if the first color in the image
                    // happens to be black, with an alpha component of zero.
                    if (this.previousNode == null)
                    {
                        this.previousColor = packed;
                        this.root.AddColor(pixel, this.maxColorBits, 0, this);
                    }
                    else
                    {
                        // Just update the previous node
                        this.previousNode.Increment(pixel);
                    }
                }
                else
                {
                    this.previousColor = packed;
                    this.root.AddColor(pixel, this.maxColorBits, 0, this);
                }
            }
コード例 #3
0
ファイル: OctreeQuantizer.cs プロジェクト: xjlonly/ImageSharp
                /// <summary>
                /// Add a color into the tree
                /// </summary>
                /// <param name="pixel">The color</param>
                /// <param name="colorBits">The number of significant color bits</param>
                /// <param name="level">The level in the tree</param>
                /// <param name="octree">The tree to which this node belongs</param>
                public void AddColor(TColor pixel, int colorBits, int level, Octree octree)
                {
                    // Update the color information if this is a leaf
                    if (this.leaf)
                    {
                        this.Increment(pixel);

                        // Setup the previous node
                        octree.TrackPrevious(this);
                    }
                    else
                    {
                        // Go to the next level down in the tree
                        int   shift = 7 - level;
                        Color color = new Color(pixel.ToVector4());
                        int   index = ((color.A & Mask[0]) >> (shift - 3)) |
                                      ((color.B & Mask[level + 1]) >> (shift - 2)) |
                                      ((color.G & Mask[level + 1]) >> (shift - 1)) |
                                      ((color.R & Mask[level + 1]) >> shift);

                        OctreeNode child = this.children[index];

                        if (child == null)
                        {
                            // Create a new child node and store it in the array
                            child = new OctreeNode(level + 1, colorBits, octree);
                            this.children[index] = child;
                        }

                        // Add the color to the child node
                        child.AddColor(pixel, colorBits, level + 1, octree);
                    }
                }
コード例 #4
0
        public virtual void Create(int width, int height, TColor clearColor, string htmlDocument)
        {
            Canvas    = GfxFactory.Create <IGfxCanvas>();
            GfxServer = GfxFactory.Create <IGfxServer>();
            GfxServer.Initialize(width, height, clearColor);

            Width  = width;
            Height = height;

            var domFactory = new TDomFactory();

            Document = domFactory.Create <IDocument>();
            Document.Parse(htmlDocument);

            // Create the canvas. Need a canvas for the screen. For example,
            // the screen render the mouse cursor. Because it render something,
            // we need a Canvas.
            // As you can see, this is a hack, because, normally, every
            // control create it's own canvas in TControl::Create(). But
            // we skip the base class initialization, so need to create the
            // canvas by hand.

            //Canvas = new TCanvas(this);

            //SetBounds(Rect.left, Rect.top, Rect.right, Rect.bottom);#
        }
コード例 #5
0
                /// <summary>
                /// Add a color into the tree
                /// </summary>
                /// <param name="pixel">The color</param>
                /// <param name="colorBits">The number of significant color bits</param>
                /// <param name="level">The level in the tree</param>
                /// <param name="octree">The tree to which this node belongs</param>
                /// <param name="buffer">The buffer array.</param>
                public void AddColor(TColor pixel, int colorBits, int level, Octree octree, byte[] buffer)
                {
                    // Update the color information if this is a leaf
                    if (this.leaf)
                    {
                        this.Increment(pixel, buffer);

                        // Setup the previous node
                        octree.TrackPrevious(this);
                    }
                    else
                    {
                        // Go to the next level down in the tree
                        int shift = 7 - level;
                        pixel.ToXyzwBytes(buffer, 0);

                        int index = ((buffer[3] & Mask[0]) >> (shift - 3)) |
                                    ((buffer[2] & Mask[level + 1]) >> (shift - 2)) |
                                    ((buffer[1] & Mask[level + 1]) >> (shift - 1)) |
                                    ((buffer[0] & Mask[level + 1]) >> shift);

                        OctreeNode child = this.children[index];

                        if (child == null)
                        {
                            // Create a new child node and store it in the array
                            child = new OctreeNode(level + 1, colorBits, octree);
                            this.children[index] = child;
                        }

                        // Add the color to the child node
                        child.AddColor(pixel, colorBits, level + 1, octree, buffer);
                    }
                }
コード例 #6
0
                /// <summary>
                /// Traverse the tree, building up the color palette
                /// </summary>
                /// <param name="palette">The palette</param>
                /// <param name="index">The current palette index</param>
                public void ConstructPalette(TColor[] palette, ref int index)
                {
                    if (this.leaf)
                    {
                        // This seems faster than using Vector4
                        byte r = (this.red / this.pixelCount).ToByte();
                        byte g = (this.green / this.pixelCount).ToByte();
                        byte b = (this.blue / this.pixelCount).ToByte();
                        byte a = (this.alpha / this.pixelCount).ToByte();

                        // And set the color of the palette entry
                        TColor pixel = default(TColor);
                        pixel.PackFromBytes(r, g, b, a);
                        palette[index] = pixel;

                        // Consume the next palette index
                        this.paletteIndex = index++;
                    }
                    else
                    {
                        // Loop through children looking for leaves
                        for (int i = 0; i < 8; i++)
                        {
                            if (this.children[i] != null)
                            {
                                this.children[i].ConstructPalette(palette, ref index);
                            }
                        }
                    }
                }
コード例 #7
0
ファイル: StartUpScreen.cs プロジェクト: TendoSoSoft/FIVE
        protected override void UpdateLoadingProgressBar()
        {
            if (TColor == null)
            {
                return;
            }

            float tAmount  = 0f;
            float s1Amount = 0f;
            float s2Amount = 0f;

            if (Progress < 1 / 3f)
            {
                tAmount = Progress * 3f;
            }
            else if (Progress < 2 / 3f)
            {
                tAmount  = 1f;
                s1Amount = Progress * 3f - 1f;
            }
            else
            {
                tAmount  = 1f;
                s1Amount = 1f;
                s2Amount = Progress * 3f - 2f;
            }

            TColor.GetComponent <Image>().fillAmount  = tAmount;
            S1Color.GetComponent <Image>().fillAmount = s1Amount;
            S2Color.GetComponent <Image>().fillAmount = s2Amount;
            if (Math.Abs(Progress - 1) < float.Epsilon)
            {
                DoFadingOut();
            }
        }
コード例 #8
0
                /// <summary>
                /// Return the palette index for the passed color
                /// </summary>
                /// <param name="pixel">The pixel data.</param>
                /// <param name="level">The level.</param>
                /// <param name="buffer">The buffer array.</param>
                /// <returns>
                /// The <see cref="int"/> representing the index of the pixel in the palette.
                /// </returns>
                public int GetPaletteIndex(TColor pixel, int level, byte[] buffer)
                {
                    int index = this.paletteIndex;

                    if (!this.leaf)
                    {
                        int shift = 7 - level;
                        pixel.ToXyzwBytes(buffer, 0);

                        int pixelIndex = ((buffer[3] & Mask[0]) >> (shift - 3)) |
                                         ((buffer[2] & Mask[level + 1]) >> (shift - 2)) |
                                         ((buffer[1] & Mask[level + 1]) >> (shift - 1)) |
                                         ((buffer[0] & Mask[level + 1]) >> shift);

                        if (this.children[pixelIndex] != null)
                        {
                            index = this.children[pixelIndex].GetPaletteIndex(pixel, level + 1, buffer);
                        }
                        else
                        {
                            throw new Exception($"Cannot retrive a pixel at the given index {pixelIndex}.");
                        }
                    }

                    return(index);
                }
コード例 #9
0
        private void GetField(int idField, TetrisGameBoard board)
        {
            BoardPoint[,] result = new BoardPoint[board.Width, board.Height];
            SqlCommand comm = GetCommand("GetPoints");

            comm.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@idField", DbType = DbType.Int32, Value = idField
            });
            DataTable table = new DataTable();

            table.Load(comm.ExecuteReader());

            if (table.Rows.Count != 0)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    var    row = table.Rows[i];
                    TColor col = (TColor)row[0];
                    byte   x   = (byte)row[1];
                    byte   y   = (byte)row[2];
                    result[x, y] = new BoardPoint(col);
                }
                board.Field = result;
            }
        }
コード例 #10
0
ファイル: OctreeQuantizer.cs プロジェクト: xjlonly/ImageSharp
                /// <summary>
                /// Return the palette index for the passed color
                /// </summary>
                /// <param name="pixel">The <see cref="TColor"/> representing the pixel.</param>
                /// <param name="level">The level.</param>
                /// <returns>
                /// The <see cref="int"/> representing the index of the pixel in the palette.
                /// </returns>
                public int GetPaletteIndex(TColor pixel, int level)
                {
                    int index = this.paletteIndex;

                    if (!this.leaf)
                    {
                        int   shift      = 7 - level;
                        Color color      = new Color(pixel.ToVector4());
                        int   pixelIndex = ((color.A & Mask[0]) >> (shift - 3)) |
                                           ((color.B & Mask[level + 1]) >> (shift - 2)) |
                                           ((color.G & Mask[level + 1]) >> (shift - 1)) |
                                           ((color.R & Mask[level + 1]) >> shift);

                        if (this.children[pixelIndex] != null)
                        {
                            index = this.children[pixelIndex].GetPaletteIndex(pixel, level + 1);
                        }
                        else
                        {
                            throw new Exception($"Cannot retrive a pixel at the given index {pixelIndex}.");
                        }
                    }

                    return(index);
                }
コード例 #11
0
ファイル: OctreeQuantizer.cs プロジェクト: xjlonly/ImageSharp
                /// <summary>
                /// Traverse the tree, building up the color palette
                /// </summary>
                /// <param name="palette">The palette</param>
                /// <param name="index">The current palette index</param>
                public void ConstructPalette(List <TColor> palette, ref int index)
                {
                    if (this.leaf)
                    {
                        // Consume the next palette index
                        this.paletteIndex = index++;

                        byte r = (this.red / this.pixelCount).ToByte();
                        byte g = (this.green / this.pixelCount).ToByte();
                        byte b = (this.blue / this.pixelCount).ToByte();
                        byte a = (this.alpha / this.pixelCount).ToByte();

                        // And set the color of the palette entry
                        TColor pixel = default(TColor);
                        pixel.PackFromVector4(new Color(r, g, b, a).ToVector4());
                        palette.Add(pixel);
                    }
                    else
                    {
                        // Loop through children looking for leaves
                        for (int i = 0; i < 8; i++)
                        {
                            if (this.children[i] != null)
                            {
                                this.children[i].ConstructPalette(palette, ref index);
                            }
                        }
                    }
                }
コード例 #12
0
 /// <summary>
 /// Increment the pixel count and add to the color information
 /// </summary>
 /// <param name="pixel">The pixel to add.</param>
 /// <param name="buffer">The buffer array.</param>
 public void Increment(TColor pixel, byte[] buffer)
 {
     pixel.ToXyzwBytes(buffer, 0);
     this.pixelCount++;
     this.red   += buffer[0];
     this.green += buffer[1];
     this.blue  += buffer[2];
 }
コード例 #13
0
ファイル: Classes.cs プロジェクト: Alenavski/OOTPiSP
 public CatalogItem(string name, string cloth, int length, double price, TColor color)
 {
     this.Name   = name;
     this.Cloth  = cloth;
     this.Length = length;
     this.Price  = price;
     this.Color  = color;
 }
コード例 #14
0
        private void w64SetPixel(byte[] raw, int x, int y, TColor color)
        {
            var val    = (int)color;
            int offset = (8 * (y / 8) + (x / 8)) * 32 + 4 * (y % 8) + (x % 8) / 2;
            int nibble = x & 1;

            raw[offset] &= (byte)~(0x0F << (4 * nibble));
            raw[offset] |= (byte)(val << (4 * nibble));
        }
コード例 #15
0
 /// <summary>
 /// Increment the pixel count and add to the color information
 /// </summary>
 /// <param name="pixel">The pixel to add.</param>
 /// <param name="buffer">The buffer array.</param>
 public void Increment(TColor pixel, byte[] buffer)
 {
     pixel.ToBytes(buffer, 0, ComponentOrder.XYZW);
     this.pixelCount++;
     this.red   += buffer[0];
     this.green += buffer[1];
     this.blue  += buffer[2];
     this.alpha += buffer[3];
 }
コード例 #16
0
            public override Image <TColor, TPacked> Create()
            {
                var    image = base.Create();
                TColor color = default(TColor);

                color.PackFromBytes(this.r, this.g, this.b, this.a);

                return(image.Fill(color));
            }
コード例 #17
0
            public override Image <TColor> GetImage()
            {
                Image <TColor> image = base.GetImage();
                TColor         color = default(TColor);

                color.PackFromBytes(this.r, this.g, this.b, this.a);

                return(image.Fill(color));
            }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Octree"/> class.
 /// </summary>
 /// <param name="maxColorBits">
 /// The maximum number of significant bits in the image
 /// </param>
 public Octree(int maxColorBits)
 {
     this.maxColorBits   = maxColorBits;
     this.Leaves         = 0;
     this.reducibleNodes = new OctreeNode[9];
     this.root           = new OctreeNode(0, this.maxColorBits, this);
     this.previousColor  = default(TColor);
     this.previousNode   = null;
 }
コード例 #19
0
ファイル: StartUpScreen.cs プロジェクト: TendoSoSoft/FIVE
        private void SetUpTSSPositionAndBar()
        {
            TBoundary.transform.localPosition  = new Vector3(-0.144f * width, 0.1798f * height, 0f);
            S1Boundary.transform.localPosition = new Vector3(0, 0.1996f * height, 0f);
            S2Boundary.transform.localPosition = new Vector3(0.1404f * width, 0.17983f * height, 0f);

            TColor.GetComponent <Image>().fillAmount  = 0;
            S1Color.GetComponent <Image>().fillAmount = 0;
            S2Color.GetComponent <Image>().fillAmount = 0;
        }
コード例 #20
0
    public void Test_SetComplexObject()
    {
        Human  human = new Human();
        Head   head  = new Head();
        TColor color = new TColor();

        ReflectionHelper.SetFieldValue("m_Head", human, head);
        ReflectionHelper.SetFieldValue("m_Head.m_HairColor", human, color);
        Assert.AreEqual(color, human.GetHead().GetColor(), "Color was unable to be set correctly");
    }
コード例 #21
0
 public Medium_Alcholol(Bottle bottle, TType mtype, string recipe, TCooking_Method cooking_method, TColor color, TShugar shugar, double degree, int year, string name, double price, int count, string country) : base(degree, year, name, price, count, country)
 {
     this.Bottle         = bottle;
     this.Cooking_Method = cooking_method;
     this.Shugar         = shugar;
     this.Recipe         = recipe;
     this.MType          = mtype;
     this.Color          = color;
     this.Category       = TCategories.Medium_Alcholol;
 }
コード例 #22
0
ファイル: U3DJsonSetting.cs プロジェクト: daixian/Math3D
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                var    obj  = (Color)value;
                TColor tobj = new TColor()
                {
                    r = obj.r, g = obj.g, b = obj.b, a = obj.a
                };

                serializer.Serialize(writer, tobj);
            }
コード例 #23
0
ファイル: OctreeQuantizer.cs プロジェクト: xjlonly/ImageSharp
                /// <summary>
                /// Increment the pixel count and add to the color information
                /// </summary>
                /// <param name="pixel">
                /// The pixel to add.
                /// </param>
                public void Increment(TColor pixel)
                {
                    this.pixelCount++;
                    Color color = new Color(pixel.ToVector4());

                    this.red   += color.R;
                    this.green += color.G;
                    this.blue  += color.B;
                    this.alpha += color.A;
                }
コード例 #24
0
        /// <summary>The initializing constructor. Initializes a new instance of the Range class.</summary>
        /// <param name="foreColor">The foreground (text) color.<see cref="X11.TColor"/></param>
        /// <param name="backColor">The background color.<see cref="X11.TColor"/></param>
        /// <param name="fontStyle">The font style.<see cref="System.Drawing.FontStyle"/></param>
        /// <param name="fontData">The font data.<see cref="X11.X11FontData"/></param>
        public Style(TColor foreColor, TColor backColor, System.Drawing.FontStyle fontStyle, X11FontData fontData)
        {
            if (fontData == null)
            {
                throw new ArgumentNullException("fontData");
            }

            _foreColor = foreColor;
            _backColor = backColor;
            _fontStyle = fontStyle;

            _fontData = fontData;
        }
コード例 #25
0
    public static TColor Parse(string str)
    {
        ColorUtility.TryParseHtmlString(str, out Color color);
        var data = new TColor
        {
            r = color.r,
            g = color.g,
            b = color.b,
            a = color.a
        };

        return(data);
    }
コード例 #26
0
        private static AnalyticsObject GetRectangle()
        {
            AnalyticsObject aObject;
            TPolygon        tPolygon;
            TColor          tColor;

            aObject              = new AnalyticsObject();
            aObject.Name         = "SuspectArea";
            aObject.AlarmTrigger = true;
            aObject.Value        = "A suspect item";
            aObject.Confidence   = 0.9;
            aObject.Description  = "Object description";
            tPolygon             = new TPolygon();
            aObject.Polygon      = tPolygon;

            tColor         = new TColor();
            tColor.A       = 255;
            tColor.R       = 255;
            tColor.G       = 255;
            tColor.B       = 0;
            tPolygon.Color = tColor;

            PointList pointList = new PointList();
            TPoint    tPoint;

            tPoint   = new TPoint();
            tPoint.X = 0.3D;
            tPoint.Y = 0.3D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.6D;
            tPoint.Y = 0.3D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.6D;
            tPoint.Y = 0.6D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.3D;
            tPoint.Y = 0.6D;
            pointList.Add(tPoint);
            tPoint   = new TPoint();
            tPoint.X = 0.3D;
            tPoint.Y = 0.3D;
            pointList.Add(tPoint);

            tPolygon.PointList = pointList;

            return(aObject);
        }
コード例 #27
0
ファイル: StartUpScreen.cs プロジェクト: TendoSoSoft/FIVE
 private void SetActive()
 {
     Gen.SetActive(true);
     Laurence.SetActive(true);
     Wen.SetActive(true);
     Wally.SetActive(true);
     Yu.SetActive(true);
     QuestionMark.SetActive(true);
     ExclamationMark.SetActive(true);
     LaurenceMark.SetActive(true);
     TBoundary.SetActive(true);
     TColor.SetActive(true);
     S1Boundary.SetActive(true);
     S1Color.SetActive(true);
     S2Boundary.SetActive(true);
     S2Color.SetActive(true);
 }
コード例 #28
0
            /// <summary>
            /// Convert the nodes in the Octree to a palette with a maximum of colorCount colors
            /// </summary>
            /// <param name="colorCount">The maximum number of colors</param>
            /// <returns>
            /// An <see cref="List{TColor}"/> with the palletized colors
            /// </returns>
            public TColor[] Palletize(int colorCount)
            {
                while (this.Leaves > colorCount)
                {
                    this.Reduce();
                }

                // Now palletize the nodes
                TColor[] palette = new TColor[colorCount + 1];

                int paletteIndex = 0;

                this.root.ConstructPalette(palette, ref paletteIndex);

                // And return the palette
                return(palette);
            }
コード例 #29
0
    public void Init(string textValue, TColor tColor = TColor.Default)
    {
        switch (tColor)
        {
        case TColor.Enemy:
            txtEnergy.color = Color.red;
            break;

        case TColor.Player:
            txtEnergy.color = Color.blue;
            break;

        case TColor.Default:
            txtEnergy.color = Color.white;
            break;
        }
        txtEnergy.text = textValue;
    }
コード例 #30
0
ファイル: StartUpScreen.cs プロジェクト: TendoSoSoft/FIVE
        private void DoFadingOut()
        {
            float duration = 1.5f;

            Wally.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            Gen.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            Laurence.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            Yu.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            Wen.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            QuestionMark.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            ExclamationMark.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            LaurenceMark.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            TBoundary.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            TColor.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            S1Boundary.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            S1Color.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            S2Boundary.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            S2Color.GetComponent <Image>().CrossFadeAlpha(0, duration, false);
            Destroy();
        }