| Home Page | Recent Changes | Preferences

Canvas (UT)

UT :: Object (UT) >> Canvas (Package: Engine)

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 following classes:

Class Comments
Actor (UT) Declares the event RenderOverlays. RenderOverlays is called automatically when this actor is the local PlayerPawn's ViewTarget.
Console Declares the events PreRender and PostRender. PreRender is automatically called on each frame before the world is rendered and PostRender afterwards.
Pawn (UT) Declares the events PreRender and PostRender (see above). Called on each frame for any Pawn possessed by the local player.
HUD (UT) Declares the events PreRender and PostRender (see above). Called on each frame while the HUD is visible. In addition, RenderOverlays (declared in Actor (UT)) is called by PlayerPawn on each frame in its own RenderOverlays event. If you create your own HUD (UT) subclass, it's usually a better idea to overwrite just some of the other functions declared in HUD or ChallengeHUD (or a deeper subclass) which take care of drawing individual parts of the HUD.
ScoreBoard Declares the function ShowScores, called by ChallengeHUD on each frame in PostRender when the scoreboard is displayed. Overwrite this function in a subclass to implement your own scoreboard.
Mutator (UT) Declares the event PostRender, called by ChallengeHUD on each frame in PostRender if this mutator has registered itself as a HUD mutator.
Weapon (UT) RenderOverlays and PostRender (declared in Actor) are called by Pawn (UT) on each frame in RenderOverlays/PostRender when this weapon is currently active. (See also the bOwnsCrosshair property in Weapon (UT).)
UWindowWindow BeforePaint, Paint and AfterPaint are called each frame to draw the window or dialog control.

See Canvas for Canvas properties and methods available in UT2003.

Sobiwan: I looked for the function PostRender() in the the above classes and every one of them calls PostRender (canvas Canvas). Since functions can pass a class type and a name, is the syntax for this case PostRender (type name)? Is it saying "run the postrender function on the class type canvas on the class name Canvas"? I dont understand why not just pass the type (canvas) since that is its name.

RDGDanClark: The function needs to know the type of variable that you're passing it, in all cases. What they've done here is a pretty good example of bad programming style. Just as you should never have a variable in your code of type int called Int or of type float called Float, you should never have a variable of type canvas called Canvas. You're right about the translation though, it is saying "run the PostRender function using a passed variable of type canvas that is called Canvas".

Properties

float ClipX, ClipY
float CurX, CurY
float OrgX, OrgY
float SpaceX, SpaceY
float SizeX, SizeY (const)
Zero-based actual dimensions.
float CurYL
byte Style
The values of this variable correspond to the ERenderStyle enum of the Actor (UT) class, but that can't be used in this class.
bool bCenter
bool bNoSmooth
Whether bilinear filtering should not be applied.
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 Texture (UT) or Font will be drawn darker. (or more translucent, see color blending)
Font Font
Font SmallFont, MedFont, BigFont, LargeFont
Viewport ViewPort (const)
float Z

Methods

Texture Drawing

DrawTile (Texture (UT) Tex, float XL, float YL, float U, float V, float UL, float VL)
This draws a rectangle within the texture onto the screen. The upper left of the texture will be at the current pen position.
  • Tex - the texture to draw.
  • XL, YL - width and height on the screen, in number of pixels.
  • U, V - coordinates, within the texture, of the upper left of the rectangular window.
  • UL, VL - width and height, in pixels, of the window within the texture.
DrawTileClipped (Texture (UT) Tex, float XL, float YL, float U, float V, float UL, float VL)
DrawPattern (Texture (UT) Tex, float XL, float YL, float Scale)
This draws the specifed texture onto the screen, tiling it to fit a rectangle. The upper left of the rectangle will be at the current pen position.
  • Tex - the texture to draw.
  • XL, YL - width and height of the rectangle.
  • Scale - scale the texture (proportionately) by this ratio.

Draconx: There are some bizarre things I've noticed with this function. Try using it to draw onto a UWindow, then move that UWindow around to see an interesting effect. I will have to investigate exactly what this function does later. For drawing tiled backgrounds on UWindows, the DrawTile() function (defined in UWindowWindow) seems to work much better.

DrawIcon (Texture (UT) Tex, float Scale)
This draws and proportionately scales the specified texture onto the screen. The upper left of the texture will be at the current pen position.
  • Tex - the texture to draw.
  • Scale - scale the texture by this ratio.
DrawRect (Texture (UT) Tex, float RectX, float RectY)
This draws and disproportionately scales the specified texture onto the screen. The upper left of the texture will be at the current pen position.
  • Tex - the texture to draw.
  • RectX - the new width of the texture
  • RectY - the new height of the texture

Text Drawing

StrLen (coerce string String, out float XL, out float YL)
Get the size of a string when it would be drawn by DrawText() using the current font.
DrawText (coerce string Text, optional bool CR)
DrawTextClipped (coerce string Text, optional bool bCheckHotKey)
TextSize (coerce string String, out float XL, out float YL)
Get the size of a string when it would be drawn by DrawTextClipped() using the current font.

Actor Drawing

DrawActor (Actor (UT) A, bool WireFrame, optional bool ClearZ)
Draws the actor A at its current location, whether it's actually visible or not. The actor can be drawn as wire frame or how it actually looks. ClearZ causes the actor to be drawn on top of everything else, i.e. it will be visible even if it would normally be (partially or completely) obscured by other objects.
DrawClippedActor (Actor (UT) A, bool WireFrame, int X, int Y, int XB, int YB, optional bool ClearZ)
Same as DrawActor(), but only draws within the rectangle specified by X, Y, XB and YB.

Misc Stuff

DrawPortal (int X, int Y, int Width, int Height, Actor (UT) CamActor, vector CamLocation, rotator CamRotation, optional int FOV, optional bool ClearZ)
Note: This doesn't draw sprites (this includes particles and coronas) correctly in UT.
Reset ( )
Resets the canvas properties.
SetPos (float X, float Y)
Sets the drawing position.
SetOrigin (float X, float Y)
Sets the origin of the canvas by changing the OrgX and OrgY properties.
SetClip (float X, float Y)
Sets the clipping size of the canvas by changing the ClipX and ClipY properties.

Category Class (UT)

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In