Example #1
0
        public static bool Load(string fileName)
        {
            texture = new Texture(fileName);
            if (texture.id == 0)
            {
                return(false);
            }

            float w = texture.size.Width;
            float h = texture.size.Height;

            glyphs = new List <TextureCoord>(256);

            for (int i = 15; i >= 0; i--)
            {
                for (int j = 0; j < 16; j++)
                {
                    TextureCoord tc = new TextureCoord();
                    tc.u1 = ((w / 16) * j) / w;
                    tc.v1 = ((h / 16) * i + h / 16) / h;
                    tc.u2 = ((w / 16) * j + w / 16) / w;
                    tc.v2 = ((h / 16) * i) / h;

                    glyphs.Add(tc);
                }
            }

            return(true);
        }
            public override void Parse(string line)
            {
                string[] parts = line.Split(' ');

                float x = parts[0].ParseInvariantFloat();
                float y = parts[1].ParseInvariantFloat();

                var texture = new TextureCoord(x, y);

                _textureDataStore.AddTexture(texture);
            }
Example #3
0
        // 0 0 - правый верхний угол экрана
        // Имя файла с текстурами, время смены кадра в мс
        public Sprite(string fileName, Size _size, int _animatedTime = 0)
        {
            animatedTime = _animatedTime;

            pos_g.X = 0.0f;
            pos_g.Y = 0.0f;
            pos.X   = 0.0f;
            pos.Y   = 0.0f;

            size_g.Width  = 0;
            size_g.Height = 0;
            size.Width    = 0;
            size.Height   = 0;

            texture = new Texture(fileName);
            if (texture.size.IsEmpty)
            {
                return;
            }

            int frameCount = texture.size.Width / texture.size.Height;

            textureCoord = new List <TextureCoord>(frameCount);

            float w = (float)texture.size.Width;
            float h = (float)texture.size.Height;

            for (int i = 0; i < frameCount; i++)
            {
                TextureCoord tex = new TextureCoord();

                tex.u1 = (h * i) / w;
                tex.v1 = 1;
                tex.u2 = (h * i + h) / w;
                tex.v2 = 0;

                textureCoord.Add(tex);
            }

            size = size_g = _size;
        }
 public void AddTextureCoord(TextureCoord textureCoord) => throw new System.NotImplementedException();
Example #5
0
 public void AddTexture(TextureCoord texture)
 {
     _textures.Add(texture);
 }