public static TrueTypeText CreateTrueTypeText(Renderer renderer, string fontPath, int fontSize, Color color, string text, int wrapLength) { Font font = new Font(fontPath, fontSize); Surface surface = new Surface(font, text, color, wrapLength); TrueTypeText trueTypeText = new TrueTypeText(renderer, surface, text, font, color, wrapLength); return trueTypeText; }
public Texture(Renderer renderer, Surface surface) { Assert.IsNotNull(renderer, Errors.E_RENDERER_NULL); Assert.IsNotNull(surface, Errors.E_SURFACE_NULL); this.renderer = renderer; FilePath = surface.FilePath; AccessMode = TextureAccessMode.Static; Surface = surface; CreateTextureAndCleanup(surface.Width, surface.Height); }
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); }
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); }
public void UpdateSurfaceAndTexture(Surface surface) { Assert.IsNotNull(surface, Errors.E_SURFACE_NULL); SDL.SDL_DestroyTexture(Handle); Handle = IntPtr.Zero; Surface = surface; CreateTextureAndCleanup(surface.Width, surface.Height); }
private void BuildTileSetTextures(Renderer renderer, string contentRoot) { // build textures foreach (TileSetContent tileSet in tileSets) { string path = Path.Combine(contentRoot, tileSet.ImageSource); // need to use colorkey Surface surface = new Surface(path, SurfaceType.PNG); tileSet.Texture = new Texture(renderer, surface); } }
public void UpdateText(string text, int wrapLength = 0) { Text = text; Surface surface = new Surface(Font, Text, Color, wrapLength); Texture.UpdateSurfaceAndTexture(surface); }