Surface

Surfaces are a rectangular collection of pixels Surfaces are easy to work with and edit and can be blitted on to another surface Surfaces can also be converted to textures which are more efficient but less flexible Surfaces are handled in software as opposed to textures which are handled in hardware Surfaces can be used, but when used repeatedly and stored, textures should be preferred Surface draw methods do not respect alpha, but surface blitting does; to draw with alpha, draw to another surface, and blit to desired surface

class Surface {}

Constructors

this
this(int width, int height, int depth = 32, uint flags = 0, uint Rmask = 0, uint Gmask = 0, uint Bmask = 0, uint Amask = 0)

Creates an RGB surface given at least a width and a height

this
this(int width, int height, uint format, int depth = 32, uint flags = 0)

Creates an RGB surface given at least a width, height, and an SDL_PixelFormatEnum

this
this(Surface src, SDL_PixelFormat* fmt, uint flags = 0)

Creates a surface from another surface but with a different pixel format

this
this(Surface src, uint fmt, uint flags = 0)

Creates a surface from another surface but with a different pixel format

this
this(string bmpFilePath)

Creates a surface from a BMP file path; for other image formats, use loadImage

this
this(SDL_Surface* alreadyExisting)

Creates a surface from an already existing SDL_Surface

Destructor

~this
~this()

Ensures that SDL can properly dispose of the surface

Members

Functions

blit
void blit(Surface src, iRectangle srcRect, int dstX, int dstY)

Blits another surface onto this surface Takes the surface to blit, the slice of the surface to blit, and where on this surface to blit to Is faster than a scaled blit to a rectangle

blit
void blit(Surface src, iRectangle srcRect, iRectangle dstRect)

Does a scaled blit from another surface onto this surface Takes the surface to blit, the slice of the surface to blit, and the slice on this surface of where to blit to Is slower than the blit to a location

draw
void draw(int x, int y, Color color)

Draws a point on the surface with the given color

draw
void draw(iVector point, Color color)

Draws a point on the surface with the given color

draw
void draw(iVector first, iVector second, Color color)

Draws a line on the surface with the given color

draw
void draw(iSegment line, Color color)

Draws a line on the surface with the given color

draw
void draw(iPolygon!sides toDraw, Color color)

Draws a polygon on the surface with the given color

draw
void draw(iRectangle rect, Color color)

Draws a rectangle on the surface

draw
void draw(BezierCurve!(int, 2) curve, Color color)

Draws the given bezier curve with numPoints number of points on the curve More points is smoother but slower

draw
void draw(iRectangle bounds, double startAngle, double endAngle)

Draws the ellipse bounded by the given box between the given angles in radians More points generally means a slower but more well drawn ellipse

draw
void draw(iRectangle bounds, double startAngle, double endAngle, Color color)

Draws the ellipse bounded by the given box between the given angles in radians with the given color More points generally means a slower but more well drawn ellipse

fill
void fill(iRectangle destination, Color color)

Fills a rectangle of the surface with the given color Due to how SDL surfaces work, all other drawing functions on surface are built with this one

fill
void fill(iRectangle bounds, double startAngle, double endAngle)

Fills the ellipse bounded by the given box between the given angles in radians Fills the ellipse between the arc endpoints: fills ellipse as arc rather than filling as ellipse (not a pizza slice) More points generally means a slower but more well drawn ellipse

fill
void fill(iRectangle bounds, double startAngle, double endAngle, Color color)

Fills the ellipse bounded by the given box between the given angles in radians with the given color Fills the ellipse between the arc endpoints: fills ellipse as arc rather than filling as ellipse (not a pizza slice) More points generally means a slower but more well drawn ellipse

fill
void fill(iPolygon!sides toDraw, Color color)

Fills a polygon on the surface with the given color

saveBMP
void saveBMP(string fileName)

Saves the surface as a BMP with the given file name

Properties

alphaMod
ubyte alphaMod [@property setter]

Sets the alpha modifier for the surface Alpha modification works by multiplying the alphaMultiplier / 255 into the surface pixels

alphaMod
ubyte alphaMod [@property getter]

Gets the alpha modifier for the surface Alpha modification works by multiplying the alphaMultiplier / 255 into the surface pixels

blendMode
SDL_BlendMode blendMode [@property setter]

Sets the surface's blend mode

blendMode
SDL_BlendMode blendMode [@property getter]

Gets the surface's blend mode

clipRect
iRectangle clipRect [@property setter]

Sets the clip boundaries for the surface Anything put on the surface outside of the clip boundaries gets discarded

clipRect
iRectangle clipRect [@property getter]

Gets the clip boundaries for the surface Anything put on the surface outside of the clip boundaries gets discarded

colorMod
Color colorMod [@property setter]

Sets the color modifier for the surface Color modification works by multiplying the colorMultiplier / 255 into the surface pixels

colorMod
Color colorMod [@property getter]

Gets the color modifier for the surface Color modification works by multiplying the colorMultiplier / 255 into the surface pixels

dimensions
iVector dimensions [@property getter]

Gets the surfaces dimensions as a vector with width as the x component and height as the y component

handle
SDL_Surface* handle [@property getter]

Returns the raw SDL data of this object

Meta