本文整理汇总了C++中VisualServer::canvas_item_add_rect方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualServer::canvas_item_add_rect方法的具体用法?C++ VisualServer::canvas_item_add_rect怎么用?C++ VisualServer::canvas_item_add_rect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualServer
的用法示例。
在下文中一共展示了VisualServer::canvas_item_add_rect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void StyleBoxFlat::draw(RID p_canvas_item,const Rect2& p_rect) const {
VisualServer *vs = VisualServer::get_singleton();
Rect2i r = p_rect;
for (int i=0;i<border_size;i++) {
Color color_upleft=light_color;
Color color_downright=dark_color;
if (blend) {
color_upleft.r=(border_size-i)*color_upleft.r/border_size + i*bg_color.r/border_size;
color_upleft.g=(border_size-i)*color_upleft.g/border_size + i*bg_color.g/border_size;
color_upleft.b=(border_size-i)*color_upleft.b/border_size + i*bg_color.b/border_size;
color_downright.r=(border_size-i)*color_downright.r/border_size + i*bg_color.r/border_size;
color_downright.g=(border_size-i)*color_downright.g/border_size + i*bg_color.g/border_size;
color_downright.b=(border_size-i)*color_downright.b/border_size + i*bg_color.b/border_size;
}
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i( r.pos.x,r.pos.y+r.size.y-1), Size2(r.size.x ,1 )),color_downright);
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i( r.pos.x+r.size.x-1,r.pos.y ), Size2( 1 ,r.size.y )), color_downright);
vs->canvas_item_add_rect(p_canvas_item, Rect2( r.pos, Size2(r.size.x ,1 )), color_upleft);
vs->canvas_item_add_rect(p_canvas_item, Rect2( r.pos, Size2( 1 ,r.size.y )), color_upleft);
r.pos.x++;
r.pos.y++;
r.size.x-=2;
r.size.y-=2;
}
if (draw_center)
vs->canvas_item_add_rect(p_canvas_item, Rect2( r.pos, r.size) , bg_color );
}
示例2: draw
void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
VisualServer *vs = VisualServer::get_singleton();
Rect2i r = p_rect;
for (int i = 0; i < border_size; i++) {
Color color_upleft = light_color;
Color color_downright = dark_color;
if (blend) {
color_upleft.r = (border_size - i) * color_upleft.r / border_size + i * bg_color.r / border_size;
color_upleft.g = (border_size - i) * color_upleft.g / border_size + i * bg_color.g / border_size;
color_upleft.b = (border_size - i) * color_upleft.b / border_size + i * bg_color.b / border_size;
color_downright.r = (border_size - i) * color_downright.r / border_size + i * bg_color.r / border_size;
color_downright.g = (border_size - i) * color_downright.g / border_size + i * bg_color.g / border_size;
color_downright.b = (border_size - i) * color_downright.b / border_size + i * bg_color.b / border_size;
}
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.position.x, r.position.y + r.size.y - 1), Size2(r.size.x, 1)), color_downright);
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.position.x + r.size.x - 1, r.position.y), Size2(1, r.size.y)), color_downright);
vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, Size2(r.size.x, 1)), color_upleft);
vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, Size2(1, r.size.y)), color_upleft);
r.position.x++;
r.position.y++;
r.size.x -= 2;
r.size.y -= 2;
}
if (draw_center)
vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, r.size), bg_color);
Rect2i r_add = p_rect;
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y - additional_border_size[MARGIN_TOP]), Size2(r_add.size.width + additional_border_size[MARGIN_LEFT] + additional_border_size[MARGIN_RIGHT], additional_border_size[MARGIN_TOP])), light_color);
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y), Size2(additional_border_size[MARGIN_LEFT], r_add.size.height)), light_color);
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x + r_add.size.width, r_add.position.y), Size2(additional_border_size[MARGIN_RIGHT], r_add.size.height)), dark_color);
vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y + r_add.size.height), Size2(r_add.size.width + additional_border_size[MARGIN_LEFT] + additional_border_size[MARGIN_RIGHT], additional_border_size[MARGIN_BOTTOM])), dark_color);
}