-
Notifications
You must be signed in to change notification settings - Fork 0
class_canvasitem
Inherits: node\ Category: Core\
Base class of anything 2D.
- void #_draw(****) virtual
- void #edit_set_state( var state )
- void #edit_get(****) const
- void #edit_set_rect( Rect2 rect )
- void #edit_rotate( real degrees )
- Rect2 #get_item_rect(****) const
- RID #get_canvas_item(****) const
- bool #is_visible(****) const
- bool #is_hidden(****) const
- void #show(****)
- void #hide(****)
- void #update(****)
- void #set_as_toplevel( bool enable )
- bool #is_set_as_toplevel(****) const
- void #set_blend_mode( int blend_mode )
- int #get_blend_mode(****) const
- void #set_opacity( real opacity )
- real #get_opacity(****) const
- void #set_self_opacity( real self_opacity )
- real #get_self_opacity(****) const
- void #set_on_top( bool on_top )
- bool #is_on_top(****) const
- void #draw_line( Vector2 from, Vector2 to, Color color, real width=1 )
- void #draw_rect( Rect2 rect, Color color )
- void #draw_circle( Vector2 pos, real radius, Color color )
- void #draw_texture( Texture texture, Vector2 pos )
- void #draw_texture_rect( Texture texture, Rect2 rect, bool tile=false, Color modulate=Color(1,1,1,1) )
- void #draw_texture_rect_region( Texture texture, Rect2 rect, Rect2 src_rect, Color modulate=Color(1,1,1,1) )
- void #draw_style_box( StyleBox style_box, Rect2 rect )
- void #draw_primitive( Vector2Array points, ColorArray colors, Vector2Array uvs=Array(), Texture texture=Object(), real width=1 )
- void #draw_polygon( Vector2Array points, ColorArray colors, Vector2Array uvs, Texture texture=Array(), real arg4=Object() )
- void #draw_colored_polygon( Vector2Array points, ColorArray color, Vector2Array uvs, Texture texture=Array(), real arg4=Object() )
- void #draw_string( Font font, Vector2 pos, String text, Color modulate=Color(1,1,1,1), int clip_w=-1 )
- real #draw_char( Font font, Vector2 pos, String char, String next, Color modulate=Color(1,1,1,1) )
- void #draw_set_transform( Vector2 pos, real rot, Vector2 scale )
- Matrix32 #get_transform(****) const
- Matrix32 #get_global_transform(****) const
- Matrix32 #get_viewport_transform(****) const
- Rect2 #get_viewport_rect(****) const
- RID #get_canvas(****) const
- Object #get_world_2d(****) const
- Object #get_viewport(****) const
- item_rect_changed**(****)**
- draw**(****)**
- visibility_changed**(****)**
- hide**(****)**
- BLEND_MODE_MIX = 0 - Mix blending mode.
- BLEND_MODE_ADD = 1 - Additive blending mode.
- BLEND_MODE_SUB = 2 - Substractive blending mode.
- BLEND_MODE_MUL = 3 - Multiplicative blending mode.
- NOTIFICATION_DRAW = 30 - CanvasItem is requested to draw.
- NOTIFICATION_VISIBILITY_CHANGED = 31 - Canvas item visibility has changed.
- NOTIFICATION_ENTER_CANVAS = 32 - Canvas item has entered the canvas.
- NOTIFICATION_EXIT_CANVAS = 33 - Canvas item has exited the canvas.
- NOTIFICATION_TRANSFORM_CHANGED = 29 - Canvas item transform has changed. Only received if requested.
Base class of anything 2D. Canvas items are laid out in a tree and children inherit and extend the transform of their parent. CanvasItem is extended by control, for anything GUI related, and by node2d for anything 2D engine related. Any CanvasItem can draw. For this, the "update" function must be called, then NOTIFICATION_DRAW will be received on idle time to request redraw. Because of this, canvas items don't need to be redraw on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw_* functions). They can only be used inside the notification, signal or _draw() overrided function, though. Canvas items are draw in tree order. By default, children are on top of their parents so a root CanvasItem will be drawn behind everything (this can be changed per item though). Canvas items can also be hidden (hiding also their subtree). They provide many means for changing standard parameters such as opacity (for it and the subtree) and self opacity, blend mode. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
== _draw ==
- void #_draw(****) virtual \ Called (if exists) to draw the canvas item. == edit_set_state ==
- void #edit_set_state( var state ) \ Used for editing, returns an opaque value represeting the transform state. == edit_rotate ==
- void #edit_rotate( real degrees ) \ Used for editing, handle rotation. == get_item_rect ==
- Rect2 #get_item_rect(****) const \ Return a rect containing the editable contents of the item. == get_canvas_item ==
- RID #get_canvas_item(****) const \ Return the canvas item RID used by visualserver for this item. == is_visible ==
- bool #is_visible(****) const \ Return true if this CanvasItem is visible. It may be invisible because itself or a parent canvas item is hidden. == is_hidden ==
- bool #is_hidden(****) const \ Return true if this CanvasItem is hidden. Note that the CanvasItem may not be visible, but as long as it's not hidden (#hide called) the function will return false. == show ==
- void #show(****) \ Show the CanvasItem currently hidden. == hide ==
- void #hide(****) \ Hide the CanvasItem currently visible. == update ==
- void #update(****) \ Queue the CanvasItem for update. NOTIFICATION_DRAW will be called on idle time to request redraw. == set_as_toplevel ==
- void #set_as_toplevel( bool enable ) \ Set as toplevel. This means that it will not inherit transform from parent canvas items. == is_set_as_toplevel ==
- bool #is_set_as_toplevel(****) const \ Return if set as toplevel. See #set_as_toplevel/ == set_blend_mode ==
- void #set_blend_mode( int blend_mode ) \ Set the blending mode from enum BLEND_MODE_*. == get_blend_mode ==
- int #get_blend_mode(****) const \ Return the current blending mode from enum BLEND_MODE_*. == set_opacity ==
- void #set_opacity( real opacity ) \ Set canvas item opacity. This will affect the canvas item and all the children. == get_opacity ==
- real #get_opacity(****) const \ Return the canvas item opacity. This affects the canvas item and all the children. == get_self_opacity ==
- real #get_self_opacity(****) const \ Set canvas item self-opacity. This does not affect the opacity of children items. == set_on_top ==
- void #set_on_top( bool on_top ) \ Set canvas item as drawing over the parent canvas item (default: true). == is_on_top ==
- bool #is_on_top(****) const \ Return if the canvas item is drawing over the parent canvas item (default: true). == draw_line ==
- void #draw_line( Vector2 from, Vector2 to, Color color, real width=1 ) \ Draw a line from a 2D point to another, with a given color and width. == draw_rect ==
- void #draw_rect( Rect2 rect, Color color ) \ Draw a colored rectangle. == draw_circle ==
- void #draw_circle( Vector2 pos, real radius, Color color ) \ Draw a colored circle. == draw_texture ==
- void #draw_texture( Texture texture, Vector2 pos ) \ Draw a texture at a given position. == draw_texture_rect ==
- void #draw_texture_rect( Texture texture, Rect2 rect, bool tile=false, Color modulate=Color(1,1,1,1) ) \ Draw a textured rectangle at a given position, optionally modulated by a color. == draw_texture_rect_region ==
- void #draw_texture_rect_region( Texture texture, Rect2 rect, Rect2 src_rect, Color modulate=Color(1,1,1,1) ) \ Draw a textured rectangle region at a given position, optionally modulated by a color. == draw_style_box ==
- void #draw_style_box( StyleBox style_box, Rect2 rect ) \ Draw a styled rectangle. == draw_primitive ==
- void #draw_primitive( Vector2Array points, ColorArray colors, Vector2Array uvs=Array(), Texture texture=Object(), real width=1 ) \ Draw a custom primitive, 1 point for a point, 2 points for a line, 3 points for a triangle and 4 points for a quad. == draw_polygon ==
- void #draw_polygon( Vector2Array points, ColorArray colors, Vector2Array uvs, Texture texture=Array(), real arg4=Object() ) \ Draw a polygon of any amount of points, convex or concave. == draw_colored_polygon ==
- void #draw_colored_polygon( Vector2Array points, ColorArray color, Vector2Array uvs, Texture texture=Array(), real arg4=Object() ) \ Draw a colored polygon of any amount of points, convex or concave. == draw_string ==
- void #draw_string( Font font, Vector2 pos, String text, Color modulate=Color(1,1,1,1), int clip_w=-1 ) \ Draw a string using a custom font. == draw_char ==
- real #draw_char( Font font, Vector2 pos, String char, String next, Color modulate=Color(1,1,1,1) ) \ Draw a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char. == draw_set_transform ==
- void #draw_set_transform( Vector2 pos, real rot, Vector2 scale ) \ Set a custom transform for drawing. Anything drawn afterwards will be transformed by this.