本文整理汇总了C++中draw_rectangle函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_rectangle函数的具体用法?C++ draw_rectangle怎么用?C++ draw_rectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_rectangle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: size
void add_noise_dialog::preview_window::paint (sxsdk::graphic_context_interface &gc, const sx::rectangle_class *visible_rectangle, void *) {
if(!preview_image) return;
if(dirty) {
const sx::vec<int,2> size(preview_image->get_size());
boost::scoped_array<sxsdk::rgb_class> buffer_rgb(new sxsdk::rgb_class[size.x * size.y]); // cut alpha channel.
preview_image->get_real_colors(0, 0, size.x, size.y, buffer_rgb.get());
preview_image->set_real_colors(0, 0, size.x, size.y, buffer_rgb.get());
dirty = false;
}
// 画像の縦横比に合わせて、余白部分を塗りつぶし
const sx::vec<int,2> preview_size = stored_image->uniscale_rectangle(get_client_rectangle(false), sx::rectangle_class(sx::vec<int,2>(0,0), stored_image->get_size())).size();
const sx::vec<int,2> background_size = get_client_rectangle(false).size();
sx::rectangle_class draw_rectangle(sx::vec<int, 2>(0, 0), preview_size);
const sx::vec<int,2> margin = (background_size - draw_rectangle.size()) / 2;
// draw_rectangle.offset(margin);
draw_rectangle += margin;
gc.set_color(sxsdk::rgb_class(0.2f, 0.2f, 0.2f));
if(margin.x > 0) {
sx::rectangle_class mask({ 0, 0 }, { margin.x, background_size.y });
gc.paint_rectangle(mask);
gc.paint_rectangle(mask + sx::vec<int,2>(draw_rectangle.max.x, 0));
}
if(margin.y > 0) {
sx::rectangle_class mask({ 0, 0 }, { background_size.x, margin.y });
gc.paint_rectangle(mask);
gc.paint_rectangle(mask + sx::vec<int,2>(0, draw_rectangle.max.y));
}
gc.restore_color(); // set_color() に対応して必ず呼び出す
// プレビューイメージを描画
gc.draw_image(preview_image, draw_rectangle);
}
示例2: calculate_clipping_rectangle
void
twidget::draw_debug_border(surface& frame_buffer, int x_offset, int y_offset)
{
SDL_Rect r = redraw_action_ == tredraw_action::partly
? calculate_clipping_rectangle(x_offset, y_offset)
: calculate_blitting_rectangle(x_offset, y_offset);
switch(debug_border_mode_) {
case 0:
/* DO NOTHING */
break;
case 1:
draw_rectangle(
r.x, r.y, r.w, r.h, debug_border_colour_, frame_buffer);
break;
case 2:
sdl_fill_rect(frame_buffer, &r, debug_border_colour_);
break;
default:
assert(false);
}
}
示例3: decode_and_draw
static void decode_and_draw(rectangle_t* obj, const area_t * limiting_canvas_area)
{
area_t canvas_area = widget_compute_canvas_area(obj->glyph, limiting_canvas_area);
canvas_t *canv = canvas_new(&canvas_area);
if (obj->corner_radius)
{
if (obj->is_filled) {
draw_solid_round_rectangle(canv, color_to_pixel(obj->fill_color), obj->corner_radius);
}
if (obj->has_border) {
draw_round_rectangle(canv, color_to_pixel(obj->border_color), obj->border_tickness, obj->corner_radius);
}
}
else
{
if (obj->is_filled) {
draw_solid_rectangle(canv, color_to_pixel(obj->fill_color));
}
if (obj->has_border) {
draw_rectangle(canv, color_to_pixel(obj->border_color), obj->border_tickness);
}
}
canvas_delete(canv);
}
示例4: i_mousemove
static void i_mousemove(void* widget, GdkEventButton *event, gpointer data) {
int x = event->x;
int y = event->y;
revert_pixbuf();
draw_rectangle(sx,sy,x,y);
/*printf("mouse move %d %d \n",x,y);*/
}
示例5: draw
void draw() const // draw the rectangle
{
shape:: draw();
draw_rectangle(xCo, yCo, xCo + width, yCo + height);
set_color(cWHITE); // draw diagonal
draw_line(xCo, yCo, xCo + width, yCo + height);
}
示例6: pika_p
//----------------------------------------------------
//pravokotna pika
void pika_p(float *sl, int w, int h, float size, float amp)
{
int i;
for (i=0;i<w*h;i++) sl[i]=0.5-amp/2.0; //background
draw_rectangle(sl, w, h, w/2-size/2, h/2-size/2, size, size, 0.5+amp/2.0);
}
示例7: consume_power_task
void consume_power_task(void *pvParam)
{
prepare_mobile(false);
power_screen(true);
LED_Light(led_white, true);
draw_rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
while(1);
}
示例8: grid
//----------------------------------------------------------
//draws a transparent mesurement grid
//*a = alpha channel
void grid(unsigned char *sl, int w, int h, unsigned char *a)
{
int i,j;
unsigned char black,white,tr;
black=0;
white=255;
tr=200; //how opaque are the marks
for (i=0;i<(w*h);i++) sl[i]=black; //black background
for (i=0;i<(w*h);i++) a[i]=0; //transparent
for (i=0;i<h;i=i+2)
for (j=0;j<w;j=j+10)
{
sl[i*w+j]=white;
a[i*w+j]=tr;
}
for (i=0;i<h;i=i+10)
for (j=0;j<w;j=j+2)
{
sl[i*w+j]=white;
a[i*w+j]=tr;
}
for (i=0;i<h;i=i+50)
for (j=0;j<w;j=j+50)
{
draw_rectangle(sl,w,h,i,j-1,1,3,white);
draw_rectangle(sl,w,h,i-1,j,3,1,white);
draw_rectangle(a,w,h,i,j-1,1,3,tr);
draw_rectangle(a,w,h,i-1,j,3,1,tr);
}
for (i=0;i<h;i=i+100)
for (j=0;j<w;j=j+100)
{
draw_rectangle(sl,w,h,i,j-4,1,9,white);
draw_rectangle(sl,w,h,i-4,j,9,1,white);
draw_rectangle(sl,w,h,i-1,j-1,3,3,white);
draw_rectangle(a,w,h,i,j-4,1,9,tr);
draw_rectangle(a,w,h,i-4,j,9,1,tr);
draw_rectangle(a,w,h,i-1,j-1,3,3,tr);
}
}
示例9: draw_cube
void ShZshapeManager::draw_shape(const char* content)
{
if (content == "cube")
{
draw_cube();
}
if (content == "cylinder")
{
draw_cylinder();
}
if (content == "pipe")
{
draw_pipe();
}
if (content == "cone")
{
draw_cone();
}
if (content == "circle")
{
draw_circle();
}
if (content == "ring")
{
draw_ring();
}
if (content == "pyramid")
{
draw_pyramid();
}
if (content == "triangle")
{
draw_triangle();
}
if (content == "rectangle")
{
draw_rectangle();
}
if (content == "polygon")
{
draw_polygon();
}
if (content == "multigonalStar")
{
draw_multigonalStar();
}
}
示例10: status_init_mode_flight
/*
* Initializes the persistent text / graphics for each mode
*/
void status_init_mode_flight(){
//Clear buffer
draw_rectangle(0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, DRAW_FILLED, VALUE_ON, OVERLAY_NAND);
//Write text labels
draw_text(STATUS_PITCH_X, STATUS_PITCH_Y, (char*) "Pitch", FONT_XSMALL_WIDTH, FONT_XSMALL_HEIGHT, ORIENTATION_NORMAL, font_xsmall, codepage_ascii_caps, VALUE_ON, OVERLAY_OR);
draw_text(STATUS_ROLL_X, STATUS_ROLL_Y, (char*) "Roll", FONT_XSMALL_WIDTH, FONT_XSMALL_HEIGHT, ORIENTATION_NORMAL, font_xsmall, codepage_ascii_caps, 1,OVERLAY_OR);
// degree symbols
draw_rectangle(63, 6, 65, 8, DRAW_UNFILLED, VALUE_ON, OVERLAY_OR);
draw_rectangle(63, 23, 65, 25, DRAW_UNFILLED, VALUE_ON, OVERLAY_OR);
//Draw invalid batteries
status_set_pilot_battery_level(-1);
status_set_control_battery_level(-1);
glcd_write_buffer();
}
示例11: show_cursor
static void show_cursor(int index, int color)
{
if (index < 0) return;
int x = (index % 4) * SLOT_W;
int y = 219 - (index / 4 + 1) * SLOT_H;
draw_rectangle(x, y, SLOT_W, SLOT_H - 2, color, 0);
}
示例12: status_init_mode_version
void status_init_mode_version(){
//Clear buffer
draw_rectangle(0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, DRAW_FILLED, VALUE_ON, OVERLAY_NAND);
//Write text labels
draw_text(STATUS_CONFIG_MODE_TITLE_X, STATUS_CONFIG_MODE_TITLE_Y, (char*) "Version", FONT_SMALL_WIDTH, FONT_SMALL_HEIGHT, ORIENTATION_NORMAL, font_small, codepage_ascii_caps, VALUE_ON, OVERLAY_OR);
glcd_write_buffer();
}
示例13: draw_rectangle
/*
* Abstract implementation to hightlight the shape.
* Draws a larger rectangle around shape.
*/
void Rectangle::highlight()
{
draw_rectangle(
color_yellow,
false,
_position.x - 5, _position.y - 5,
_width + 10, _height + 10
);
}
示例14: get_rect_by_corners
void Canvas::draw_zoom_rectangle( wxDC *dc )
{
wxRect drawn_rect = get_rect_by_corners( drag_start, drag_end );
wxRect max_rect(
wxSize( contents->GetWidth(), contents->GetHeight() )
* zoom_in_level / zoom_out_level );
if ( drawn_rect.Intersects( max_rect ) )
draw_rectangle( drawn_rect.Intersect( max_rect ), dc );
}
示例15: main_draw_shape
void main_draw_shape(struct template_t *tmp_tpl) {
char *sval = NULL;
if(template_get_setting_string(tmp_tpl, "shape", &sval) == 0) {
int filled = 0, x = 0, y = 0, width = fb_width(), height = fb_height(), border = 0, fcolor = 0;
int x1 = 0, x2 = 0, y1 = 0, y2 = 0, radius = 0, thickness = 1, zindex = 0;
unsigned short *color = NULL;
if(strcmp(sval, "rectangle") == 0 || strcmp(sval, "circle") == 0) {
template_get_setting_number(tmp_tpl, "x", &x);
template_get_setting_number(tmp_tpl, "y", &y);
template_get_setting_number(tmp_tpl, "border", &border);
template_get_setting_number(tmp_tpl, "filled", &filled);
} else if(strcmp(sval, "line") == 0) {
template_get_setting_number(tmp_tpl, "x1", &x1);
template_get_setting_number(tmp_tpl, "x2", &x2);
template_get_setting_number(tmp_tpl, "y1", &y1);
template_get_setting_number(tmp_tpl, "y2", &y2);
template_get_setting_number(tmp_tpl, "thickness", &thickness);
}
if(strcmp(sval, "rectangle") == 0) {
template_get_setting_number(tmp_tpl, "width", &width);
template_get_setting_number(tmp_tpl, "height", &height);
} else if(strcmp(sval, "circle") == 0) {
template_get_setting_number(tmp_tpl, "radius", &radius);
}
if(template_get_setting_color(tmp_tpl, "color", &color) != 0) {
color = malloc(sizeof(unsigned short)*3);
color[0] = 0, color[1] = 0, color[2] = 0;
fcolor = 1;
}
template_get_setting_number(tmp_tpl, "z-index", &zindex);
if(nodaemon == 0) {
if(strcmp(sval, "rectangle") == 0) {
if(filled) {
draw_rectangle_filled(x, y, zindex, width, height, draw_color(color[0], color[1], color[2]));
} else {
draw_rectangle(x, y, zindex, width, height, border, draw_color(color[0], color[1], color[2]));
}
} else if(strcmp(sval, "circle") == 0) {
if(filled) {
draw_circle_filled(x, y, zindex, radius, draw_color(color[0], color[1], color[2]));
} else {
draw_circle(x, y, zindex, radius, border, draw_color(color[0], color[1], color[2]));
}
} else if(strcmp(sval, "line") == 0) {
draw_line(x1, y1, x2, y2, zindex, thickness, draw_color(color[0], color[1], color[2]));
}
}
if(fcolor) {
free(color);
}
}
}