Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.NineSlice Class Reference

Graphic type used to render a panel made up of 9 slices of an image. Handy for rendering panels with border graphics. More...

Inherits Otter.Graphic.

Public Member Functions

 NineSlice (string source, int width=0, int height=0, Rectangle?fillRect=null)
 Create a new NineSlice with a file path to a Texture. More...
 
 NineSlice (Texture texture, int width, int height, Rectangle?fillRect=null)
 Create a new NineSlice with a Texture. More...
 
 NineSlice (AtlasTexture texture, int width, int height, Rectangle?fillRect=null)
 Create a new NineSlice with an AtlasTexture. More...
 
NineSlice SetFillRect (int x1, int y1, int x2, int y2)
 Set the FillRect of the NineSlice. This determines which areas are stretched or tiled when rendering the tiles. More...
 
Rectangle GetFillRect ()
 Get the FillRect of the NineSlice. This determines which areas are stretched or tiled when rendering the tiles. More...
 
NineSlice SetBorderPadding (int top, int right, int bottom, int left)
 Set the FillRect of the NineSlice using padding values. More...
 
NineSlice SetBorderPadding (int padding)
 Set the FillRect of the NineSlice using padding values. More...
 
NineSlice SetBorderPadding (int horizontal, int vertical)
 Set the FillRect of the NineSlice using padding values. More...
 
override void Render (float x=0, float y=0)
 Draw the NineSlice. More...
 
- Public Member Functions inherited from Otter.Graphic
Transformation AddTransform (Transformation transform)
 
Transformation AddTransform (Vector2 translation, Vector2 scale, Vector2 origin, float rotation)
 
Transformation AddTransform ()
 
Transformation RemoveTransformation (Transformation transform)
 
Transformation PopTransformation ()
 
virtual void ClearShader ()
 Removes the shader from the graphic. More...
 
void SetPosition (float x, float y)
 Set the position of the Graphic. More...
 
void SetPosition (Graphic g, float offsetX=0, float offsetY=0)
 Set the position of the Graphic. More...
 
void SetPosition (Vector2 xy)
 Set the position of the Graphic. More...
 
void SetOrigin (float x, float y)
 Set the origin of the Graphic. More...
 
void SetOrigin (Vector2 xy)
 Set the origin of the Graphic. More...
 
void SetTexture (string path)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
void SetTexture (Texture texture)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
void SetTexture (AtlasTexture atlasTexture)
 Set the Texture that the Graphic is using (if it is using one.) More...
 
virtual void Update ()
 Update the graphic. More...
 
virtual void CenterOrigin ()
 Centers the graphic origin. More...
 
virtual void CenterOriginZero ()
 Centers the graphic origin while retaining its relative position. More...
 

Static Public Member Functions

static void SetFillRect (string key, int x1, int y1, int x2, int y2)
 Register a fill rectangle for a specific asset. Useful for not having to set the same fill rect every time you use a NineSlice for a specific image. More...
 
static void SetFillRect (string[] keys, int x1, int y1, int x2, int y2)
 Sets the FillRect for a NineSlice globally. More...
 
static void SetBorderPadding (string key, int top, int right, int bottom, int left)
 Set the FillRect of the NineSlice using padding values. More...
 
static void SetBorderPadding (string key, int padding)
 Set the FillRect of the NineSlice using padding values. More...
 
static void SetBorderPadding (string key, int horizontal, int vertical)
 Set the FillRect of the NineSlice using padding values. More...
 

Public Attributes

bool UseInsideOrigin
 Draw the panel from the top left corner of the middle slice. More...
 
bool SnapWidth
 When using PanelType.Tiled snap the width to increments of the tile width. More...
 
bool SnapHeight
 When using PanelType.Tiled snap the height to increments of the tile height. More...
 
PanelSizeMode PanelSizeMode = PanelSizeMode.All
 Determines how the size of the panel will be adjusted when setting PanelWidth and PanelHeight. If set to All, the entire panel will be the width and height. If set to Inside, the inside of the panel will be the width and height. More...
 
- Public Attributes inherited from Otter.Graphic
List< TransformationTransforms = new List<Transformation>() { new Transformation() }
 
bool Relative = true
 Determines if the Graphic is rendered relative to its Entity. More...
 
bool Visible = true
 Determines if the Graphic will render. More...
 
float ScrollX = 1
 The scroll factor for the x position. Used for parallax like effects. Values lower than 1 will scroll slower than the camera (appear to be further away) and values higher than 1 will scroll faster than the camera (appear to be closer.) More...
 
float ScrollY = 1
 The scroll factor for the y position. Used for parallax like effects. Values lower than 1 will scroll slower than the camera (appear to be further away) and values higher than 1 will scroll faster than the camera (appear to be closer.) More...
 
float ShakeX
 The horizontal amount to randomly offset the graphic by each frame. More...
 
float ShakeY
 The vertial amount to randomly offset the graphic by each frame. More...
 
Rectangle TextureRegion
 The region to render the Texture with. More...
 
Rectangle AtlasRegion
 The Rectangle to render an AtlasTexture with. More...
 
Shader Shader
 The shader to be applied to this graphic. More...
 
string Name = "Graphic"
 The name of the graphic. More...
 
BlendMode Blend = BlendMode.Alpha
 The blend mode to be applied to this graphic. More...
 
bool RepeatX
 Determines if the image should be rendered multiple times horizontally. More...
 
bool RepeatY
 Determines if the image should be rendered multiple times vertically. More...
 

Protected Member Functions

override void UpdateDrawable ()
 Updates the internal SFML data for rendering. More...
 
- Protected Member Functions inherited from Otter.Graphic
void Append (float x, float y, Color color, float u, float v)
 
void Append (float x, float y, Color color=null)
 
virtual void SFMLRender (Drawable drawable, float x=0, float y=0)
 

Properties

PanelType PanelType [get, set]
 The type of panel to use for the NineSlice. More...
 
Rectangle ClippingRegion [get, set]
 Render the NineSlice through a clipping rectangle. More...
 
bool UsePanelClip [get, set]
 Determines if the ClippingRegion is used or not. More...
 
int PanelWidth [get, set]
 Set the panel width of the NineSlice. This will update and rerender it. More...
 
int PanelHeight [get, set]
 Set the panel height of the NineSlice. This will update and rerender it. More...
 
- Properties inherited from Otter.Graphic
Transformation Transform [get]
 
float X [get, set]
 The X position of the Graphic. More...
 
float Y [get, set]
 The Y position of the Graphic. More...
 
float ScaleX [get, set]
 The horizontal scale of the graphic. Used in the final transformation. More...
 
float ScaleY [get, set]
 The vertical scale of the graphic. Used in the final transformation. More...
 
float Angle [get, set]
 The angle of rotation of the graphic. Used in the final transformation. More...
 
float OriginX [get, set]
 The X origin point to scale and rotate the graphic with. Used in the final transformation. More...
 
float OriginY [get, set]
 The Y origin point to scale and rotate the graphic with. Used in the final transformation. More...
 
Color Color [get, set]
 The base color of the Graphic. Multiplies the vertices of the graphic by this color. More...
 
virtual Texture Texture [get, set]
 The texture that the graphic is using. More...
 
float Alpha [get, set]
 The base transparency of the graphic. A shortcut to access the base color's Alpha. More...
 
int Width [get, set]
 The width of the Graphic. More...
 
int Height [get, set]
 The height of the Graphic. More...
 
float ScaledWidth [get, set]
 The width in pixels of the image after applying the X scale. More...
 
float ScaledHeight [get, set]
 The height in pixels of the image after applying the Y scale. More...
 
virtual bool Smooth [get, set]
 Smooth the texture of a sprite image while scaling it. More...
 
float Scroll [get, set]
 Set both ScrollX and ScrollY. More...
 
float HalfWidth [get]
 Half of the width. More...
 
float HalfHeight [get]
 Half of the height. More...
 
float Scale [set]
 Sets both the ScaleX and ScaleY at the same time. More...
 
bool Repeat [set]
 Sets both RepeatX and RepeatY at the same time. More...
 
float Shake [set]
 A shortcut to set both ShakeX and ShakeY. More...
 
float Left [get]
 The X position of the left side of the Graphic. More...
 
float Top [get]
 The Y position of the top of the Graphic. More...
 
float Right [get]
 The X position of the right side of the Graphic. More...
 
float Bottom [get]
 The Y position of the bottom of the Graphic. More...
 
int TextureLeft [get]
 The X position of the left of the Texture. More...
 
int TextureRight [get]
 The X position of the right of the Texture. More...
 
int TextureTop [get]
 The Y position of the top of the Texture. More...
 
int TextureBottom [get]
 The Y position of the bottom of the Texture. More...
 

Additional Inherited Members

- Protected Attributes inherited from Otter.Graphic
VertexArray SFMLVertices = new VertexArray(PrimitiveType.Quads)
 
Drawable SFMLDrawable
 
float RepeatSizeX
 
bool roundRendering = true
 
bool Dynamic
 If true the graphic will always update its drawable. More...
 

Detailed Description

Graphic type used to render a panel made up of 9 slices of an image. Handy for rendering panels with border graphics.

Constructor & Destructor Documentation

Otter.NineSlice.NineSlice ( string  source,
int  width = 0,
int  height = 0,
Rectangle fillRect = null 
)

Create a new NineSlice with a file path to a Texture.

Parameters
sourceThe file path to the Texture.
widthThe width of the NineSlice panel.
heightThe height of the NineSlice panel.
fillRectThe rectangle to determine the stretched areas.
Otter.NineSlice.NineSlice ( Texture  texture,
int  width,
int  height,
Rectangle fillRect = null 
)

Create a new NineSlice with a Texture.

Parameters
textureThe Texture to use.
widthThe width of the NineSlice panel.
heightThe height of the NineSlice panel.
fillRectThe rectangle to determine the stretched areas.
Otter.NineSlice.NineSlice ( AtlasTexture  texture,
int  width,
int  height,
Rectangle fillRect = null 
)

Create a new NineSlice with an AtlasTexture.

Parameters
textureThe AtlasTexture to use.
widthThe width of the NineSlice panel.
heightThe height of the NineSlice panel.
fillRectThe rectangle to determine the stretched areas.

Member Function Documentation

Rectangle Otter.NineSlice.GetFillRect ( )

Get the FillRect of the NineSlice. This determines which areas are stretched or tiled when rendering the tiles.

Returns
The Rectangle of the FillRect.
override void Otter.NineSlice.Render ( float  x = 0,
float  y = 0 
)
virtual

Draw the NineSlice.

Parameters
xThe X position offset.
yThe Y position offset.

Reimplemented from Otter.Graphic.

static void Otter.NineSlice.SetBorderPadding ( string  key,
int  top,
int  right,
int  bottom,
int  left 
)
static

Set the FillRect of the NineSlice using padding values.

Parameters
topHow far from the top of the texture to begin the rectangle.
rightHow far from the right of the texture to end the rectangle.
bottomHow far from the bottom of the texture to end the rectangle.
leftHow far from the left of the texture to begin the rectangle.
Returns
The NineSlice object.
static void Otter.NineSlice.SetBorderPadding ( string  key,
int  padding 
)
static

Set the FillRect of the NineSlice using padding values.

Parameters
paddingHow far from the border of the texture to make the rectangle.
Returns
The NineSlice object.
static void Otter.NineSlice.SetBorderPadding ( string  key,
int  horizontal,
int  vertical 
)
static

Set the FillRect of the NineSlice using padding values.

Parameters
horizontalHow far horizontally from the border of the texture to make the rectangle.
verticalHow far horizontally from the border of the texture to make the rectangle.
Returns
The NineSlice object.
NineSlice Otter.NineSlice.SetBorderPadding ( int  top,
int  right,
int  bottom,
int  left 
)

Set the FillRect of the NineSlice using padding values.

Parameters
topHow far from the top of the texture to begin the rectangle.
rightHow far from the right of the texture to end the rectangle.
bottomHow far from the bottom of the texture to end the rectangle.
leftHow far from the left of the texture to begin the rectangle.
Returns
The NineSlice object.
NineSlice Otter.NineSlice.SetBorderPadding ( int  padding)

Set the FillRect of the NineSlice using padding values.

Parameters
paddingHow far from the border of the texture to make the rectangle.
Returns
The NineSlice object.
NineSlice Otter.NineSlice.SetBorderPadding ( int  horizontal,
int  vertical 
)

Set the FillRect of the NineSlice using padding values.

Parameters
horizontalHow far horizontally from the border of the texture to make the rectangle.
verticalHow far horizontally from the border of the texture to make the rectangle.
Returns
The NineSlice object.
static void Otter.NineSlice.SetFillRect ( string  key,
int  x1,
int  y1,
int  x2,
int  y2 
)
static

Register a fill rectangle for a specific asset. Useful for not having to set the same fill rect every time you use a NineSlice for a specific image.

Parameters
keyThe asset path.
x1Fill rect x1.
y1Fill Rect y1
x2Fill rect x2.
y2Fill Rect y2
static void Otter.NineSlice.SetFillRect ( string[]  keys,
int  x1,
int  y1,
int  x2,
int  y2 
)
static

Sets the FillRect for a NineSlice globally.

Parameters
keysThe source Texture of the NineSlice. (File path or name on Atlas both work.)
x1The left corner of the fill rectangle.
y1The top corner of the fill rectangle.
x2The right corner of the fill rectangle.
y2The bottom corner of the fill rectangle.
NineSlice Otter.NineSlice.SetFillRect ( int  x1,
int  y1,
int  x2,
int  y2 
)

Set the FillRect of the NineSlice. This determines which areas are stretched or tiled when rendering the tiles.

Parameters
x1The left corner of the rectangle.
y1The top corner of the rectangle.
x2The right corner of the rectangle.
y2The bottom corner of the rectangle.
Returns
The NineSlice object.
override void Otter.NineSlice.UpdateDrawable ( )
protectedvirtual

Updates the internal SFML data for rendering.

Reimplemented from Otter.Graphic.

Member Data Documentation

PanelSizeMode Otter.NineSlice.PanelSizeMode = PanelSizeMode.All

Determines how the size of the panel will be adjusted when setting PanelWidth and PanelHeight. If set to All, the entire panel will be the width and height. If set to Inside, the inside of the panel will be the width and height.

bool Otter.NineSlice.SnapHeight

When using PanelType.Tiled snap the height to increments of the tile height.

bool Otter.NineSlice.SnapWidth

When using PanelType.Tiled snap the width to increments of the tile width.

bool Otter.NineSlice.UseInsideOrigin

Draw the panel from the top left corner of the middle slice.

Property Documentation

Rectangle Otter.NineSlice.ClippingRegion
getset

Render the NineSlice through a clipping rectangle.

int Otter.NineSlice.PanelHeight
getset

Set the panel height of the NineSlice. This will update and rerender it.

PanelType Otter.NineSlice.PanelType
getset

The type of panel to use for the NineSlice.

int Otter.NineSlice.PanelWidth
getset

Set the panel width of the NineSlice. This will update and rerender it.

bool Otter.NineSlice.UsePanelClip
getset

Determines if the ClippingRegion is used or not.


The documentation for this class was generated from the following file: