C# Class GarrysModLuaShared.surface

The surface library allows you to draw text and shapes on the screen. Primarily used for making HUDs & custom GUI panels.
Exibir arquivo Open project: OmegaExtern/gmod-csharp-binary-module

Public Methods

Method Description
DisableClipping ( LuaState luaState, bool disable ) : void

Enables or disables the clipping used by the VGUI that limits the drawing operations to a panels bounds.

DrawLine ( LuaState luaState, uint startX, uint startY, uint endX, uint endY ) : void

Draws a line from one point to another.

DrawOutlinedRect ( LuaState luaState, uint x, uint y, uint width, uint height ) : void

Draws a hollow box with a border width of 1 px.

DrawRect ( LuaState luaState, uint x, uint y, uint width, uint height ) : void

Draws a solid rectangle on the screen.

DrawText ( LuaState luaState, string text ) : void

Draw the specified text on the screen, using the previously set position, font and color.

DrawTexturedRect ( LuaState luaState, uint x, uint y, uint width, uint height ) : void

Draw a textured rectangle with the given position and dimensions on the screen, using the current active texture.

DrawTexturedRectRotated ( LuaState luaState, uint x, uint y, uint width, uint height, double rotation ) : void

Draw a textured rotated rectangle with the given position and dimensions and angle on the screen, using the current active texture.

DrawTexturedRectUV ( LuaState luaState, uint x, uint y, uint width, uint height, double startU, double startV, double endU, double endV ) : void

Draws a textured rectangle with a repeated or partial texture. U and V refer to texture coordinates. 0,0 is the bottom left corner of the texture, 1,0 is the bottom right, 1,1 is the top right and 0,1 is the top left. If you are using a .png image, you must supply "noclamp" as second parameter for Global.Material. Using a start point of(1,0) and an end point to(0,1), you can draw an image flipped horizontally, etc with other directions.

GetTextSize ( LuaState luaState, string text ) : int>.Tuple

Returns the width and height (in pixels) of the given text, but only if the font has been set with SetFont.

GetTextSize ( LuaState luaState, string text, int &width, int &height ) : void

Returns the width and height (in pixels) of the given text, but only if the font has been set with SetFont.

GetTextureID ( LuaState luaState, string nameOrPath ) : uint

Returns the texture ID of the texture with the given name/path.

GetTextureSize ( LuaState luaState, uint textureId ) : int>.Tuple

Returns the size of the texture with the associated texture ID.

GetTextureSize ( LuaState luaState, uint textureId, int &width, int &height ) : void

Returns the size of the texture with the associated texture ID.

PlaySound ( LuaState luaState, string soundFile ) : void

Play a sound file directly on the client (such as UI sounds, etc).

SetAlphaMultiplier ( LuaState luaState, double multiplier ) : void

Sets a multiplier that will influence all upcoming drawing operations.

SetDrawColor ( LuaState luaState, byte r, byte g, byte b, byte a = byte.MaxValue ) : void

Set the color of any future shapes to be drawn.

SetFont ( LuaState luaState, string fontName ) : void

Set the current font to be used for text operations later.

SetTextColor ( LuaState luaState, byte r, byte g, byte b, byte a = byte.MaxValue ) : void

Set the color of any future text to be drawn.

SetTextPos ( LuaState luaState, uint x, uint y ) : void

Set the position to draw any future text.

SetTexture ( LuaState luaState, uint textureId ) : void

Sets the texture to be used in all upcoming surface draw operations.

Method Details

DisableClipping() public static method

Enables or disables the clipping used by the VGUI that limits the drawing operations to a panels bounds.
public static DisableClipping ( LuaState luaState, bool disable ) : void
luaState LuaState Pointer to lua_State struct.
disable bool True to disable, false to enable the clipping.
return void

DrawLine() public static method

Draws a line from one point to another.
public static DrawLine ( LuaState luaState, uint startX, uint startY, uint endX, uint endY ) : void
luaState LuaState Pointer to lua_State struct.
startX uint The start X coordinate.
startY uint The start Y coordinate.
endX uint The end X coordinate.
endY uint The end Y coordinate.
return void

DrawOutlinedRect() public static method

Draws a hollow box with a border width of 1 px.
public static DrawOutlinedRect ( LuaState luaState, uint x, uint y, uint width, uint height ) : void
luaState LuaState Pointer to lua_State struct.
x uint The start X coordinate.
y uint The start Y coordinate.
width uint The width.
height uint The height.
return void

DrawRect() public static method

Draws a solid rectangle on the screen.
public static DrawRect ( LuaState luaState, uint x, uint y, uint width, uint height ) : void
luaState LuaState Pointer to lua_State struct.
x uint The X co-ordinate.
y uint The Y co-ordinate.
width uint The width of the rectangle.
height uint The height of the rectangle.
return void

DrawText() public static method

Draw the specified text on the screen, using the previously set position, font and color.
public static DrawText ( LuaState luaState, string text ) : void
luaState LuaState Pointer to lua_State struct.
text string The text to be rendered.
return void

DrawTexturedRect() public static method

Draw a textured rectangle with the given position and dimensions on the screen, using the current active texture.
public static DrawTexturedRect ( LuaState luaState, uint x, uint y, uint width, uint height ) : void
luaState LuaState Pointer to lua_State struct.
x uint The X co-ordinate.
y uint The Y co-ordinate.
width uint The width of the rectangle.
height uint The height of the rectangle.
return void

DrawTexturedRectRotated() public static method

Draw a textured rotated rectangle with the given position and dimensions and angle on the screen, using the current active texture.
public static DrawTexturedRectRotated ( LuaState luaState, uint x, uint y, uint width, uint height, double rotation ) : void
luaState LuaState Pointer to lua_State struct.
x uint The X co-ordinate, representing the center of the rectangle.
y uint The Y co-ordinate, representing the center of the rectangle.
width uint The width of the rectangle.
height uint The height of the rectangle.
rotation double The rotation of the rectangle, in degrees.
return void

DrawTexturedRectUV() public static method

Draws a textured rectangle with a repeated or partial texture. U and V refer to texture coordinates. 0,0 is the bottom left corner of the texture, 1,0 is the bottom right, 1,1 is the top right and 0,1 is the top left. If you are using a .png image, you must supply "noclamp" as second parameter for Global.Material. Using a start point of(1,0) and an end point to(0,1), you can draw an image flipped horizontally, etc with other directions.
public static DrawTexturedRectUV ( LuaState luaState, uint x, uint y, uint width, uint height, double startU, double startV, double endU, double endV ) : void
luaState LuaState Pointer to lua_State struct.
x uint The X coordinate.
y uint The Y coordinate.
width uint The width of the rectangle.
height uint The height of the rectangle.
startU double The U texture mapping of the rect origin.
startV double The V texture mapping of the rect origin.
endU double The U texture mapping of the rect end.
endV double The V texture mapping of the rect end.
return void

GetTextSize() public static method

Returns the width and height (in pixels) of the given text, but only if the font has been set with SetFont.
public static GetTextSize ( LuaState luaState, string text ) : int>.Tuple
luaState LuaState Pointer to lua_State struct.
text string The string to check the size of.
return int>.Tuple

GetTextSize() public static method

Returns the width and height (in pixels) of the given text, but only if the font has been set with SetFont.
public static GetTextSize ( LuaState luaState, string text, int &width, int &height ) : void
luaState LuaState Pointer to lua_State struct.
text string The string to check the size of.
width int Width of in pixels.
height int Height of in pixels.
return void

GetTextureID() public static method

Returns the texture ID of the texture with the given name/path.
public static GetTextureID ( LuaState luaState, string nameOrPath ) : uint
luaState LuaState Pointer to lua_State struct.
nameOrPath string Name or path of the texture.
return uint

GetTextureSize() public static method

Returns the size of the texture with the associated texture ID.
public static GetTextureSize ( LuaState luaState, uint textureId ) : int>.Tuple
luaState LuaState Pointer to lua_State struct.
textureId uint The texture ID.
return int>.Tuple

GetTextureSize() public static method

Returns the size of the texture with the associated texture ID.
public static GetTextureSize ( LuaState luaState, uint textureId, int &width, int &height ) : void
luaState LuaState Pointer to lua_State struct.
textureId uint The texture ID.
width int The width of texture.
height int The height of texture.
return void

PlaySound() public static method

Play a sound file directly on the client (such as UI sounds, etc).
public static PlaySound ( LuaState luaState, string soundFile ) : void
luaState LuaState Pointer to lua_State struct.
soundFile string The path to the sound file.
return void

SetAlphaMultiplier() public static method

Sets a multiplier that will influence all upcoming drawing operations.
public static SetAlphaMultiplier ( LuaState luaState, double multiplier ) : void
luaState LuaState Pointer to lua_State struct.
multiplier double The multiplier ranging from 0 to 1.
return void

SetDrawColor() public static method

Set the color of any future shapes to be drawn.
public static SetDrawColor ( LuaState luaState, byte r, byte g, byte b, byte a = byte.MaxValue ) : void
luaState LuaState Pointer to lua_State struct.
r byte The red value of color.
g byte The green value of color.
b byte The blue value of color.
a byte The alpha value of color.
return void

SetFont() public static method

Set the current font to be used for text operations later.
public static SetFont ( LuaState luaState, string fontName ) : void
luaState LuaState Pointer to lua_State struct.
fontName string The name of the font to use.
return void

SetTextColor() public static method

Set the color of any future text to be drawn.
public static SetTextColor ( LuaState luaState, byte r, byte g, byte b, byte a = byte.MaxValue ) : void
luaState LuaState Pointer to lua_State struct.
r byte The red value of color.
g byte The green value of color.
b byte The blue value of color.
a byte The alpha value of color.
return void

SetTextPos() public static method

Set the position to draw any future text.
public static SetTextPos ( LuaState luaState, uint x, uint y ) : void
luaState LuaState Pointer to lua_State struct.
x uint The X co-ordinate.
y uint The Y co-ordinate.
return void

SetTexture() public static method

Sets the texture to be used in all upcoming surface draw operations.
public static SetTexture ( LuaState luaState, uint textureId ) : void
luaState LuaState Pointer to lua_State struct.
textureId uint The ID of the texture to draw with.
return void