summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-26 13:01:17 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-26 13:01:17 -0300
commit130b83bc527b90448a36f8d6357183d29c837cd5 (patch)
tree38c0b775d06cb992298a75a7c40a370e1baebb98 /scene/2d
parentfb9d1498bf96f89773dff3f0e5ab6051b84f59bc (diff)
Ability to set draw transform as a matrix, closes #5428
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/canvas_item.cpp12
-rw-r--r--scene/2d/canvas_item.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 976a5c4f1e..21a3ecef32 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<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, Ref<Texture> 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 8b44e09857..8a61b449fd 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -222,6 +222,7 @@ public:
float draw_char(const Ref<Font>& 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 */