示例#1
0
 /// <summary>
 /// Main constructor used to instantiate a tile when data is known at import
 /// </summary>
 /// <param name="texture"></param>
 /// <param name="source"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public Tile(Texture texture, Rectangle source, int width, int height)
 {
     ID = Guid.NewGuid();
     IsEmpty = false;
     Texture = texture;
     SourceTextureBounds = source;
     Width = width;
     Height = height;
 }
示例#2
0
        public TrueTypeText(Renderer renderer, Surface surface, string text, Font textFont, Color color, int wrapLength)
        {
            Assert.IsNotNull(renderer, Errors.E_RENDERER_NULL);
            Assert.IsNotNull(surface, Errors.E_SURFACE_NULL);
            Assert.IsNotNull(textFont, Errors.E_FONT_NULL);

            Text = text;
            Font = textFont;
            Color = color;
            WrapLength = wrapLength;
            if (wrapLength > 0)
                IsWrapped = true;
            else
                IsWrapped = false;
            Texture = new Texture(renderer, surface);
        }
示例#3
0
        public Image(Renderer renderer, Surface surface, ImageFormat imageFormat)
        {
            Assert.IsNotNull(renderer, Errors.E_RENDERER_NULL);
            Assert.IsNotNull(surface, Errors.E_SURFACE_NULL);

            if (surface.Type == SurfaceType.Text)
                throw new Exception("Cannot create images from text surfaces.");

            Format = imageFormat;

            if (surface.Type == SurfaceType.BMP)
                Format = ImageFormat.BMP;
            else if (surface.Type == SurfaceType.PNG)
                Format = ImageFormat.PNG;
            else if (surface.Type == SurfaceType.JPG)
                Format = ImageFormat.JPG;

            Texture = new Texture(renderer, surface);
        }