示例#1
0
        public static StyleItem styleItemNinePatch(NinePatch p)
        {
            StyleItem i = new StyleItem();

            i.type  = StyleItem.Type.NINEPATCH;
            i.patch = p;
            return(i);
        }
示例#2
0
        public void addImage(NinePatch p, Rect r)
        {
            bool pushTex = shouldPushTexture(p.myTexture);

            if (pushTex)
            {
                pushTexture(p.myTexture);
            }

            UInt32 cl = Color4.White.toUInt();

            Vector2[] verts = p.generateVerts(r);
            Vector2[] uvs   = p.generateUvs();

            UInt16 startVertex = (UInt16)myVertCount;

            //generate 16 verts
            int index = 0;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    myVerts[myVertCount].Position = verts[index];
                    myVerts[myVertCount].TexCoord = uvs[index];
                    myVerts[myVertCount].Color    = cl;
                    myVertCount++;
                    index++;
                }
            }

            //indexes in verts
            writeIndex((UInt16)(startVertex + 0)); writeIndex((UInt16)(startVertex + 4)); writeIndex((UInt16)(startVertex + 1));
            writeIndex((UInt16)(startVertex + 1)); writeIndex((UInt16)(startVertex + 4)); writeIndex((UInt16)(startVertex + 5));

            writeIndex((UInt16)(startVertex + 1)); writeIndex((UInt16)(startVertex + 5)); writeIndex((UInt16)(startVertex + 2));
            writeIndex((UInt16)(startVertex + 2)); writeIndex((UInt16)(startVertex + 5)); writeIndex((UInt16)(startVertex + 6));

            writeIndex((UInt16)(startVertex + 2)); writeIndex((UInt16)(startVertex + 6)); writeIndex((UInt16)(startVertex + 3));
            writeIndex((UInt16)(startVertex + 3)); writeIndex((UInt16)(startVertex + 6)); writeIndex((UInt16)(startVertex + 7));



            writeIndex((UInt16)(startVertex + 4)); writeIndex((UInt16)(startVertex + 8)); writeIndex((UInt16)(startVertex + 5));
            writeIndex((UInt16)(startVertex + 5)); writeIndex((UInt16)(startVertex + 8)); writeIndex((UInt16)(startVertex + 9));

            writeIndex((UInt16)(startVertex + 5)); writeIndex((UInt16)(startVertex + 9)); writeIndex((UInt16)(startVertex + 6));
            writeIndex((UInt16)(startVertex + 6)); writeIndex((UInt16)(startVertex + 9)); writeIndex((UInt16)(startVertex + 10));

            writeIndex((UInt16)(startVertex + 6)); writeIndex((UInt16)(startVertex + 10)); writeIndex((UInt16)(startVertex + 7));
            writeIndex((UInt16)(startVertex + 7)); writeIndex((UInt16)(startVertex + 10)); writeIndex((UInt16)(startVertex + 11));



            writeIndex((UInt16)(startVertex + 8)); writeIndex((UInt16)(startVertex + 12)); writeIndex((UInt16)(startVertex + 9));
            writeIndex((UInt16)(startVertex + 9)); writeIndex((UInt16)(startVertex + 12)); writeIndex((UInt16)(startVertex + 13));

            writeIndex((UInt16)(startVertex + 9)); writeIndex((UInt16)(startVertex + 13)); writeIndex((UInt16)(startVertex + 10));
            writeIndex((UInt16)(startVertex + 10)); writeIndex((UInt16)(startVertex + 13)); writeIndex((UInt16)(startVertex + 14));

            writeIndex((UInt16)(startVertex + 10)); writeIndex((UInt16)(startVertex + 14)); writeIndex((UInt16)(startVertex + 11));
            writeIndex((UInt16)(startVertex + 11)); writeIndex((UInt16)(startVertex + 14)); writeIndex((UInt16)(startVertex + 15));


            if (pushTex)
            {
                popTexture();
            }
        }