Graphics

Description

sealed class Tinman.Engine.Drawing.Graphics

Derived from

Disposable abstract
IBeginEnd
ILineThickness

The Graphics class provides methods for performing pixel-perfect 2D drawing.

Pixel coordinates always refer to the center of a pixel, e.g. the pixel coordinates (0|0) refer to the center of the top-left pixel in the viewport. The center of the lower-right pixel is at (ScreenWidth-1|ScreenHeight-1). Names of method parameters that take pixel coordinates have the 'pixel' prefix (e.g. 'pixelX').

Screen coordinates refer to the whole viewport: the screen coordinates (0|0) refer to the top-left corner of the top-left pixel in the viewport. The lower-right corner of the lower-right pixel is at (ScreenWidth|ScreenHeight). Names of method parameters that take screen coordinates have the 'screen' prefix (e.g. 'screenX').

The Flush method may be called to make sure that all buffered work gets submitted. When this method has returned, all used resources may be disposed, without any impact on 2D rendering.

The Draw* methods allow passing of null resources (e.g. Bitmap, ITexture2D, PixelFont). In this case, these methods draw nothing and return silently.

The members of this class may be grouped by their usage:

Public / Constants

Alpha


public constant Alpha → (3:int32)

Source data from alpha channel of texture.

Blue


public constant Blue → (2:int32)

Source data from blue color channel.

Green


public constant Green → (1:int32)

Source data from green color channel.

Luminance


public constant Luminance → (6:int32)

Source data from average luminance of red, green and blue channels.

One


public constant One → (5:int32)

Source data as always one.

Red


public constant Red → (0:int32)

Source data from red color channel.

Zero


public constant Zero → (4:int32)

Source data as always zero.

Public / Constructors

Graphics


public constructor Graphics → (1)

context in : IGraphicsContext

[not-null]
The graphics context to use.

Creates a new instance of Graphics.

The recommended way to obtain an instance of this class is by querying the shared graphics object of the graphics context (see IGraphicsContext.Graphics).

RenderException

If a graphics subsystem error has occurred.

Public / Methods

Clear


[BeginEnd]
public method Clear → (1)

color in : int64

The color to clear to.

Clears the current clip rectangle to the given color.

Color​Channels


public method ColorChannels → (4)

red opt : int32 = Graphics.Red

The source for the output red channel.

green opt : int32 = Graphics.Green

The source for the output green channel.

blue opt : int32 = Graphics.Blue

The source for the output blue channel.

alpha opt : int32 = Graphics.Alpha

The source for the output alpha channel.

Specifies the color channel sources for 2D rendering.

The following sources may be specified:
Red, Green, Blue, Alpha, Zero, One, Luminance.

Color channel values are sourced from the texture samples. When rendering without textures, an opaque white texture sample is used instead. Modulation colors that have been passed to render methods will be applied after the color sources are applied.

Compute​Anchor​X

2 overloads


[Pure]
public static method ComputeAnchorX1 → (3)

anchor in : Anchor

The anchor type.

pixelRight in : int32

Pixel coordinate of right edge.

pixelLeft opt : int32 = 0

Pixel coordinate of left edge.

returns → int32

The anchor pixel X-coordinate.

Computes the position for the given anchor.


[Pure]
public static method ComputeAnchorX2 → (3)

anchor in : Anchor

The anchor type.

pixelRight in : float32

Pixel coordinate of right edge.

pixelLeft opt : float32 = 0

Pixel coordinate of left edge.

returns → float32

The anchor pixel X-coordinate.

Computes the position for the given anchor.

Compute​Anchor​Y

2 overloads


[Pure]
public static method ComputeAnchorY1 → (4)

anchor in : Anchor

The anchor type.

pixelBottom in : int32

Pixel coordinate of bottom edge.

pixelTop opt : int32 = 0

Pixel coordinate of top edge.

pixelBaseline opt : int32 = 0

Pixel coordinate of baseline.

returns → int32

The anchor pixel Y-coordinate.

Computes the position for the given anchor.


[Pure]
public static method ComputeAnchorY2 → (4)

anchor in : Anchor

The anchor type.

pixelBottom in : float32

Pixel coordinate of bottom edge.

pixelTop opt : float32 = 0

Pixel coordinate of top edge.

pixelBaseline opt : float32 = 0

Pixel coordinate of baseline.

returns → float32

The anchor pixel Y-coordinate.

Computes the position for the given anchor.

Create​Bitmap


[OwnerReturn]
public method CreateBitmap → (3)

width in : int32

[>0]
The image width, in pixels.

height in : int32

[>0]
The image height, in pixels.

flags opt : BitmapFlags = BitmapFlags.Default

The image flags.

returns → Bitmap

The created image resource.

Creates a new image resource.

RenderException

If a graphics subsystem error has occurred.

Create​Primitive​Buffer


[OwnerReturn]
public method CreatePrimitiveBuffer → (1)

capacity in : int32

[>0]
The buffer capacity, in vertices.

returns → IVertexBuffer

The vertex buffer for 2D primitives (see remarks).

Creates a vertex buffer that can be used to draw batched 2D primitives.

The returned buffer has the following layout:

  1. Byte offset #0: Screen X-coordinate (32-bit floating point).

  2. Byte offset #4: Screen Y-coordinate (32-bit floating point).

  3. Byte offset #8: Depth coordinate (32-bit floating point).

  4. Byte offset #12: Color value (32-bit integer, A8R8G8B8).

  5. Byte offset #16: Texture U-coordinate (32-bit floating point).

  6. Byte offset #20: Texture V-coordinate (32-bit floating point).

  7. Byte offset #24: Unused padding bytes (should be 0).

  8. Byte offset #32: End of vertex data (exclusive).

Different layouts may be used, as long as the following vertex elements are present:

RenderException

If a graphics subsystem error has occurred.

Draw​Bitmap

2 overloads


[BeginEnd]
public method DrawBitmap1 → (4)

bitmap in : Bitmap

The image to draw.

pixel in : Vec2I

Pixel coordinates of image anchor.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.White

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

See also

Graphics.Offset


[BeginEnd]
public method DrawBitmap2 → (5)

bitmap in : Bitmap

The image to draw.

pixelX in : int32

Pixel X-coordinate of image anchor.

pixelY in : int32

Pixel Y-coordinate of image anchor.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.White

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

See also

Graphics.Offset

Draw​Bitmap​Outline


[BeginEnd]
public method DrawBitmapOutline → (5)

bitmap in : Bitmap

The image to draw.

pixelX in : int32

Pixel X-coordinate of image anchor.

pixelY in : int32

Pixel Y-coordinate of image anchor.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.Black

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

See also

Graphics.Offset

Draw​Bitmap​Part

2 overloads


[BeginEnd]
public method DrawBitmapPart1 → (5)

bitmap in : Bitmap

The image to draw.

part in : Box2I

The bitmap part to draw.

pixel in : Vec2I

Pixel coordinates of image anchor.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.White

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

See also

Graphics.Offset


[BeginEnd]
public method DrawBitmapPart2 → (9)

bitmap in : Bitmap

The image to draw.

partX in : int32

[0..bitmap.Width]
X-coordinate of top-left bitmap pixel to draw.

partY in : int32

[0..bitmap.Height]
Y-coordinate of top-left bitmap pixel to draw.

partWidth in : int32

[0..bitmap.Width-partX]
Width of bitmap part to draw, in pixels.

partHeight in : int32

[0..bitmap.Height-partY]
Height of bitmap part to draw, in pixels.

pixelX in : int32

Pixel X-coordinate of image anchor.

pixelY in : int32

Pixel Y-coordinate of image anchor.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.White

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

See also

Graphics.Offset

Draw​Bitmap​Stretch


[BeginEnd]
public method DrawBitmapStretch → (7)

bitmap in : Bitmap

The image to draw.

pixelX in : int32

Pixel X-coordinate of image anchor.

pixelY in : int32

Pixel Y-coordinate of image anchor.

width in : int32

[>0]
Width of image on screen.

height in : int32

[>0]
Height of image on screen.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.White

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

See also

Graphics.Offset

Draw​Bitmap​Transform


[BeginEnd]
public method DrawBitmapTransform → (6)

bitmap in : Bitmap

The image to draw.

transform in : Mat3F

The transformation matrix to apply (see remarks).

pixelX in : int32

Pixel X-coordinate of image anchor.

pixelY in : int32

Pixel Y-coordinate of image anchor.

anchor opt : Anchor = Anchor.TopLeft

The image anchor to use.

color opt : int64 = Colors.White

Image pixels will be modulated by this color (see Colors) value.

Draws a bitmap image onto the screen.

First the untransformed bitmap bounds are computed from the given image anchor. Then the given transformation matrix is applied to the corner vertices of the bitmap bounds. Finally, a textured quad is rendered using the transformed corner vertices.

Draw​Char


[BeginEnd]
public method DrawChar → (6)

font in : PixelFont

The font to use.

in : char

The character to draw.

pixelX in : int32

Pixel X-coordinate of anchor point.

pixelY in : int32

Pixel Y-coordinate of anchor point.

color in : int64

The color to use (see Colors).

anchor opt : Anchor = Anchor.TopLeft

The anchor to use.

Draws a character glyph onto the 2D canvas.

See also

PixelFont

Draw​Circle


[BeginEnd]
public method DrawCircle → (5)

pixelX in : float32

Pixel X-coordinate of circle center.

pixelY in : float32

Pixel Y-coordinate of circle center.

radius in : float32

Radius of circle, in pixel units.

colorBorder in : int64

Color (see Colors) of circle border or 0 for no border.

colorFill opt : int64 = 0

Color (see Colors) of circle fill of 0 for no fill.

Draws a circle.

Draw​Line


[BeginEnd]
public method DrawLine → (5)

pixelX1 in : float32

Pixel X-coordinate of first point.

pixelY1 in : float32

Pixel Y-coordinate of first point.

pixelX2 in : float32

Pixel X-coordinate of second point.

pixelY2 in : float32

Pixel Y-coordinate of second point.

color in : int64

The color (see Colors) to use.

Draws a line segment.

Draw​Line​Horizontal


[BeginEnd]
public method DrawLineHorizontal → (4)

pixelX in : int32

Pixel X-coordinate of first line endpoint.

pixelY in : int32

Pixel Y-coordinate of line.

length in : int32

Length of the line, in pixels.

color in : int64

The color (see Colors) value to use.

Draws a horizontal line.

See also

Graphics.Offset

Draw​Line​Vertical


[BeginEnd]
public method DrawLineVertical → (4)

pixelX in : int32

Pixel X-coordinate of line.

pixelY in : int32

Pixel Y-coordinate of first line endpoint.

length in : int32

Length of the line, in pixels.

color in : int64

The color (see Colors) value to use.

Draws a vertical line.

See also

Graphics.Offset

Draw​Polygon

3 overloads


[BeginEnd]
public method DrawPolygon1 → (4)

color in : int64

Modulation color for the polygon vertex colors.

vertices in : Vertex [ ]

[not-null]
The polygon vertices.

first opt : int32 = 0

[0..vertices.Length]
Index of first polygon vertex.

count opt : int32 = -1

[-1..vertices.Length-first]
Number of polygon vertices. If -1 all remaining vertices are used.

Draws a simple polygon.


[BeginEnd]
public method DrawPolygon2 → (4)

texture in : Bitmap

The texture image to use.

vertices in : Vertex [ ]

[not-null]
The polygon vertices.

first opt : int32 = 0

[0..vertices.Length]
Index of first polygon vertex.

count opt : int32 = -1

[-1..vertices.Length-first]
Number of polygon vertices. If -1 all remaining vertices are used.

Draws a simple polygon.


[BeginEnd]
public method DrawPolygon3 → (4)

texture in : ITexture2D

The texture image to use.

vertices in : Vertex [ ]

[not-null]
The polygon vertices.

first opt : int32 = 0

[0..vertices.Length]
Index of first polygon vertex.

count opt : int32 = -1

[-1..vertices.Length-first]
Number of polygon vertices. If -1 all remaining vertices are used.

Draws a simple polygon.

Draw​Polyline


[BeginEnd]
public method DrawPolyline → (5)

closed in : bool

Connect the last vertex with the first vertex (i.e. draw a closed polyline)?

color in : int64

Modulation color for the polyline vertex colors.

vertices in : Vertex [ ]

[not-null]
The polyline vertices.

first opt : int32 = 0

[0..vertices.Length]
Index of first polyline vertex.

count opt : int32 = -1

[-1..vertices.Length-first]
Number of polyline vertices. If -1 all remaining vertices are used.

Draws a polyline.

Draw​Primitive


[BeginEnd]
public method DrawPrimitive → (4)

primitive in : Primitive

The primitive to draw.

first in : int32

[>=0]
First vertex to draw (see remarks).

count in : int32

[>=0]
Number of vertices to draw (see remarks).

matrix in : Mat3F

The transformation matrix to apply to the primitive vertices, before applying the current translation amounts (see Translation).

Draws a batched 2D primitive.

If an index buffer has been specified to DrawPrimitivePrepare, the given first in and count in parameters refer to elements in the index buffer. Otherwise, they refer to vertices in the 2D vertex buffer.

Draw​Primitive​Begin


[BeginEnd]
public method DrawPrimitiveBegin → (3)

primitive in : Primitive

The primitive to render.

texture opt : ITexture2D = null

The texture image to use.

slice opt : int32 = 0

The texture slice to use.

Begins to render a 2D primitive which vertices are specified via the Vertex(…​) method.

Draw​Primitive​End


[BeginEnd]
public method DrawPrimitiveEnd → ()

Finishes rendering of the current 2D primitive.

Draw​Primitive​Prepare


[BeginEnd]
public method DrawPrimitivePrepare → (3)

geometryBuffer in : IGeometryBuffer

The geometry buffer (see CreatePrimitiveBuffer) or null to stop rendering of batched primitives (see remarks).

texture opt : ITexture2D = null

Optional texture to use.

slice opt : int32 = 0

The texture array slice to use.

Prepares to render batched 2D primitives.

After all batched primitives have been submitted, this method should be called to set the geometry buffer to null. Performing any other subsequent non-batched rendering will have the same effect.

Draw​Primitive​Vertex

4 overloads


[BeginEnd]
public method DrawPrimitiveVertex1 → (1)

in : Vertex

The vertex.

Specifies the next vertex for the current 2D primitive.


[BeginEnd]
public method DrawPrimitiveVertex2 → (2)

in : Vertex

The vertex.

color in : int64

The color to multiply with Vertex.Color.

Specifies the next vertex for the current 2D primitive.


[BeginEnd]
public method DrawPrimitiveVertex3 → (3)

screenX in : float32

Screen X-coordinate of vertex.

screenY in : float32

Screen Y-coordinate of vertex.

color in : int64

The diffuse vertex color (see Colors).

Specifies the next vertex for the current 2D primitive.


[BeginEnd]
public method DrawPrimitiveVertex4 → (5)

screenX in : float32

Screen X-coordinate of vertex.

screenY in : float32

Screen Y-coordinate of vertex.

color in : int64

The diffuse vertex color (see Colors).

in : float32

Texture U-coordinate.

in : float32

Texture V-coordinate.

Specifies the next vertex for the current 2D primitive.

Draw​Rectangle

2 overloads


[BeginEnd]
public method DrawRectangle1 → (3)

bounds in : Box2I

The rectangle bounds, in pixel coordinates.

colorBorder in : int64

The border color (see Colors) to use or 0 for no border.

colorFill opt : int64 = 0

The fill color (see Colors) to use or 0 for no fill.

Draws a rectangle.

See also

Graphics.Offset


[BeginEnd]
public method DrawRectangle2 → (6)

pixelX in : int32

Pixel X-coordinate of top-left corner of rectangle.

pixelY in : int32

Pixel Y-coordinate of top-left corner of rectangle.

width in : int32

Width of rectangle, in pixels.

height in : int32

Height of rectangle, in pixels.

colorBorder in : int64

The border color (see Colors) to use or 0 for no border.

colorFill opt : int64 = 0

The fill color (see Colors) to use or 0 for no fill.

Draws a rectangle.

See also

Graphics.Offset

Draw​Round​Rectangle

2 overloads


[BeginEnd]
public method DrawRoundRectangle1 → (5)

bounds in : Box2I

The rectangle bounds, in pixel coordinates.

round in : int32

Radius of round corners, in pixel units.

colorBorder in : int64

The border color (see Colors) to use or 0 for no border.

colorFill opt : int64 = 0

The fill color (see Colors) to use or 0 for no fill.

corners opt : Corner = Corner.All

The round rectangle corners.

Draws a rectangle with round corners.

See also

Graphics.Offset


[BeginEnd]
public method DrawRoundRectangle2 → (8)

pixelX in : int32

Pixel X-coordinate of top-left corner of rectangle.

pixelY in : int32

Pixel Y-coordinate of top-left corner of rectangle.

width in : int32

Width of rectangle, in pixels.

height in : int32

Height of rectangle, in pixels.

round in : int32

Radius of round corners, in pixel units.

colorBorder in : int64

The border color (see Colors) to use or 0 for no border.

colorFill opt : int64 = 0

The fill color (see Colors) to use or 0 for no fill.

corners opt : Corner = Corner.All

The round rectangle corners.

Draws a rectangle with round corners.

Draw​Shape

2 overloads


[BeginEnd]
public method DrawShape1 → (3)

shape in : IShape

[not-null]
The vector shape.

colorBorder in : int64

The color to use for drawing the shape triangles.

colorFill opt : int64 = 0

The color to use for drawing the shape edges.

Draws the given vector shape (see IShape.EdgeAt).

Shape triangles (see IShape.TriangleAt) will be drawn with the given colorFill opt. Shape edges (see IShape.EdgeAt will be drawn with the given colorBorder in. Aggregated shapes (see IShape.ShapeAt) will be drawn by calling this method recursively. Shape vertex coordinates are interpreted as screen coordinates.


[BeginEnd]
public method DrawShape2 → (4)

shape in : IShape

[not-null]
The vector shape.

transform in : Mat3D

The transformation matrix from shape coordinates to screen coordinates.

colorBorder in : int64

The color to use for drawing the shape triangles.

colorFill opt : int64 = 0

The color to use for drawing the shape edges.

Draws the given vector shape.

Shape triangles (see IShape.TriangleAt) will be drawn with the given colorFill opt. Shape edges (see IShape.EdgeAt will be drawn with the given colorBorder in. Aggregated shapes (see IShape.ShapeAt) will be drawn by calling this method recursively.

Draw​String


[BeginEnd]
public method DrawString → (6)

font in : PixelFont

The font to use.

text in : string

[not-null]
The text to draw.

pixelX in : int32

Pixel X-coordinate of anchor point.

pixelY in : int32

Pixel Y-coordinate of anchor point.

color in : int64

The color (see Colors) to use.

anchor opt : Anchor = Anchor.TopLeft

The anchor to use.

Draws a pixel-perfect string onto the 2D canvas.

Draw​String​Outline


[BeginEnd]
public method DrawStringOutline → (7)

font in : PixelFont

The font to use.

text in : string

[not-null]
The text to draw.

pixelX in : int32

Pixel X-coordinate of anchor point.

pixelY in : int32

Pixel Y-coordinate of anchor point.

textColor in : int64

The text color (see Colors) to use.

anchor opt : Anchor = Anchor.TopLeft

The anchor to use.

outlineColor opt : int64 = Colors.Black & Colors.Opaque50

The outline color (see Colors) to use.

Draws a pixel-perfect string onto the 2D canvas.

Find​Anchor


[Pure]
public static method FindAnchor → (2)

direction in : Vec2D

Direction vector pointing towards a rectangle.

baseline opt : bool = true

true uses Anchor.Base as the rectangle bottom edge, false uses Anchor.Bottom.

returns → Anchor

The best anchor.

Finds the best anchor on a rectangle for the given screen direction.

Flip​Anchor


[Pure]
public static method FlipAnchor → (1)

anchor in : Anchor

The anchor to flip.

returns → Anchor

The flipped anchor.

Flips the given anchor.

Flush


public method Flush → ()

Flushes buffered render commands to the GPU.

Usually it is not necessary to call this method, because a flush automatically happens when IBeginEnd.End is called.

Fullscreen


public method Fullscreen → ()

Sets the Bounds of this Graphics object to full-screen (i.e. the size of the current render target, see IGraphicsContext.Size).

Load​Bitmap​From

2 overloads


[OwnerReturn]
public method LoadBitmapFrom1 → (2)

file in : Path

[not-null]
The file path.

flags opt : BitmapFlags = BitmapFlags.Default

The image flags to apply when loading the image file.

returns → Bitmap

The loaded image resource.

Loads an image resource from the given file.

This method will always perform sRGB decompression on file in.

IOException

If an I/O error has occurred.

ValidatingException

If the image reader has reported an error, for example because of an unsupported file format feature.

RenderException

If a graphics subsystem error has occurred.


[OwnerReturn]
public method LoadBitmapFrom2 → (2)

image in : IImage

[not-null]
The image descriptor.

flags opt : BitmapFlags = BitmapFlags.Default

The image flags to apply when loading the image file.

returns → Bitmap

The loaded image resource.

Loads an image resource from the given image descriptor.

IOException

If an I/O error has occurred.

ValidatingException

If the image reader has reported an error, for example because of an unsupported file format feature.

RenderException

If a graphics subsystem error has occurred.

Load​Font​From


[OwnerReturn]
public method LoadFontFrom → (1)

file in : Path

[not-null]
The file path.

returns → PixelFont

The loaded font resource.

Loads a pixel font resource from the given image file.

IOException

If an I/O error has occurred.

ValidatingException

If the given image is not a valid pixel font, see PixelFontBuilder.

RenderException

If a graphics subsystem error has occurred.

See also

PixelFontBuilder

Mask


[BeginEnd]
public method Mask → (2)

texture opt : ITexture2D = null

The opacity mask texture or null to disable the mask.

screen opt : Box2F = default(Box2F)

The screen bounds of the opacity mask or Box2F.Empty to disable the mask.

Specifies an opacity mask to use for subsequent rendering.

The opacity mask is enabled by passing a non-null texture opt and non-empty screen opt bounds. While enabled, the mask will affect rendering in the following way:

  • For each rendered pixel, the screen coordinates of the pixel center are transformed with a matrix which maps the screen coordinates given by Box2F.TopLeft and Box2F.BottomRight of screen opt to the texture coordinates (0,0) and (1,1).

  • The given texture opt is sampled at the computed texture coordinates, using SamplerStatePreset.LinearClamp. The red channel of the texture sample is used as the mask opacity, the other channels are ignored.

  • Applying the color channels (see ColorChannels) yields the pixel color. The alpha channel of the pixel color is modulated with the mask opacity.

Pop​Clip


[BeginEnd]
public method PopClip → ()

Restores the most recent clip rectangle from the clip stack.

Pop​Depth


[BeginEnd]
public method PopDepth → ()

Restores the previous depth value.

Push​Clip

2 overloads


[BeginEnd]
public method PushClip1 → (1)

bounds in : Box2I

The bounds of the clip rectangle, in pixel coordinates.

returns → bool

true if the clip rectangle contains at least one screen pixel, false if it is empty.

Pushes the current clip rectangle onto the stack, intersects it with the given rectangle and sets the clip rectangle to the result.

See also

Graphics.PopClip


[BeginEnd]
public method PushClip2 → (4)

pixelX in : int32

Pixel X-coordinate of top-left corner of clip rectangle.

pixelY in : int32

Pixel Y-coordinate of top-left corner of clip rectangle.

width in : int32

Width of clip rectangle, in pixels.

height in : int32

Height of clip rectangle, in pixels.

returns → bool

true if the clip rectangle contains at least one screen pixel, false if it is empty.

Pushes the current clip rectangle onto the clip stack and intersects it with the given rectangle.

The current Translation is applied to pixelX in and pixelY in.

See also

Graphics.PopClip

Push​Depth


[BeginEnd]
public method PushDepth → (1)

depth in : float32

The depth value, in the range [0..1].

Uses the given depth value for all subsequent 2D primitives.

Reset


public method Reset → ()

Resets the render state to default values.

This method is called automatically when the outermost call to IBeginEnd.Begin is made and when Bounds is set between calls to IBeginEnd.Begin and IBeginEnd.End. The following render state is reset:

Test​Clip


public method TestClip → (4)

pixelX in : int32

Pixel X-coordinate of top-left corner of clip rectangle.

pixelY in : int32

Pixel Y-coordinate of top-left corner of clip rectangle.

width in : int32

[>=0]
Width of clip rectangle, in pixels.

height in : int32

[>=0]
Height of clip rectangle, in pixels.

returns → bool

true if the intersection of the rectangles contains at least one screen pixel, false if it is empty.

Tests if the current clip rectangle intersects with the given clip rectangle.

Translate

2 overloads


[BeginEnd]
public method Translate1 → (1)

pixel in : Vec2I

Translation amount, in pixels.

Translates all 2D rendering by the given amount.


[BeginEnd]
public method Translate2 → (2)

pixelX in : int32

Horizontal translation amount, in pixels.

pixelY in : int32

Vertical translation amount, in pixels.

Translates all 2D rendering by the given amount.

Write


public static method Write → (3)

vertex in : Vertex

The vertex to write.

buffer in : ByteBuffer

[not-null]
The target buffer.

depth opt : float32 = 0

The screen depth value (see PushDepth).

Writes the given vertex to the specified buffer.

Public / Attributes

Bounds


public attribute Bounds → (get,set)

value : Box2I

The bounds, in pixel coordinates.

The bounds of this graphics object on the render target(s) of the graphics context.

See also

Graphics.Reset

Cache


public attribute Cache → (get)

value : ResourceCache

[not-null]
The shared resource cache.

The shared resource cache of this Graphics instance.

Resources that have been obtained via IResourceCache.GetNull will be disposed when this Graphics object is disposed.

Clip


public attribute Clip → (get)

value : Box2I

The clip rectangle, in screen pixel coordinates.

Returns the current clip rectangle.

Context


public attribute Context → (get)

value : IGraphicsContext

[not-null]
The graphics context.

Returns the graphics context.

Default​Font


public attribute DefaultFont → (get)

value : PixelFont

[not-null]
The simple font.

Returns a PixelFont object that has been created from ColorBuffer.DrawChar.

Loader


public attribute Loader → (get)

value : ResourceLoader

[not-null]
The shared resource loader.

The shared resource loader of this Graphics instance.

Offset


public attribute Offset → (get,set)

value : Vec2F

The sub-pixel offsets.

Specifies the sub-pixel offset for subsequent rendering of pixel-aligned visuals.

Only the fractional parts of the components of the given vector are used, the integral parts are set to zero.

Draw methods that take integer coordinates make use of the sub-pixel offset. Namely, these are:

Please note that draw methods that use pixel fonts do not apply the sub-pixels offset.

Screen​Bounds


public attribute ScreenBounds → (get)

value : Box2I

The screen bounds.

Returns the screen bounds, where (0,0) is the top-left corner.

Screen​Height


public attribute ScreenHeight → (get)

value : int32

[>0]
The screen height, in pixels.

Returns the screen height.

Screen​Size


public attribute ScreenSize → (get)

value : Vec2I

The screen size, in pixels.

Returns the screen size.

Screen​Width


public attribute ScreenWidth → (get)

value : int32

[>0]
The screen width, in pixels.

Returns the screen width.

Translation


public attribute Translation → (get,set)

value : Vec2I

The current translation.

The current translation amounts.