Canvas
The Canvas is a wrapper for methods for drawing text, Textures and meshes on the local player's screen. Canvas objects are passed to various events and functions in the various classes, e.g. HUD, Weapon, GUI classes and Interactions.
See Canvas (UT) for Canvas properties and methods available in UT.
Properties
- bool bCenter
- Whether to center the text.
- bool bNoSmooth
- Whether bilinear filtering should not be applied.
- bool bRenderLevel
- Will render the level if enabled.
- float ClipX, ClipY
- Width and height of the clipping region.
- float CurX, CurY
- Current position for drawing relative to origin set by OrgX/OrgY.
- float OrgX, OrgY
- Origin for drawing and upper left corner of the clipping window.
- int SizeX, SizeY
- Zero-based actual dimensions.
- float SpaceX, SpaceY
- Spacing for after executing one of the Draw* methods, i.e. this contains the screen size of the last drawn element.
- byte Style
- The values of this variable correspond to the ERenderStyle enum of the Actor class.
- color DrawColor
- Color to use for drawing. White (R=255,G=255,B=255) means draw everything in its default colors. If any color component is lower than 255 the specific color component of the Material or Font will be drawn darker. Alpha values specify the opacity of the drawn Material or Font. (A=255 means completely opaque) Also see color blending.
- Plane ColorModulate
- Modulate all colors by this before rendering.
- float CurYL
- Largest Y size since DrawText.
- float FontScaleX, FontScaleY
- font Font
- Font for DrawText.
- font MedFont, SmallFont, TinyFont
- string MedFontName, SmallFontName, TinyFontName
- Viewport Viewport (const)
- Viewport that owns the canvas.
- pointer pCanvasUtil (const)
- Used internally.
Methods
Texture Drawing
- DrawTile (Material Mat, float XL, float YL, float U, float V, float UL, float VL)
- This draws a rectangle within the material onto the screen. The upper left of the material will be at the current pen position.
- Mat
- The material to draw.
- XL, YL
- Width and height of the material on the screen, in number of pixels.
- U, V
- coordinates, within the material, of the upper left of the rectangular window.
- UL, VL
- width and height, in pixels, of the window within the material.
- DrawTileClipped (Material Mat, float XL, float YL, float U, float V, float UL, float VL)
- Like DrawTile, but the material is clipped according to the region set by OrgX/OrgY and ClipX/ClipY.
- DrawTileStretched (Material Mat, float XL, float YL)
- Draws the whole material stretched to the specified size. The texture is divided into four parts and only the pixels along the horizontal and vertical center lines are stretched.
- DrawTileJustified (Material Mat, byte Justification, float XL, float YL)
- DrawTileScaled (Material Mat, float XScale, float YScale)
- Draws the whole material scaled as specified by the multipliers.
- DrawPattern (Material Tex, float XL, float YL, float Scale)
- Draws the scaled material and repeats it to fill a rectangle of the specified size.
- DrawIcon (Texture Tex, float Scale)
- Draws the whole texture once with the specified scaling. Unlike most other draw functions, this one doesn't work with all Material classes. Only materials subclassed from Texture can be used, i.e. you can't use it to draw modifiers (shaders, etc.) or ScriptedTextures.
- DrawRect (Texture Tex, float RectX, float RectY)
- Draws the whole texture stretched to the specified size.
- DrawVertical (float X, float height)
- Draw a vertical line. The line's color is specified through DrawColor.
- DrawHorizontal (float Y, float width)
- Draw a horizontal line.
- DrawLine (int direction, float size)
- DrawLine is special as it saves it's original position. Direction: 0 = up, 1 = down, 2 = left, 3 = right
- DrawBracket (float width, float height, float bracket_size)
- DrawBox (canvas canvas, float width, float height)
- Draws a box of the specified size. For some reason this function doesn't draw on the Canvas object you call it from, but needs a Canvas object as the first parameter.
Text Drawing
- DrawText (coerce string Text, optional bool CR)
- DrawTextClipped (coerce string Text, optional bool bCheckHotKey)
- StrLen (coerce string String, out float XL, out float YL)
- Get the size of a string when it would be drawn using the current font. The text will be wrapped according to the canvas width.
- TextSize (coerce string String, out float XL, out float YL)
- Get the size of a string when it would be drawn using the current font. The text will be clipped at the
- WrapStringToArray (string Text, out array<string> OutArray, float dx, string EOL)
- Takes Text and splits it based on how it would fit in the limitation of dx. Also will make a split when it encounters the characters contained in EOL. You can then use the strings of OutArray to make wrapped text by iterating through the array and placing each line of text one step lower than the last. dx would work best as an equation like Canvas.SizeX * 0.2 (20% of the Canvas width).
- WrapText (out String Text, out String Line, float dx, Font F, float FontScaleX) [static]
- DrawTextJustified (coerce string String, byte Justification, float x1, float y1, float x2, float y2)
- DrawScreenText (String Text, float X, float Y, EDrawPivot Pivot)
Actor Drawing
- DrawActor (Actor A, bool WireFrame, optional bool ClearZ, optional float DisplayFOV)
- DrawScreenActor (Actor A, optional float FOV, optional bool WireFrame, optional bool ClearZ)
- DrawPortal (int X, int Y, int Width, int Height, Actor CamActor, vector CamLocation, rotator CamRotation, optional int FOV, optional bool ClearZ)
- It doesn't work when using OpenGL.
- vector WorldToScreen (vector WorldLoc)
- Converts the given absolute world coordinates to canvas coordinates. The returned vector's X and Y components contain the coordinates. What is the Z component? a dot product of an angle maybe? – Wormbo
- GetCameraLocation (out vector CameraLocation, out rotator CameraRotation)
- Returns the camera's location and rotation.
- Clear (optional bool ClearRGB, optional bool ClearZ)
- SetScreenLight (int index, vector Position, color lightcolor, float radius)
- SetScreenProjector (int index, vector Position, color color, float radius, Texture tex)
Other Functions
- Reset ( )
- Resets the canvas properties.
- SetPos(float X, float Y)
- Sets CurX/Y.
- SetOrigin(float X, float Y)
- Sets OrgX/Y.
- SetClip(float X, float Y)
- Sets ClipX/Y.
- SetDrawColor (byte R, byte G, byte B, optional byte A)
- Sets the DrawColor.
- Color MakeColor(byte R, byte G, byte B, optional byte A) [static]
- Returns a Color struct with the specified values. When A is not specified or set to 0, then A=255 is used.