diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 976a5c4f1ed..21a3ecef320 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -756,6 +756,17 @@ void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const S VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,xform); } +void CanvasItem::draw_set_transform_matrix(const Matrix32& p_matrix) { + + if (!drawing) { + ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); + ERR_FAIL(); + } + + VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,p_matrix); + +} + void CanvasItem::draw_polygon(const Vector& p_points, const Vector& p_colors,const Vector& p_uvs, Ref p_texture) { if (!drawing) { @@ -1076,6 +1087,7 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1))); ObjectTypeDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform); + ObjectTypeDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix); ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); ObjectTypeDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform); ObjectTypeDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 8b44e098575..8a61b449fd4 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -222,6 +222,7 @@ public: float draw_char(const Ref& p_font,const Point2& p_pos, const String& p_char,const String& p_next="",const Color& p_modulate=Color(1,1,1)); void draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale); + void draw_set_transform_matrix(const Matrix32& p_matrix); /* RECT / TRANSFORM */