Ability to set draw transform as a matrix, closes #5428

This commit is contained in:
Juan Linietsky 2016-06-26 13:01:17 -03:00
parent fb9d1498bf
commit 130b83bc52
2 changed files with 13 additions and 0 deletions

View File

@ -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);

View File

@ -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 */