示例#1
0
        public Surface(Font font, string text, Color color, int wrapLength)
        {
            if (wrapLength < 0)
                throw new ArgumentOutOfRangeException("wrapLength", "Wrap length must be greater than 0.");

            Type = SurfaceType.Text;
            SDL.SDL_Color rawColor = new SDL.SDL_Color() { r = color.R, g = color.G, b = color.B };

            if (wrapLength > 0)
                Handle = SDL_ttf.TTF_RenderText_Blended_Wrapped(font.Handle, text, rawColor, (uint)wrapLength);
            else
                Handle = SDL_ttf.TTF_RenderText_Blended(font.Handle, text, rawColor);

            if (Handle == IntPtr.Zero)
                throw new Exception(String.Format("Error while loading text surface: {0}", SDL.SDL_GetError()));

            GetSurfaceMetaData();
        }
示例#2
0
 public Effect(AlignEnum alignment, ref Scale scale, ref SDL.SDL_Color color)
 {
     this.alignment = alignment; this.scale = scale; use_color = true; this.color = color;
 }
示例#3
0
 public Effect(ref Scale scale, ref SDL.SDL_Color color)
 {
     alignment = AlignEnum.LEFT; this.scale = scale; use_color = true; this.color = color;
 }
示例#4
0
 public Effect(AlignEnum alignment, ref Scale scale)
 {
     this.alignment = alignment; this.scale = scale; use_color = false; color = new SDL.SDL_Color(){r = 255, g = 255, b = 255, a = 255};
 }
示例#5
0
 public Effect(AlignEnum alignment)
 {
     this.alignment = alignment; use_color = false; color = new SDL.SDL_Color(){r = 255, g = 255, b = 255, a = 255};
 }
示例#6
0
 public Effect(ref Scale scale)
 {
     alignment = AlignEnum.LEFT; this.scale = scale; use_color = false; color =  new SDL.SDL_Color(){r = 255, g = 255, b = 255, a = 255};
 }
示例#7
0
 public Effect()
 {
     alignment = AlignEnum.LEFT; use_color = false; color = new SDL.SDL_Color(){r = 255, g = 255, b = 255, a = 255};
 }
示例#8
0
        public SDLTexture RenderTextBlended( SDLRenderer renderer,
                                             string text,
                                             Color color )
        {
            // Check inputs.
            if ( renderer == null )
            {
                throw new ArgumentNullException( "renderer" );
            }

            // Convert color to SDL format.
            SDL.SDL_Color sdlColor = new SDL.SDL_Color();

            sdlColor.r = color.RedByte;
            sdlColor.g = color.GreenByte;
            sdlColor.b = color.BlueByte;

            // Render the text message to an SDL_Surface and then convert the surface into an
            // SDL texture.
            SDLTexture texture;

            using ( SDLSurface surface = new SDLSurface( SDL_ttf.TTF_RenderText_Blended(
                                                            mFont,
                                                            text,
                                                            sdlColor ) ) )
            {
                texture = new SDLTexture( renderer, surface );
            }

            return texture;
        }