UCanvas

A drawing canvas.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/Canvas.h

Include

#include "Engine/Canvas.h"

Syntax

class UCanvas : public UObject

Remarks

A drawing canvas.

Variables

Name Description

Public variable

uint32: 1

 

bCenterX

Public variable

uint32: 1

 

bCenterY

Public variable

uint32: 1

 

bNoSmooth

Public variable

int32

 

CachedDisplayHeight

Public variable

int32

 

CachedDisplayWidth

Public variable

FCanvas *

 

Canvas

Public variable

float

 

ClipX

Public variable

float

 

ClipY

Public variable

FPlane

 

ColorModulate

Internal.

Public variable

UTexture2D *...

 

DefaultTexture

Public variable

FDisplayDebugMa...

 

DisplayDebugManager

Public variable

FColor

 

DrawColor

Public variable

UTexture2D *...

 

GradientTexture0

Public variable

FQuat

 

HmdOrientation

Public variable

float

 

OrgX

Modifiable properties.

Public variable

float

 

OrgY

Public variable

UReporterGraph ...

 

ReporterGraph

Helper class to render 2d graphs on canvas

Public variable

int32

 

SafeZonePadEX

Public variable

int32

 

SafeZonePadEY

Public variable

int32

 

SafeZonePadX

Cached data for safe zone calculation.

Public variable

int32

 

SafeZonePadY

Public variable

FSceneView *...

 

SceneView

Public variable

int32

 

SizeX

Public variable

int32

 

SizeY

Public variable

int32

 

UnsafeSizeX

Public variable

int32

 

UnsafeSizeY

Public variable

FMatrix

 

ViewProjectionMatrix

Constructors

Name Description

Public function

UCanvas

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function

void

 

ApplySafeZoneTransform()

Applies the current Platform's safe zone to the current Canvas position.

Public function Static

void

 

CanvasStringSize

(
    FTextSizingParameters& Parameters,
    const TCHAR* pText
)

Calculates the size of the specified string.

Public function Static

void

 

ClippedStrLen

(
    const UFont* Font,
    float ScaleX,
    float ScaleY,
    int32& XL,
    int32& YL,
    const TCHAR* Text
)

Calculate the length of a string.

Public function

FFontRenderI...

 

CreateFontRenderInfo

(
    bool bClipText,
    bool bEnableShadow,
    FLinearColor GlowColor,
    FVector2D GlowOuterRadius,
    FVector2D GlowInnerRadius
)

Constructor for FontRenderInfo

Public function Const

void

 

Deproject

(
    FVector2D ScreenPos,
    FVector& WorldOrigin,
    FVector& WorldDirection
)

Transforms 2D screen coordinates into a 3D world-space origin and direction.

Public function Virtual

void

 

DrawDebugGraph

(
    const FString& Title,
    float ValueX,
    float ValueY,
    float UL_X,
    float UL_Y,
    float W,
    float H,
    FVector2D RangeX,
    FVector2D RangeY
)

Draws a graph comparing 2 variables. Useful for visual debugging and tweaking.

Public function

void

 

DrawIcon

(
    FCanvasIcon Icon,
    float X,
    float Y,
    float Scale
)

Draw a CanvasIcon at the desired canvas position.

Public function

void

 

DrawItem

(
    FCanvasItem& Item,
    float X,
    float Y
)

Draw a CanvasItem at the given coordinates

Public function

void

 

DrawItem

(
    FCanvasItem& Item,
    const FVector2D& InPosition
)

Draw a CanvasItem at the given coordinates

Public function

void

 

DrawItem

(
    FCanvasItem& Item
)

Draw a CanvasItem

Public function

void

 

DrawScaledIcon

(
    FCanvasIcon Icon,
    float X,
    float Y,
    FVector Scale
)

Draw a scaled CanvasIcon at the desired canvas position.

Public function

float

 

DrawText

(
    const UFont* InFont,
    const FString& InText,
    float X,
    float Y,
    float XScale,
    float YScale,
    const FFontRenderInfo& RenderInfo
)

Draws a string of text to the screen.

Public function

float

 

DrawText

(
    const UFont* InFont,
    const FText& InText,
    float X,
    float Y,
    float XScale,
    float YScale,
    const FFontRenderInfo& RenderInfo
)

Public function

void

 

DrawTile

(
    UTexture* Tex,
    float X,
    float Y,
    float XL,
    float YL,
    float U,
    float V,
    float UL,
    float VL,
    EBlendMode BlendMode
)

Draw arbitrary aligned rectangle.

Public function Const

void

 

GetCenter

(
    float& outX,
    float& outY
)

Return X,Y for center of the draw region.

Public function Const

float

 

GetDPIScale()

Public function

TWeakObjectP...

 

GetReporterGraph()

Creates if necessary and returns ReporterGraph instance for 2d graph canvas drawing

Public function

void

 

Init

(
    int32 InSizeX,
    int32 InSizeY,
    FSceneView* InSceneView,
    FCanvas* InCanvas
)

Initializes the canvas.

Public function

void

 

K2_Deproject

(
    FVector2D ScreenPosition,
    FVector& WorldOrigin,
    FVector& WorldDirection
)

Performs a deprojection of a screen space coordinate using the projection matrix set up for the Canvas.

Public function

void

 

K2_DrawBorder

(
    UTexture* BorderTexture,
    UTexture* BackgroundTexture,
    UTexture* LeftBorderTexture,
    UTexture* RightBorderTexture,
    UTexture* TopBorderTexture,
    UTexture* BottomBorderTexture,
    FVector2D ScreenPosition,
    FVector2D ScreenSize,
    FVector2D CoordinatePosition,
    FVector2D CoordinateSize,
    FLinearColor RenderColor,
    FVector2D BorderScale,
    FVector2D BackgroundScale,
    float Rotation,
    FVector2D PivotPoint,
    FVector2D CornerSize
)

Draws a 3x3 grid border with tiled frame and tiled interior on the Canvas.

Public function

void

 

K2_DrawBox

(
    FVector2D ScreenPosition,
    FVector2D ScreenSize,
    float Thickness,
    FLinearColor RenderColor
)

Draws an unfilled box on the Canvas.

Public function

void

 

K2_DrawLine

(
    FVector2D ScreenPositionA,
    FVector2D ScreenPositionB,
    float Thickness,
    FLinearColor RenderColor
)

Draws a line on the Canvas.

Public function

void

 

K2_DrawMaterial

(
    UMaterialInterface* RenderMate...,
    FVector2D ScreenPosition,
    FVector2D ScreenSize,
    FVector2D CoordinatePosition,
    FVector2D CoordinateSize,
    float Rotation,
    FVector2D PivotPoint
)

Draws a material on the Canvas.

Public function

void

 

K2_DrawMaterialTriangle

(
    UMaterialInterface* RenderMate...,
    TArray< FCanvasUVTri > Triangles
)

Draws a set of triangles on the Canvas.

Public function

void

 

K2_DrawPolygon

(
    UTexture* RenderTexture,
    FVector2D ScreenPosition,
    FVector2D Radius,
    int32 NumberOfSides,
    FLinearColor RenderColor
)

Draws a polygon on the Canvas.

Public function

void

 

K2_DrawText

(
    UFont* RenderFont,
    const FString& RenderText,
    FVector2D ScreenPosition,
    FVector2D Scale,
    FLinearColor RenderColor,
    float Kerning,
    FLinearColor ShadowColor,
    FVector2D ShadowOffset,
    bool bCentreX,
    bool bCentreY,
    bool bOutlined,
    FLinearColor OutlineColor
)

Draws text on the Canvas.

Public function

void

 

K2_DrawTexture

(
    UTexture* RenderTexture,
    FVector2D ScreenPosition,
    FVector2D ScreenSize,
    FVector2D CoordinatePosition,
    FVector2D CoordinateSize,
    FLinearColor RenderColor,
    EBlendMode BlendMode,
    float Rotation,
    FVector2D PivotPoint
)

Draws a texture on the Canvas.

Public function

void

 

K2_DrawTriangle

(
    UTexture* RenderTexture,
    TArray< FCanvasUVTri > Triangles
)

Draws a set of triangles on the Canvas.

Public function

FVector

 

K2_Project

(
    FVector WorldLocation
)

Performs a projection of a world space coordinates using the projection matrix set up for the Canvas.

Public function

FVector2D

 

K2_StrLen

(
    UFont* RenderFont,
    const FString& RenderText
)

Returns the wrapped text size in screen space coordinates.

Public function

FVector2D

 

K2_TextSize

(
    UFont* RenderFont,
    const FString& RenderText,
    FVector2D Scale
)

Returns the clipped text size in screen space coordinates.

Public function Static

FCanvasIcon

 

MakeIcon

(
    UTexture* Texture,
    float U,
    float V,
    float UL,
    float VL
)

Fake CanvasIcon constructor.

Public function Static

void

 

MeasureStringInternal

(
    FTextSizingParameters& Parameters,
    const TCHAR*const pText,
    const int32 TextLength,
    const int32 StopAfterHorizontalOffs...,
    const ELastCharacterIndexFormat Cha...,
    int32& OutLastCharacterIndex
)

Measures a string, optionally stopped after the specified horizontal offset in pixels is reached.

Public function

void

 

PopSafeZoneTransform()

Public function Const

FVector

 

Project

(
    FVector Location
)

Transforms a 3D world-space vector into 2D screen coordinates.

Public function Virtual

void

 

Reset

(
    bool bKeepOrigin
)

Reset canvas parameters, optionally do not change the origin

Public function

void

 

SetClip

(
    float X,
    float Y
)

Sets the position of the lower-left corner of the clipping region of the Canvas

Public function

void

 

SetDrawColor

(
    uint8 R,
    uint8 G,
    uint8 B,
    uint8 A
)

Set draw color. (R,G,B,A)

Public function

void

 

SetDrawColor

(
    FColor const& C
)

Set draw color. (FColor)

Public function

void

 

SetLinearDrawColor

(
    FLinearColor InColor,
    float OpacityOverride
)

Set DrawColor with a FLinearColor and optional opacity override

Public function

void

 

SetView

(
    FSceneView* InView
)

Changes the view for the canvas.

Public function

void

 

StrLen

(
    const UFont* InFont,
    const FString& InText,
    float& XL,
    float& YL,
    bool bDPIAware
)

Calculate the length of a string, taking text wrapping into account.

Public function

void

 

TextSize

(
    const UFont* InFont,
    const FString& InText,
    float& XL,
    float& YL,
    float ScaleX,
    float ScaleY
)

Calculates the horizontal and vertical size of a given string.

Public function

void

 

Update()

Updates the canvas.

Public function Static

void

 

UpdateAllCanvasSafeZoneData()

Function to go through all constructed canvas items and update their safe zone data.

Public function

void

 

UpdateSafeZoneData()

Updates cached SafeZone data from the device. Call when main device is resized.

Public function

int32

 

WrappedPrint

(
    bool Draw,
    float X,
    float Y,
    int32& out_XL,
    int32& out_YL,
    const UFont* Font,
    float ScaleX,
    float ScaleY,
    bool bCenterTextX,
    bool bCenterTextY,
    const TCHAR* Text,
    const FFontRenderInfo& RenderInfo
)

Compute size and optionally print text with word wrap.

Public function

void

 

WrappedStrLenf

(
    const UFont* Font,
    float ScaleX,
    float ScaleY,
    int32& XL,
    int32& YL,
    const TCHAR* Fmt,
    ...
)

Calculate the size of a string built from a font, word wrapped to a specified region.

Public function

void

 

WrapString

(
    FTextSizingParameters& Parameters,
    const float InCurX,
    const TCHAR*const pText,
    TArray< FWrappedStringElement >& o...,
    FCanvasWordWrapper::FWrappedLineDat...
)

Public function Static

void

 

WrapString

(
    FCanvasWordWrapper& Wrapper,
    FTextSizingParameters& Parameters,
    const float InCurX,
    const TCHAR*const pText,
    TArray< FWrappedStringElement >& o...,
    FCanvasWordWrapper::FWrappedLineDat...
)

Parses a single string into an array of strings that will fit inside the specified bounding region.

Overridden from UObject

Name Description

Public function Virtual

void

 

BeginDestroy()

Called before destroying the object.

Enums

Name

Description

Public enum

ELastCharacterIndexFormat

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss