CanvasItem
Abstract base class for everything in 2D space.
Abstract base class for everything in 2D space.
Abstract base class for everything in 2D space. Canvas items are laid out in a tree; children inherit and extend their parent's transform. CanvasItem is extended by Control for GUI-related nodes, and by Entity2D for 2D game objects.
Any CanvasItem can draw. For this, CanvasItem.QueueRedraw is called by the engine, then CanvasItem.NotificationDraw will be received on idle time to request a redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw_* functions). However, they can only be used inside CanvasItem.Draw, its corresponding ReckfellObject.Notification or methods connected to the CanvasItem.Draw signal.
Canvas items are drawn in tree order on their canvas layer. By default, children are on top of their parents, so a root CanvasItem will be drawn behind everything. This behavior can be changed on a per-item basis.
A CanvasItem can be hidden, which will also hide its children. By adjusting various other properties of a CanvasItem, you can also modulate its color (via CanvasItem.Modulate or CanvasItem.SelfModulate), change its Z-index, blend mode, and more.
Note that properties like transform, modulation, and visibility are only propagated to direct CanvasItem child nodes. If there is a non-CanvasItem node in between, like Entity or AnimationPlayer, the CanvasItem nodes below will have an independent position and CanvasItem.Modulate chain. See also CanvasItem.TopLevel.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties16
ClipChildrenProperty
public CanvasItem.ClipChildrenMode ClipChildren { get; set; }The mode in which this node clips its children, acting as a mask.
Note: Clipping nodes cannot be nested or placed within a CanvasGroup. If an ancestor of this node clips its children or is a CanvasGroup, then this node's clip mode should be set to CanvasItem.ClipChildrenMode.Disabled to avoid unexpected behavior.
LightMaskProperty
public int LightMask { get; set; }The rendering layers in which this CanvasItem responds to Light2D nodes.
MaterialProperty
public Material Material { get; set; }The 2D item’s own material: CanvasItemMaterial or a ShaderMaterial with a canvas_item program. UseParentMaterial=true selects the parent material instead. Items sharing one ShaderMaterial share its regular uniforms.
ModulateProperty
public Color Modulate { get; set; }Color multiplier for the item and inheriting CanvasItem descendants. Account for modulation in a custom shader: the example passes vertex-stage COLOR through a varying and multiplies the separately sampled texture by it. Otherwise assigning fragment-stage COLOR can discard the intended multiplication.
OversamplingWithScaleProperty
public CanvasItem.OversamplingWithScaleEnum OversamplingWithScale { get; set; }If enabled, oversampling for this CanvasItem is automatically adjusted with scale. This makes fonts and DpiTexture images automatically re-render to match the actual scale they are drawn at, for crisper visuals. This has a performance impact on the CPU every time the node's scale changes, so it is disabled by default.
Note: For Control nodes with Control.OffsetTransformEnabled set to true, scale-based oversampling is only effective if Control.OffsetTransformVisualOnly is false. This ensures there is no performance overhead when using visual-only offset transforms (as often used in animations).
SelfModulateProperty
public Color SelfModulate { get; set; }The color applied to this CanvasItem. This property does not affect child CanvasItems, unlike CanvasItem.Modulate which affects both the node itself and its children.
Note: Internal children are also not affected by this property (see the include_internal parameter in Entity.AddChild). For built-in nodes this includes sliders in ColorPicker, and the tab bar in TabContainer.
ShowBehindParentProperty
public bool ShowBehindParent { get; set; }If true, this node draws behind its parent.
TextureFilterProperty
public CanvasItem.TextureFilterEnum TextureFilter { get; set; }Texture-filter policy for this item. ParentNode inherits the setting; LinearWithMipmaps uses mipmaps when available. The example prepares an ImageTexture with mipmaps for downscaled images. This property neither enables MSAA nor generates mipmaps.
TextureRepeatProperty
public CanvasItem.TextureRepeatEnum TextureRepeat { get; set; }The repeating mode used to render this CanvasItem's texture(s). It affects what happens when the texture is sampled outside its extents, for example by setting a Sprite2D.RegionRect that is larger than the texture or assigning Polygon2D UV points outside the texture.
Note: TextureRect is not affected by CanvasItem.TextureRepeat, as it uses its own texture repeating implementation.
TopLevelProperty
public bool TopLevel { get; set; }Stops inheriting the parent CanvasItem transform. Does not remove the item from the tree, move it to another viewport or disable its canvas transform from a camera or CanvasLayer.
UseParentMaterialProperty
public bool UseParentMaterial { get; set; }If true, drawing uses the parent material instead of the item’s own Material. The assigned own resource remains accessible through its getter. Verification shows parent tint overriding child grayscale and false restoring the child shader.
VisibilityLayerProperty
public uint VisibilityLayer { get; set; }The rendering layer in which this CanvasItem is rendered by Viewport nodes. A Viewport will render a CanvasItem if it and all its parents share a layer with the Viewport's canvas cull mask. For an easier way to change this value from a script, see CanvasItem.SetVisibilityLayerBit.
Note: A CanvasItem does not inherit its parents' visibility layers. This means that if a parent CanvasItem does not have all the same layers as its child, the child may not be visible even if both the parent and child have CanvasItem.Visible set to true. For example, if a parent has layer 1 and a child has layer 2, the child will not be visible in a Viewport with the canvas cull mask set to layer 1 or 2 (see Viewport.CanvasCullMask). To ensure that both the parent and child are visible, the parent must have both layers 1 and 2, or the child must have CanvasItem.TopLevel set to true.
VisibleProperty
public bool Visible { get; set; }If true, this CanvasItem may be drawn. Whether this CanvasItem is actually drawn depends on the visibility of all of its CanvasItem ancestors. In other words: this CanvasItem will be drawn when CanvasItem.IsVisibleInTree returns true and all CanvasItem ancestors share at least one CanvasItem.VisibilityLayer with this CanvasItem.
Note: For controls that inherit Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.
YSortEnabledProperty
public bool YSortEnabled { get; set; }If true, this and child CanvasItem nodes with a higher Y position are rendered in front of nodes with a lower Y position. If false, this and child CanvasItem nodes are rendered normally in scene tree order.
With Y-sorting enabled on a parent node ('A') but disabled on a child node ('B'), the child node ('B') is sorted but its children ('C1', 'C2', etc.) render together on the same Y position as the child node ('B'). This allows you to organize the render order of a scene without changing the scene tree.
Nodes sort relative to each other only if they are on the same CanvasItem.ZIndex.
Note: Y-sorting does not affect the order in which CanvasItem nodes are processed, or the way input events are handled. This is especially important to keep in mind for Control nodes.
ZAsRelativeProperty
public bool ZAsRelative { get; set; }If true, this node's final Z index is relative to its parent's Z index.
For example, if CanvasItem.ZIndex is 2 and its parent's final Z index is 3, then this node's final Z index will be 5 (2 + 3).
ZIndexProperty
public int ZIndex { get; set; }The order in which this node is drawn. A node with a higher Z index will display in front of others. Must be between RenderingServer.CanvasItemZMin and RenderingServer.CanvasItemZMax (inclusive).
Note: The Z index does not affect the order in which CanvasItem nodes are processed, or the way input events are handled. This is especially important to keep in mind for Control nodes.
Methods114
DrawAnimationSlicevoid
public void DrawAnimationSlice(double animationLength, double sliceBegin, double sliceEnd, double offset = 0d);Subsequent drawing commands will be ignored unless they fall within the specified animation slice. This is a faster way to implement animations that loop on background rather than redrawing constantly.
| Name | Type | Default |
|---|---|---|
animationLength | double | — |
sliceBegin | double | — |
sliceEnd | double | — |
offset | double | 0d |
DrawArcvoid
public void DrawArc(Vector2 center, float radius, float startAngle, float endAngle, int pointCount, Color color, float width = -1f, bool antialiased = false);Draws an unfilled arc between the given angles with a uniform color and width and optional antialiasing (supported only for positive width). The larger the value of point_count, the smoother the curve. center is defined in local space. For elliptical arcs, see CanvasItem.DrawEllipseArc. See also CanvasItem.DrawCircle.
If width is negative, it will be ignored and the arc will be drawn using RenderingServer.PrimitiveType.LineStrip. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
The arc is drawn from start_angle towards the value of end_angle so in clockwise direction if start_angle < end_angle and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of start_angle and end_angle is greater than @C#.TAU radians, then a full circle arc is drawn (i.e. arc will not overlap itself).
| Name | Type | Default |
|---|---|---|
center | Vector2 | — |
radius | float | — |
startAngle | float | — |
endAngle | float | — |
pointCount | int | — |
color | Color | — |
width | float | -1f |
antialiased | bool | false |
DrawChar2 overloads
public void DrawChar(Font font, Vector2 pos, string @char, int fontSize, Color? modulate);Draws a string first character using a custom font. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. pos is defined in local space.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
char | string | — |
fontSize | int | — |
modulate | Color? | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawChar(Font font, Vector2 pos, string @char, int fontSize = 16, Color? modulate = default, float oversampling = 0f);Draws a string first character using a custom font. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. pos is defined in local space.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
char | string | — |
fontSize | int | 16 |
modulate | Color? | default |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawCharOutline2 overloads
public void DrawCharOutline(Font font, Vector2 pos, string @char, int fontSize, int size, Color? modulate);Draws a string first character outline using a custom font. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. pos is defined in local space.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
char | string | — |
fontSize | int | — |
size | int | — |
modulate | Color? | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawCharOutline(Font font, Vector2 pos, string @char, int fontSize = 16, int size = -1, Color? modulate = default, float oversampling = 0f);Draws a string first character outline using a custom font. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. pos is defined in local space.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
char | string | — |
fontSize | int | 16 |
size | int | -1 |
modulate | Color? | default |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawCircle2 overloads
public void DrawCircle(Vector2 position, float radius, Color color);Draws a circle, with position defined in local space. See also CanvasItem.DrawEllipse, CanvasItem.DrawArc, CanvasItem.DrawPolyline, and CanvasItem.DrawPolygon.
If filled is true, the circle will be filled with the color specified. If filled is false, the circle will be drawn as a stroke with the color and width specified.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: width is only effective if filled is false.
| Name | Type | Default |
|---|---|---|
position | Vector2 | — |
radius | float | — |
color | Color | — |
public void DrawCircle(Vector2 position, float radius, Color color, bool filled = true, float width = -1f, bool antialiased = false);Draws a circle, with position defined in local space. See also CanvasItem.DrawEllipse, CanvasItem.DrawArc, CanvasItem.DrawPolyline, and CanvasItem.DrawPolygon.
If filled is true, the circle will be filled with the color specified. If filled is false, the circle will be drawn as a stroke with the color and width specified.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: width is only effective if filled is false.
| Name | Type | Default |
|---|---|---|
position | Vector2 | — |
radius | float | — |
color | Color | — |
filled | bool | true |
width | float | -1f |
antialiased | bool | false |
DrawColoredPolygon2 overloads
public void DrawColoredPolygon(Vector2[] points, Color color, Vector2[] uvs = null, Texture2D texture = null);Draws a colored polygon of any number of points, convex or concave. The points in the points array are defined in local space. Unlike CanvasItem.DrawPolygon, a single color must be specified for the whole polygon.
Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
color | Color | — |
uvs | Vector2[] | null |
texture | Texture2D | null |
uvsIf the parameter is null, then the default value is Array.Empty<Vector2>().
public void DrawColoredPolygon(ReadOnlySpan<Vector2> points, Color color, ReadOnlySpan<Vector2> uvs, Texture2D texture);Draws a colored polygon of any number of points, convex or concave. The points in the points array are defined in local space. Unlike CanvasItem.DrawPolygon, a single color must be specified for the whole polygon.
Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
color | Color | — |
uvs | ReadOnlySpan<Vector2> | — |
texture | Texture2D | — |
DrawDashedLine2 overloads
public void DrawDashedLine(Vector2 from, Vector2 to, Color color, float width, float dash, bool aligned);Draws a dashed line from a 2D point to another, with a given color and width. The from and to positions are defined in local space. See also CanvasItem.DrawLine, CanvasItem.DrawMultiline, and CanvasItem.DrawPolyline.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the line parts will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
dash is the length of each dash in pixels, with the gap between each dash being the same length. If aligned is true, the length of the first and last dashes may be shortened or lengthened to allow the line to begin and end at the precise points defined by from and to. Both ends are always symmetrical when aligned is true. If aligned is false, all dashes will have the same length, but the line may appear incomplete at the end due to the dash length not dividing evenly into the line length. Only full dashes are drawn when aligned is false.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: antialiased is only effective if width is greater than 0.0.
| Name | Type | Default |
|---|---|---|
from | Vector2 | — |
to | Vector2 | — |
color | Color | — |
width | float | — |
dash | float | — |
aligned | bool | — |
public void DrawDashedLine(Vector2 from, Vector2 to, Color color, float width = -1f, float dash = 2f, bool aligned = true, bool antialiased = false);Draws a dashed line from a 2D point to another, with a given color and width. The from and to positions are defined in local space. See also CanvasItem.DrawLine, CanvasItem.DrawMultiline, and CanvasItem.DrawPolyline.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the line parts will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
dash is the length of each dash in pixels, with the gap between each dash being the same length. If aligned is true, the length of the first and last dashes may be shortened or lengthened to allow the line to begin and end at the precise points defined by from and to. Both ends are always symmetrical when aligned is true. If aligned is false, all dashes will have the same length, but the line may appear incomplete at the end due to the dash length not dividing evenly into the line length. Only full dashes are drawn when aligned is false.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: antialiased is only effective if width is greater than 0.0.
| Name | Type | Default |
|---|---|---|
from | Vector2 | — |
to | Vector2 | — |
color | Color | — |
width | float | -1f |
dash | float | 2f |
aligned | bool | true |
antialiased | bool | false |
DrawEllipsevoid
public void DrawEllipse(Vector2 position, float major, float minor, Color color, bool filled = true, float width = -1f, bool antialiased = false);Draws an ellipse with semi-major axis major and semi-minor axis minor. See also CanvasItem.DrawCircle, CanvasItem.DrawEllipseArc, CanvasItem.DrawPolyline, and CanvasItem.DrawPolygon.
If filled is true, the ellipse will be filled with the color specified. If filled is false, the ellipse will be drawn as a stroke with the color and width specified.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: width is only effective if filled is false.
| Name | Type | Default |
|---|---|---|
position | Vector2 | — |
major | float | — |
minor | float | — |
color | Color | — |
filled | bool | true |
width | float | -1f |
antialiased | bool | false |
DrawEllipseArcvoid
public void DrawEllipseArc(Vector2 center, float major, float minor, float startAngle, float endAngle, int pointCount, Color color, float width = -1f, bool antialiased = false);Draws an unfilled elliptical arc between the given angles with a uniform color and width and optional antialiasing (supported only for positive width). The larger the value of point_count, the smoother the curve. For circular arcs, see CanvasItem.DrawArc. See also CanvasItem.DrawEllipse.
If width is negative, it will be ignored and the arc will be drawn using RenderingServer.PrimitiveType.LineStrip. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
The arc is drawn from start_angle towards the value of end_angle so in clockwise direction if start_angle < end_angle and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of start_angle and end_angle is greater than @C#.TAU radians, then a full ellipse is drawn (i.e. arc will not overlap itself).
| Name | Type | Default |
|---|---|---|
center | Vector2 | — |
major | float | — |
minor | float | — |
startAngle | float | — |
endAngle | float | — |
pointCount | int | — |
color | Color | — |
width | float | -1f |
antialiased | bool | false |
DrawEndAnimationvoid
public void DrawEndAnimation();After submitting all animations slices via CanvasItem.DrawAnimationSlice, this function can be used to revert drawing to its default state (all subsequent drawing commands will be visible). If you don't care about this particular use case, usage of this function after submitting the slices is not required.
DrawLcdTextureRectRegionvoid
public void DrawLcdTextureRectRegion(Texture2D texture, Rect2 rect, Rect2 srcRect, Color? modulate = default);Draws a textured rectangle region of the font texture with LCD subpixel anti-aliasing at a given position, optionally modulated by a color. The rect is defined in local space.
Texture is drawn using the following blend operation, blend mode of the CanvasItemMaterial is ignored:
dst.r = texture.r * modulate.r * modulate.a + dst.r * (1.0 - texture.r * modulate.a);
dst.g = texture.g * modulate.g * modulate.a + dst.g * (1.0 - texture.g * modulate.a);
dst.b = texture.b * modulate.b * modulate.a + dst.b * (1.0 - texture.b * modulate.a);
dst.a = modulate.a + dst.a * (1.0 - modulate.a);Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
rect | Rect2 | — |
srcRect | Rect2 | — |
modulate | Color? | default |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawLinevoid
public void DrawLine(Vector2 from, Vector2 to, Color color, float width = -1f, bool antialiased = false);Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. The from and to positions are defined in local space. See also CanvasItem.DrawDashedLine, CanvasItem.DrawMultiline, and CanvasItem.DrawPolyline.
If width is negative, then a two-point primitive will be drawn instead of a four-point one. This means that when the CanvasItem is scaled, the line will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
| Name | Type | Default |
|---|---|---|
from | Vector2 | — |
to | Vector2 | — |
color | Color | — |
width | float | -1f |
antialiased | bool | false |
DrawMeshvoid
public void DrawMesh(Mesh mesh, Texture2D texture, Transform2D? transform = default, Color? modulate = default);Draws a Mesh in 2D, using the provided texture. See MeshInstance2D for related documentation. The transform is defined in local space.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
mesh | Mesh | — |
texture | Texture2D | — |
transform | Transform2D? | default |
modulate | Color? | default |
transformIf the parameter is null, then the default value is Transform2D.Identity.
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawMsdfTextureRectRegionvoid
public void DrawMsdfTextureRectRegion(Texture2D texture, Rect2 rect, Rect2 srcRect, Color? modulate = default, double outline = 0d, double pixelRange = 4d, double scale = 1d);Draws a textured rectangle region of the multichannel signed distance field texture at a given position, optionally modulated by a color. The rect is defined in local space. See FontFile.MultichannelSignedDistanceField for more information and caveats about MSDF font rendering.
If outline is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the outline radius.
Value of the pixel_range should the same that was used during distance field texture generation.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
rect | Rect2 | — |
srcRect | Rect2 | — |
modulate | Color? | default |
outline | double | 0d |
pixelRange | double | 4d |
scale | double | 1d |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawMultiline4 overloads
public void DrawMultiline(Vector2[] points, Color color, float width);Draws multiple disconnected lines with a uniform width and color. Each line is defined by two consecutive points from points array in local space, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
color | Color | — |
width | float | — |
public void DrawMultiline(Vector2[] points, Color color, float width = -1f, bool antialiased = false);Draws multiple disconnected lines with a uniform width and color. Each line is defined by two consecutive points from points array in local space, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
color | Color | — |
width | float | -1f |
antialiased | bool | false |
public void DrawMultiline(ReadOnlySpan<Vector2> points, Color color, float width);Draws multiple disconnected lines with a uniform width and color. Each line is defined by two consecutive points from points array in local space, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
color | Color | — |
width | float | — |
public void DrawMultiline(ReadOnlySpan<Vector2> points, Color color, float width, bool antialiased);Draws multiple disconnected lines with a uniform width and color. Each line is defined by two consecutive points from points array in local space, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
color | Color | — |
width | float | — |
antialiased | bool | — |
DrawMultilineColors4 overloads
public void DrawMultilineColors(Vector2[] points, Color[] colors, float width);Draws multiple disconnected lines with a uniform width and segment-by-segment coloring. Each segment is defined by two consecutive points from points array in local space and a corresponding color from colors array, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
colors | Color[] | — |
width | float | — |
public void DrawMultilineColors(Vector2[] points, Color[] colors, float width = -1f, bool antialiased = false);Draws multiple disconnected lines with a uniform width and segment-by-segment coloring. Each segment is defined by two consecutive points from points array in local space and a corresponding color from colors array, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
colors | Color[] | — |
width | float | -1f |
antialiased | bool | false |
public void DrawMultilineColors(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, float width);Draws multiple disconnected lines with a uniform width and segment-by-segment coloring. Each segment is defined by two consecutive points from points array in local space and a corresponding color from colors array, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
colors | ReadOnlySpan<Color> | — |
width | float | — |
public void DrawMultilineColors(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, float width, bool antialiased);Draws multiple disconnected lines with a uniform width and segment-by-segment coloring. Each segment is defined by two consecutive points from points array in local space and a corresponding color from colors array, i.e. i-th segment consists of points[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
colors | ReadOnlySpan<Color> | — |
width | float | — |
antialiased | bool | — |
DrawMultilineString2 overloads
public void DrawMultilineString(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int maxLines, Color? modulate, TextServer.LineBreakFlag brkFlags, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);Breaks text into lines and draws it using the specified font at the pos in local space (top-left corner). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
maxLines | int | — |
modulate | Color? | — |
brkFlags | TextServer.LineBreakFlag | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawMultilineString(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, Color? modulate = default, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);Breaks text into lines and draws it using the specified font at the pos in local space (top-left corner). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
maxLines | int | -1 |
modulate | Color? | default |
brkFlags | TextServer.LineBreakFlag | TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawMultilineStringOutline2 overloads
public void DrawMultilineStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int maxLines, int size, Color? modulate, TextServer.LineBreakFlag brkFlags, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);Breaks text to the lines and draws text outline using the specified font at the pos in local space (top-left corner). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
maxLines | int | — |
size | int | — |
modulate | Color? | — |
brkFlags | TextServer.LineBreakFlag | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawMultilineStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, int size = 1, Color? modulate = default, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);Breaks text to the lines and draws text outline using the specified font at the pos in local space (top-left corner). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
maxLines | int | -1 |
size | int | 1 |
modulate | Color? | default |
brkFlags | TextServer.LineBreakFlag | TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawMultimeshvoid
public void DrawMultimesh(MultiMesh multimesh, Texture2D texture);Draws a MultiMesh in 2D with the provided texture. See MultiMeshInstance2D for related documentation.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
multimesh | MultiMesh | — |
texture | Texture2D | — |
DrawPolygon2 overloads
public void DrawPolygon(Vector2[] points, Color[] colors, Vector2[] uvs = null, Texture2D texture = null);Draws a solid polygon of any number of points, convex or concave. Unlike CanvasItem.DrawColoredPolygon, each point's color can be changed individually. The points array is defined in local space. See also CanvasItem.DrawPolyline and CanvasItem.DrawPolylineColors. If you need more flexibility (such as being able to use bones), use RenderingServer.CanvasItemAddTriangleArray instead.
Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
colors | Color[] | — |
uvs | Vector2[] | null |
texture | Texture2D | null |
uvsIf the parameter is null, then the default value is Array.Empty<Vector2>().
public void DrawPolygon(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, ReadOnlySpan<Vector2> uvs, Texture2D texture);Draws a solid polygon of any number of points, convex or concave. Unlike CanvasItem.DrawColoredPolygon, each point's color can be changed individually. The points array is defined in local space. See also CanvasItem.DrawPolyline and CanvasItem.DrawPolylineColors. If you need more flexibility (such as being able to use bones), use RenderingServer.CanvasItemAddTriangleArray instead.
Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
colors | ReadOnlySpan<Color> | — |
uvs | ReadOnlySpan<Vector2> | — |
texture | Texture2D | — |
DrawPolyline2 overloads
public void DrawPolyline(Vector2[] points, Color color, float width = -1f, bool antialiased = false);Draws interconnected line segments with a uniform color and width and optional antialiasing (supported only for positive width). The points array is defined in local space. When drawing large amounts of lines, this is faster than using individual CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultiline instead. See also CanvasItem.DrawPolygon.
If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
color | Color | — |
width | float | -1f |
antialiased | bool | false |
public void DrawPolyline(ReadOnlySpan<Vector2> points, Color color, float width, bool antialiased);Draws interconnected line segments with a uniform color and width and optional antialiasing (supported only for positive width). The points array is defined in local space. When drawing large amounts of lines, this is faster than using individual CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultiline instead. See also CanvasItem.DrawPolygon.
If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
color | Color | — |
width | float | — |
antialiased | bool | — |
DrawPolylineColors2 overloads
public void DrawPolylineColors(Vector2[] points, Color[] colors, float width = -1f, bool antialiased = false);Draws interconnected line segments with a uniform width, point-by-point coloring, and optional antialiasing (supported only for positive width). Colors assigned to line points match by index between points and colors, i.e. each line segment is filled with a gradient between the colors of the endpoints. The points array is defined in local space. When drawing large amounts of lines, this is faster than using individual CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultilineColors instead. See also CanvasItem.DrawPolygon.
If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
colors | Color[] | — |
width | float | -1f |
antialiased | bool | false |
public void DrawPolylineColors(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, float width, bool antialiased);Draws interconnected line segments with a uniform width, point-by-point coloring, and optional antialiasing (supported only for positive width). Colors assigned to line points match by index between points and colors, i.e. each line segment is filled with a gradient between the colors of the endpoints. The points array is defined in local space. When drawing large amounts of lines, this is faster than using individual CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultilineColors instead. See also CanvasItem.DrawPolygon.
If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
colors | ReadOnlySpan<Color> | — |
width | float | — |
antialiased | bool | — |
DrawPrimitive2 overloads
public void DrawPrimitive(Vector2[] points, Color[] colors, Vector2[] uvs, Texture2D texture = null);Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. The points array is defined in local space. See also CanvasItem.DrawLine, CanvasItem.DrawPolyline, CanvasItem.DrawPolygon, and CanvasItem.DrawRect.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
points | Vector2[] | — |
colors | Color[] | — |
uvs | Vector2[] | — |
texture | Texture2D | null |
public void DrawPrimitive(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, ReadOnlySpan<Vector2> uvs, Texture2D texture);Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. The points array is defined in local space. See also CanvasItem.DrawLine, CanvasItem.DrawPolyline, CanvasItem.DrawPolygon, and CanvasItem.DrawRect.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
points | ReadOnlySpan<Vector2> | — |
colors | ReadOnlySpan<Color> | — |
uvs | ReadOnlySpan<Vector2> | — |
texture | Texture2D | — |
DrawRect2 overloads
public void DrawRect(Rect2 rect, Color color, bool filled, float width);Draws a rectangle. If filled is true, the rectangle will be filled with the color specified. If filled is false, the rectangle will be drawn as a stroke with the color and width specified. The rect is specified in local space. See also CanvasItem.DrawTextureRect.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: width is only effective if filled is false.
Note: Unfilled rectangles drawn with a negative width may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent color).
| Name | Type | Default |
|---|---|---|
rect | Rect2 | — |
color | Color | — |
filled | bool | — |
width | float | — |
public void DrawRect(Rect2 rect, Color color, bool filled = true, float width = -1f, bool antialiased = false);Draws a rectangle. If filled is true, the rectangle will be filled with the color specified. If filled is false, the rectangle will be drawn as a stroke with the color and width specified. The rect is specified in local space. See also CanvasItem.DrawTextureRect.
If width is negative, then two-point primitives will be drawn instead of four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive width like 1.0.
If antialiased is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.
Note: width is only effective if filled is false.
Note: Unfilled rectangles drawn with a negative width may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent color).
| Name | Type | Default |
|---|---|---|
rect | Rect2 | — |
color | Color | — |
filled | bool | true |
width | float | -1f |
antialiased | bool | false |
DrawSetTransformvoid
public void DrawSetTransform(Vector2 position, float rotation = 0f, Vector2? scale = default);Sets a custom local transform for drawing via components. Anything drawn afterwards will be transformed by this.
Note: FontFile.Oversampling does not take scale into account. This means that scaling up/down will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated. To ensure text remains crisp regardless of scale, you can enable MSDF font rendering by enabling ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field (applies to the default project font only), or enabling Multichannel Signed Distance Field in the import options of a DynamicFont for custom fonts. On system fonts, SystemFont.MultichannelSignedDistanceField can be enabled in the inspector.
| Name | Type | Default |
|---|---|---|
position | Vector2 | — |
rotation | float | 0f |
scale | Vector2? | default |
scaleIf the parameter is null, then the default value is new Vector2(1.0f, 1.0f).
DrawSetTransformMatrixvoid
public void DrawSetTransformMatrix(Transform2D xform);Sets a custom local transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
| Name | Type | Default |
|---|---|---|
xform | Transform2D | — |
DrawString2 overloads
public void DrawString(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, Color? modulate, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);Draws text using the specified font at the pos in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Example: Draw "Hello world", using the project's default font:
DrawString(ThemeDB.FallbackFont, new Vector2(64, 64), "Hello world", HorizontalAlignment.Left, -1, ThemeDB.FallbackFontSize);See also Font.DrawString.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
modulate | Color? | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawString(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, Color? modulate = default, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);Draws text using the specified font at the pos in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Example: Draw "Hello world", using the project's default font:
DrawString(ThemeDB.FallbackFont, new Vector2(64, 64), "Hello world", HorizontalAlignment.Left, -1, ThemeDB.FallbackFontSize);See also Font.DrawString.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
modulate | Color? | default |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawStringOutline2 overloads
public void DrawStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int size, Color? modulate, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);Draws text outline using the specified font at the pos in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | — |
width | float | — |
fontSize | int | — |
size | int | — |
modulate | Color? | — |
justificationFlags | TextServer.JustificationFlag | — |
direction | TextServer.Direction | — |
orientation | TextServer.Orientation | — |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
public void DrawStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int size = 1, Color? modulate = default, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);Draws text outline using the specified font at the pos in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by CanvasItem.Modulate. If width is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
| Name | Type | Default |
|---|---|---|
font | Font | — |
pos | Vector2 | — |
text | string | — |
alignment | HorizontalAlignment | HorizontalAlignment.Left |
width | float | -1f |
fontSize | int | 16 |
size | int | 1 |
modulate | Color? | default |
justificationFlags | TextServer.JustificationFlag | TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound |
direction | TextServer.Direction | TextServer.Direction.Auto |
orientation | TextServer.Orientation | TextServer.Orientation.Horizontal |
oversampling | float | 0f |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawStyleBoxvoid
public void DrawStyleBox(StyleBox styleBox, Rect2 rect);Draws a styled rectangle. The rect is defined in local space.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
styleBox | StyleBox | — |
rect | Rect2 | — |
DrawTexturevoid
public void DrawTexture(Texture2D texture, Vector2 position, Color? modulate = default);Draws a texture at a given position. The position is defined in local space.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
position | Vector2 | — |
modulate | Color? | default |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawTextureRectvoid
public void DrawTextureRect(Texture2D texture, Rect2 rect, bool tile, Color? modulate = default, bool transpose = false);Draws a textured rectangle at a given position, optionally modulated by a color. The rect is defined in local space. If transpose is true, the texture will have its X and Y coordinates swapped. See also CanvasItem.DrawRect and CanvasItem.DrawTextureRectRegion.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
rect | Rect2 | — |
tile | bool | — |
modulate | Color? | default |
transpose | bool | false |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
DrawTextureRectRegionvoid
public void DrawTextureRectRegion(Texture2D texture, Rect2 rect, Rect2 srcRect, Color? modulate = default, bool transpose = false, bool clipUV = true);Draws a textured rectangle from a texture's region (specified by src_rect) at a given position in local space, optionally modulated by a color. If transpose is true, the texture will have its X and Y coordinates swapped. See also CanvasItem.DrawTextureRect.
Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
rect | Rect2 | — |
srcRect | Rect2 | — |
modulate | Color? | default |
transpose | bool | false |
clipUV | bool | true |
modulateIf the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).
ForceUpdateTransformvoid
public void ForceUpdateTransform();Forces the node's transform to update. Fails if the node is not inside the tree. See also CanvasItem.GetTransform.
Note: For performance reasons, transform changes are usually accumulated and applied once at the end of the frame. The update propagates through CanvasItem children, as well. Therefore, use this method only when you need an up-to-date transform (such as during physics operations).
GetCanvasRid
public Rid GetCanvas();Returns the Rid of the World2D canvas where this node is registered to, used by the RenderingServer.
RidGetCanvasItemRid
public Rid GetCanvasItem();Returns the internal canvas item Rid used by the RenderingServer for this node.
RidGetCanvasLayerEntityCanvasLayer
public CanvasLayer GetCanvasLayerEntity();Returns the CanvasLayer that contains this node, or null if the node is not in any CanvasLayer.
CanvasLayerGetCanvasTransformTransform2D
public Transform2D GetCanvasTransform();Returns the effective canvas transform: the CanvasLayer final transform or the viewport CanvasTransform. Requires the item in the tree; excludes the item's own local transform and final window stretch.
Transform2DEffective canvas transform, excluding the item-local matrix.
GetClipChildrenModeCanvasItem.ClipChildrenMode
public CanvasItem.ClipChildrenMode GetClipChildrenMode();CanvasItem.ClipChildrenModeGetGlobalMousePositionVector2
public Vector2 GetGlobalMousePosition();Returns mouse cursor's global position relative to the CanvasLayer that contains this node.
Note: For screen-space coordinates (e.g. when using a non-embedded Popup), you can use DisplayServer.MouseGetPosition.
Vector2GetGlobalTransformTransform2D
public Transform2D GetGlobalTransform();Returns the global transform matrix of this item, i.e. the combined transform up to the topmost CanvasItem node. The topmost item is a CanvasItem that either has no parent, has non-CanvasItem parent or it has CanvasItem.TopLevel enabled.
Transform2DGetGlobalTransformWithCanvasTransform2D
public Transform2D GetGlobalTransformWithCanvas();Composes a CanvasItem-local to canvas/viewport transform using its hierarchy and CanvasLayer or viewport canvas. Its inverse converts a point from the same viewport into local coordinates when invertible.
Transform2DComposed Transform2D. An off-tree object without CanvasLayer uses only its global object transform; this is not a complete mapping to a future viewport.
GetInstanceShaderParameterVariant
public Variant GetInstanceShaderParameter(StringName name);Reads the CanvasItem instance registry current value. After material preparation and Nil reset the declared default is available; an absent entry returns Nil. This is distinct from a shared ShaderMaterial parameter.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
nameExact case-sensitive parameter name.
VariantCurrent known instance value, or Nil.
GetLightMaskint
public int GetLightMask();intGetLocalMousePositionVector2
public Vector2 GetLocalMousePosition();Returns the mouse's position in this CanvasItem using the local coordinate system of this CanvasItem.
Vector2GetMaterialMaterial
public Material GetMaterial();Returns the assigned own resource rather than resolving the effective material under UseParentMaterial.
MaterialOwn Material, or null. Check UseParentMaterial if readback is correct but rendering uses different settings.
GetModulateColor
public Color GetModulate();ColorGetOversamplingWithScaleCanvasItem.OversamplingWithScaleEnum
public CanvasItem.OversamplingWithScaleEnum GetOversamplingWithScale();CanvasItem.OversamplingWithScaleEnumGetScreenTransformTransform2D
public Transform2D GetScreenTransform();Returns the transform of this CanvasItem in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
Equivalent to CanvasItem.GetGlobalTransformWithCanvas if the window is embedded (see Viewport.GuiEmbedSubwindows).
Transform2DGetSelfModulateColor
public Color GetSelfModulate();ColorGetTextureFilterCanvasItem.TextureFilterEnum
public CanvasItem.TextureFilterEnum GetTextureFilter();Reads the item’s stored policy. It can return ParentNode rather than the resolved filter after following inheritance.
CanvasItem.TextureFilterEnumStored TextureFilterEnum. Selecting a mipmap mode does not establish that a particular texture contains mipmap data.
GetTextureRepeatCanvasItem.TextureRepeatEnum
public CanvasItem.TextureRepeatEnum GetTextureRepeat();CanvasItem.TextureRepeatEnumGetTransformTransform2D
public Transform2D GetTransform();Returns the transform matrix of this CanvasItem.
Transform2DGetUseParentMaterialbool
public bool GetUseParentMaterial();Reads the parent-material selection flag rather than the material itself.
boolCurrent UseParentMaterial value. Use GetMaterial to read the assigned own resource.
GetViewportRectRect2
public Rect2 GetViewportRect();Returns this node's viewport boundaries as a Rect2. See also Entity.GetViewport.
Rect2GetViewportTransformTransform2D
public Transform2D GetViewportTransform();Returns the transform of this node, converted from its registered canvas's coordinate system to its viewport embedder's coordinate system. See also Viewport.GetFinalTransform and Entity.GetViewport.
Transform2DGetVisibilityLayeruint
public uint GetVisibilityLayer();uintGetVisibilityLayerBitbool
public bool GetVisibilityLayerBit(uint layer);Returns true if the layer at the given index is set in CanvasItem.VisibilityLayer.
| Name | Type | Default |
|---|---|---|
layer | uint | — |
boolGetWorld2DWorld2D
public World2D GetWorld2D();Returns the World2D this node is registered to.
Usually, this is the same as this node's viewport (see Entity.GetViewport and Viewport.FindWorld2D).
World2DGetZIndexint
public int GetZIndex();intHidevoid
public void Hide();Hide the CanvasItem if it's currently visible. This is equivalent to setting CanvasItem.Visible to false.
IsDrawBehindParentEnabledbool
public bool IsDrawBehindParentEnabled();boolIsLocalTransformNotificationEnabledbool
public bool IsLocalTransformNotificationEnabled();Returns true if the node receives CanvasItem.NotificationLocalTransformChanged whenever its local transform changes. This is enabled with CanvasItem.SetNotifyLocalTransform.
boolIsSetAsTopLevelbool
public bool IsSetAsTopLevel();boolIsTransformNotificationEnabledbool
public bool IsTransformNotificationEnabled();Returns true if the node receives CanvasItem.NotificationTransformChanged whenever its global transform changes. This is enabled with CanvasItem.SetNotifyTransform.
boolIsVisiblebool
public bool IsVisible();boolIsVisibleInTreebool
public bool IsVisibleInTree();Returns true if the node is present in the EntityTree, its CanvasItem.Visible property is true and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree, and is therefore not drawn (see CanvasItem.Draw).
Visibility is checked only in parent nodes that inherit from CanvasItem, CanvasLayer, and Window. If the parent is of any other type (such as Entity, AnimationPlayer, or Entity3D), it is assumed to be visible.
Note: This method does not take CanvasItem.VisibilityLayer into account, so even if this method returns true, the node might end up not being rendered.
boolIsYSortEnabledbool
public bool IsYSortEnabled();boolIsZRelativebool
public bool IsZRelative();boolMakeCanvasPositionLocalVector2
public Vector2 MakeCanvasPositionLocal(Vector2 viewportPoint);Converts a logical viewport point to item-local coordinates by affine-inverting canvas transform times GlobalTransform. Requires the item in the tree and an invertible basis; the input must not be an OS screen position.
| Name | Type | Default |
|---|---|---|
viewportPoint | Vector2 | — |
viewportPointLogical point in the same viewport at the canvas stage.
Vector2Point in the item's local space.
MakeInputLocalInputEvent
public InputEvent MakeInputLocal(InputEvent @event);Returns an event transformed by the inverse canvas and item transform; leaves the original event unchanged. Use for input in the same viewport's logical coordinates, not already-local GUI callback coordinates. Requires the item in the tree and an invertible basis.
| Name | Type | Default |
|---|---|---|
event | InputEvent | — |
eventEvent in the same viewport's logical coordinates; the original object is preserved.
InputEventTransformed event; the original event remains unchanged.
MoveToFrontvoid
public void MoveToFront();Moves this node below its siblings, usually causing the node to draw on top of its siblings. Does nothing if this node does not have a parent. See also Entity.MoveChild.
QueueRedrawvoid
public void QueueRedraw();Queues the CanvasItem to redraw. During idle time, if CanvasItem is visible, CanvasItem.NotificationDraw is sent and CanvasItem.Draw is called. This only occurs once per frame, even if this method has been called multiple times.
SetAsTopLevelvoid
public void SetAsTopLevel(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetClipChildrenModevoid
public void SetClipChildrenMode(CanvasItem.ClipChildrenMode mode);| Name | Type | Default |
|---|---|---|
mode | CanvasItem.ClipChildrenMode | — |
SetDrawBehindParentvoid
public void SetDrawBehindParent(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetInstanceShaderParametervoid
public void SetInstanceShaderParameter(StringName name, Variant value);Sets an instance uniform for one CanvasItem without copying its shared material. Nil resolves and assigns the declared default. Name and type must match the shader instance uniform.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
value | Variant | — |
nameExact case-sensitive parameter name.
valueValue of the declared instance type; Nil restores the declared default.
SetLightMaskvoid
public void SetLightMask(int lightMask);| Name | Type | Default |
|---|---|---|
lightMask | int | — |
SetMaterialvoid
public void SetMaterial(Material material);Assigns the item’s own material. With UseParentMaterial=true it does not determine current appearance: check inheritance first. null clears the own assignment.
| Name | Type | Default |
|---|---|---|
material | Material | — |
materialSuitable 2D Material, or null. For a text shader, use ShaderMaterial with shader_type canvas_item.
SetModulatevoid
public void SetModulate(Color modulate);| Name | Type | Default |
|---|---|---|
modulate | Color | — |
SetNotifyLocalTransformvoid
public void SetNotifyLocalTransform(bool enable);If true, the node will receive CanvasItem.NotificationLocalTransformChanged whenever its local transform changes.
Note: Many canvas items such as Bone2D or CollisionShape2D automatically enable this in order to function correctly.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetNotifyTransformvoid
public void SetNotifyTransform(bool enable);If true, the node will receive CanvasItem.NotificationTransformChanged whenever its global transform changes.
Note: Many canvas items such as Camera2D or Light2D automatically enable this in order to function correctly.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetOversamplingWithScalevoid
public void SetOversamplingWithScale(CanvasItem.OversamplingWithScaleEnum enabled);| Name | Type | Default |
|---|---|---|
enabled | CanvasItem.OversamplingWithScaleEnum | — |
SetSelfModulatevoid
public void SetSelfModulate(Color selfModulate);| Name | Type | Default |
|---|---|---|
selfModulate | Color | — |
SetTextureFiltervoid
public void SetTextureFilter(CanvasItem.TextureFilterEnum mode);Sets the 2D texture-filter policy and updates inheritance. Pixel art commonly needs Nearest; downscaled photography benefits from linear filtering with prepared mipmaps. Choose for the asset rather than treating maximum filtering as universal.
| Name | Type | Default |
|---|---|---|
mode | CanvasItem.TextureFilterEnum | — |
modeA TextureFilterEnum value. ParentNode requests inheritance; Max is an enum bound, not a filtering mode.
SetTextureRepeatvoid
public void SetTextureRepeat(CanvasItem.TextureRepeatEnum mode);| Name | Type | Default |
|---|---|---|
mode | CanvasItem.TextureRepeatEnum | — |
SetUseParentMaterialvoid
public void SetUseParentMaterial(bool enable);Switches parent-material selection for drawing. Does not remove the own Material or copy uniform values between resources.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enabletrue selects the parent material; false restores use of the own assignment.
SetVisibilityLayervoid
public void SetVisibilityLayer(uint layer);| Name | Type | Default |
|---|---|---|
layer | uint | — |
SetVisibilityLayerBitvoid
public void SetVisibilityLayerBit(uint layer, bool enabled);Set/clear individual bits on the rendering visibility layer (layer is between 0 and 31). This simplifies editing this CanvasItem's visibility layer compared to assigning the CanvasItem.VisibilityLayer property directly.
| Name | Type | Default |
|---|---|---|
layer | uint | — |
enabled | bool | — |
SetVisiblevoid
public void SetVisible(bool visible);| Name | Type | Default |
|---|---|---|
visible | bool | — |
SetYSortEnabledvoid
public void SetYSortEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetZAsRelativevoid
public void SetZAsRelative(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetZIndexvoid
public void SetZIndex(int zIndex);| Name | Type | Default |
|---|---|---|
zIndex | int | — |
Showvoid
public void Show();Show the CanvasItem if it's currently hidden. This is equivalent to setting CanvasItem.Visible to true.
Note: For controls that inherit Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.
_Drawvoid
public virtual void _Draw();Called when CanvasItem has been requested to redraw (after CanvasItem.QueueRedraw is called, either manually or by the engine).
Corresponds to the CanvasItem.NotificationDraw notification in ReckfellObject.Notification.
Signals and events4
DrawEvent
public event Action Draw;Called when CanvasItem has been requested to redraw (after CanvasItem.QueueRedraw is called, either manually or by the engine).
Corresponds to the CanvasItem.NotificationDraw notification in ReckfellObject.Notification.
public event Action Hidden;Emitted when this node becomes hidden, i.e. it's no longer visible in the tree (see CanvasItem.IsVisibleInTree).
ItemRectChangedEvent
public event Action ItemRectChanged;Emitted when the CanvasItem's boundaries (position or size) change, or when an action took place that may have affected these boundaries (e.g. changing Sprite2D.Texture).
VisibilityChangedEvent
public event Action VisibilityChanged;Emitted when the CanvasItem's visibility changes, either because its own CanvasItem.Visible property changed or because its visibility in the tree changed (see CanvasItem.IsVisibleInTree).
This signal is emitted after the related CanvasItem.NotificationVisibilityChanged notification.
Fields and constants7
NotificationDrawField
public const long NotificationDraw = 30;The CanvasItem is requested to draw (see CanvasItem.Draw).
NotificationEnterCanvasField
public const long NotificationEnterCanvas = 32;The CanvasItem has entered the canvas.
NotificationExitCanvasField
public const long NotificationExitCanvas = 33;The CanvasItem has exited the canvas.
This notification is sent in reversed order.
NotificationLocalTransformChangedField
public const long NotificationLocalTransformChanged = 35;Notification received when this node's transform changes, if CanvasItem.IsLocalTransformNotificationEnabled is true. This is not received when a parent Entity2D's transform changes. See also CanvasItem.SetNotifyLocalTransform.
Note: Many canvas items such as Camera2D or CollisionShape2D automatically enable this in order to function correctly.
NotificationTransformChangedField
public const long NotificationTransformChanged = 2000;Notification received when this node's global transform changes, if CanvasItem.IsTransformNotificationEnabled is true. See also CanvasItem.SetNotifyTransform and CanvasItem.GetTransform.
Note: Many canvas items such as Camera2D or CollisionObject2D automatically enable this in order to function correctly.
NotificationVisibilityChangedField
public const long NotificationVisibilityChanged = 31;Notification received when this node's visibility changes (see CanvasItem.Visible and CanvasItem.IsVisibleInTree).
This notification is received before the related CanvasItem.VisibilityChanged signal.
NotificationWorld2DChangedField
public const long NotificationWorld2DChanged = 36;Notification received when this CanvasItem is registered to a new World2D (see CanvasItem.GetWorld2D).
CanvasItem.ClipChildrenMode
| Value | Description |
|---|---|
AndDraw = 2 | This node is used as a mask and is also drawn. The mask is based on this node's alpha channel: Opaque pixels are kept, transparent pixels are discarded, and semi-transparent pixels are blended in according to their opacity. Children are clipped to the parent's drawn area. |
Disabled = 0 | Children are drawn over this node and are not clipped. |
Max = 3 | Represents the size of the |
Only = 1 | This node is used as a mask and is not drawn. The mask is based on this node's alpha channel: Opaque pixels are kept, transparent pixels are discarded, and semi-transparent pixels are blended in according to their opacity. Children are clipped to this node's drawn area. |
CanvasItem.OversamplingWithScaleEnum
| Value | Description |
|---|---|
Disabled = 1 | The oversampling is not affected by |
Enabled = 2 | The oversampling is a product of |
Max = 3 | Represents the size of the |
ParentNode = 0 | The |
CanvasItem.TextureFilterEnum
| Value | Description |
|---|---|
Linear = 2 | The texture filter blends between the nearest 4 pixels. This makes the texture look smooth from up close, and grainy from a distance (due to mipmaps not being sampled). |
LinearWithMipmaps = 4 | The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if |
LinearWithMipmapsAnisotropic = 6 | The texture filter blends between the nearest 4 pixels and blends between 2 mipmaps (or uses the nearest mipmap if |
Max = 7 | Represents the size of the |
Nearest = 1 | The texture filter reads from the nearest pixel only. This makes the texture look pixelated from up close, and grainy from a distance (due to mipmaps not being sampled). |
NearestWithMipmaps = 3 | The texture filter reads from the nearest pixel and blends between the nearest 2 mipmaps (or uses the nearest mipmap if |
NearestWithMipmapsAnisotropic = 5 | The texture filter reads from the nearest pixel and blends between 2 mipmaps (or uses the nearest mipmap if |
ParentNode = 0 | The |
CanvasItem.TextureRepeatEnum
| Value | Description |
|---|---|
Disabled = 1 | The texture does not repeat. Sampling the texture outside its extents will result in "stretching" of the edge pixels. You can avoid this by ensuring a 1-pixel fully transparent border on each side of the texture. |
Enabled = 2 | The texture repeats when exceeding the texture's size. |
Max = 4 | Represents the size of the |
Mirror = 3 | The texture repeats when the exceeding the texture's size in a "2×2 tiled mode". Repeated textures at even positions are mirrored. |
ParentNode = 0 | The |