Add() public method

Adds a clipped or stretched version of the texture to the batcher, with the specified color.
public Add ( Texture tex, FloatRect source, FloatRect dest, System.Color color ) : void
tex SFML.Graphics.Texture
source FloatRect
dest FloatRect
color System.Color
return void
Example #1
0
 public HWSurfaceInstance(ScriptEngine parent, string filename)
     : base(parent.Object.InstancePrototype)
 {
     using (Texture tex = new Texture(filename))
     {
         _width = tex.Size.X;
         _height = tex.Size.Y;
         _tex = new RenderTexture(_width, _height);
         _myBatch = new SpriteBatch(_tex);
         _myBatch.SetBlendMode(BlendMode.None);
         _myBatch.Add(tex, 0, 0);
         _myBatch.Flush();
         Update();
     }
     Init();
 }
Example #2
0
        public void DrawText(SpriteBatch batch, double x, double y, string text)
        {
            CheckUpdate();
            FloatRect dest = new FloatRect((float)x, (float)y, 0, (float)_height);

            for (var i = 0; i < text.Length; ++i)
            {
                IntRect src = _atlas.Sources[text[i]];
                dest.Width = src.Width;
                dest.Height = src.Height;
                batch.Add(_atlas.Texture, src, dest, _color);
                dest.Left += src.Width;
            }
        }