Beispiel #1
0
        override public void Setup_BeforeAdd(ByteBuffer buffer, int beginPos)
        {
            base.Setup_BeforeAdd(buffer, beginPos);

            buffer.Seek(beginPos, 5);

            int type = buffer.ReadByte();

            if (type != 0)
            {
                int     lineSize     = buffer.ReadInt();
                Color   lineColor    = buffer.ReadColor();
                Color   fillColor    = buffer.ReadColor();
                bool    roundedRect  = buffer.ReadBool();
                Vector4 cornerRadius = new Vector4();
                if (roundedRect)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        cornerRadius[i] = buffer.ReadFloat();
                    }
                }

                if (type == 1)
                {
                    if (roundedRect)
                    {
                        _shape.DrawRoundRect(lineSize, lineColor, fillColor, cornerRadius.x, cornerRadius.y, cornerRadius.z, cornerRadius.w);
                    }
                    else
                    {
                        _shape.DrawRect(lineSize, lineColor, fillColor);
                    }
                }
                else if (type == 2)
                {
                    _shape.DrawEllipse(lineSize, fillColor, lineColor, fillColor, 0, 360);
                }
                else if (type == 3)
                {
                    int       cnt    = buffer.ReadShort() / 2;
                    Vector2[] points = new Vector2[cnt];
                    for (int i = 0; i < cnt; i++)
                    {
                        points[i].Set(buffer.ReadFloat(), buffer.ReadFloat());
                    }

                    _shape.DrawPolygon(points, fillColor, lineSize, lineColor);
                }
                else if (type == 4)
                {
                    int     sides      = buffer.ReadShort();
                    float   startAngle = buffer.ReadFloat();
                    int     cnt        = buffer.ReadShort();
                    float[] distances  = null;
                    if (cnt > 0)
                    {
                        distances = new float[cnt];
                        for (int i = 0; i < cnt; i++)
                        {
                            distances[i] = buffer.ReadFloat();
                        }
                    }

                    _shape.DrawRegularPolygon(sides, lineSize, fillColor, lineColor, fillColor, startAngle, distances);
                }
            }
            originColor = color;
        }