Esempio n. 1
0
void 
acfilter(int width, int height)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);
  glMatrixMode(GL_TEXTURE);

  if (pause) {
    draw_rect(width, height);
    stop();
    glClear(GL_COLOR_BUFFER_BIT);
  }
  draw_rect(width / 2, height / 2);
  stop();
  glAccum(GL_ACCUM, 0.25);

  glTranslatef(1.0 / width, 0, 0);
  draw_rect(width / 2, height / 2);
  stop();
  glAccum(GL_ACCUM, 0.25);

  glLoadIdentity();
  glTranslatef(0, 1.0 / height, 0);
  draw_rect(width / 2, height / 2);
  stop();
  glAccum(GL_ACCUM, 0.25);

  glLoadIdentity();
  glTranslatef(1.0 / width, 1.0 / height, 0);
  draw_rect(width / 2, height / 2);
  stop();
  glAccum(GL_ACCUM, 0.25);

  glAccum(GL_RETURN, 1.0);
  glMatrixMode(GL_MODELVIEW);
}
Esempio n. 2
0
// helper function for drawing - no more need to go mess with
// the main function when just want to change what to draw...
void draw() {

    int x;
    
    // some pixels
    for (x = 0; x < vinfo.xres; x+=5) {
        put_pixel(x, vinfo.yres / 2, WHITE);
    }

    // some lines (note the quite likely 'Moire pattern')
    for (x = 0; x < vinfo.xres; x+=20) {
        draw_line(0, 0, x, vinfo.yres - 1, GREEN);
    }
    
    // some rectangles
    draw_rect(vinfo.xres / 4, vinfo.yres / 2 + 10, vinfo.xres / 4, vinfo.yres / 4, PURPLE);    
    draw_rect(vinfo.xres / 4 + 10, vinfo.yres / 2 + 20, vinfo.xres / 4 - 20, vinfo.yres / 4 - 20, PURPLE);    
    fill_rect(vinfo.xres / 4 + 20, vinfo.yres / 2 + 30, vinfo.xres / 4 - 40, vinfo.yres / 4 - 40, YELLOW);    

    // some circles
    int d;
    for(d = 10; d < vinfo.yres / 6; d+=10) {
        draw_circle(3 * vinfo.xres / 4, vinfo.yres / 4, d, RED);
    }
    
    fill_circle(3 * vinfo.xres / 4, 3 * vinfo.yres / 4, vinfo.yres / 6, ORANGE);
    fill_circle(3 * vinfo.xres / 4, 3 * vinfo.yres / 4, vinfo.yres / 8, RED);

}
void draw_rectangles(struct msm_frame* newFrame)
{
  struct fd_roi_t *p_fd_roi;
#ifdef DRAW_RECTANGLES
  uint8_t i;
  for (i = 0; i < camframe_roi.num_roi; i++) {
    CDBG("%s: camframe_roi: i=%d, x=%d, y=%d, dx=%d, dy=%d\n", __func__,
      i, camframe_roi.roi[i].x, camframe_roi.roi[i].y,
      camframe_roi.roi[i].dx, camframe_roi.roi[i].dy);
    draw_rect((char*)newFrame->buffer, 640,
      camframe_roi.roi[i].x, camframe_roi.roi[i].y,
      camframe_roi.roi[i].dx, camframe_roi.roi[i].dy);
  }
#endif

#ifdef CAM_FRM_DRAW_FD_RECT
  p_fd_roi = (struct fd_roi_t *)newFrame->roi_info.info;
  if(p_fd_roi && p_fd_roi->rect_num > 0){
    int i;
    for(i =0; i < p_fd_roi->rect_num; i++)
    {
      draw_rect((char*)newFrame->buffer, 800,
        p_fd_roi->faces[i].x, p_fd_roi->faces[i].y,
        p_fd_roi->faces[i].dx, p_fd_roi->faces[i].dy);
    }
  }
#endif
}
Esempio n. 4
0
static void draw_buttons(void)
{
	if (cidx == CIDX_DEFAULT) {
		wattrset(dialogw, GET_PAIR_FOR(stgs.colors->def) | A_REVERSE);
		mvwaddstr(dialogw, left_pos.y, left_pos.x, dialog_cdef_msg);
		return;
	}

	int ymid = DIALOG_BUTTON_HEIGHT/2, xmid = DIALOG_BUTTON_WIDTH/2;
	wattrset(dialogw, GET_PAIR_FOR((picked_color != COLOR_NONE) ? picked_color : DIALOG_BUTTON_COLOR));
	draw_rect(dialogw, left_pos,  DIALOG_BUTTON_WIDTH, DIALOG_BUTTON_HEIGHT);
	draw_rect(dialogw, right_pos, DIALOG_BUTTON_WIDTH, DIALOG_BUTTON_HEIGHT);
	wattron(dialogw, A_REVERSE);
	mvwaddch(dialogw, left_pos.y+ymid,  left_pos.x+xmid,  turn2arrow(TURN_LEFT));
	mvwaddch(dialogw, right_pos.y+ymid, right_pos.x+xmid, turn2arrow(TURN_RIGHT));
	if (picked_turn != TURN_NONE) {
		draw_border(dialogw, (picked_turn == TURN_LEFT) ? left_pos : right_pos,
						DIALOG_BUTTON_WIDTH, DIALOG_BUTTON_HEIGHT);
	}

	if (cidx >= 0) {
		ymid = DIALOG_DELETE_HEIGHT/2, xmid = DIALOG_DELETE_WIDTH/2;
		wattrset(dialogw, GET_PAIR_FOR(DIALOG_DELETE_COLOR));
		draw_rect(dialogw, delete_pos, DIALOG_DELETE_WIDTH, DIALOG_DELETE_HEIGHT);
		wattron(dialogw, A_REVERSE);
		mvwaddstr(dialogw, delete_pos.y+ymid, delete_pos.x+xmid, "X");
	}
}
Esempio n. 5
0
static void movePos(int x1, int y1, int x2,int y2, int richting)
{
  int ret,wall,i,bo=1;
  ret=1;
  wall=Maze[x1][y1];

  if (wall&richting)
    {
      gc_sound_play_ogg ("sounds/brick.wav", NULL);
      ret=0;
    }
  if (ret)
    {
      gc_sound_play_ogg ("sounds/prompt.wav", NULL);
      if (Maze[x2][y2]&SET)
	{
	  for (i=(ind); i>=0 && bo; i--)
	    {

	      if(position[i][0]==x2 && position[i][1]==y2)
		{
		  bo=0;
		  move_image(mazegroup,x2,y2,tuxgroup);
		  //					draw_rect(mazegroup,x2,y2,"blue");
		}
	      else
		{
		  Maze[position[i][0]][position[i][1]]&=~SET;
		  draw_rect(mazegroup, position[i][0], position[i][1], "red");
		  draw_combined_rect(mazegroup,
				     position[i-1][0],position[i-1][1],
				     position[i][0],position[i][1],
				     "red");
		  ind--;
		}


	    }
	}
      else
	{
	  ind++;
	  position[ind][0]=x2;
	  position[ind][1]=y2;
	  Maze[x2][y2]|=SET;
	  if (position[ind][0]==(breedte-1) && position[ind][1]==(end))
	    {
	      gamewon = TRUE;
	      twoDdisplay();
	      gc_bonus_display(gamewon, GC_BONUS_LION);
	    }
	  else
	    {
	      draw_combined_rect(mazegroup, x1, y1, x2, y2, "green");
	      draw_rect(mazegroup,x1,y1,"green");
	      move_image(mazegroup,x2,y2,tuxgroup);
	    }
	}
    }
}
Esempio n. 6
0
//draw a header with draw_rect and draw_text
void draw_header()
{
	draw_rect(40, 20, 560, 60, colors[0]);
	draw_rect(50, 30, 540, 40, colors[2]);
	draw_rect(60, 40, 520, 20, colors[0]);
	draw_text(64, 44, "It'sa meeee!", colors[4]);
}
Esempio n. 7
0
static void draw_control_buttons(void)
{
	Vector2i o = { (MENU_BUTTON_HEIGHT-5)/2, (MENU_BUTTON_WIDTH-5)/2 };
	Vector2i pos1 = { menu_play_pos.y  + o.y, menu_play_pos.x  + o.x };
	Vector2i pos2 = { menu_pause_pos.y + o.y, menu_pause_pos.x + o.x };
	Vector2i pos3 = { menu_stop_pos.y  + o.y, menu_stop_pos.x  + o.x };

	wattrset(menuw, ui_pair);
	draw_rect(menuw, menu_play_pos,  MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT);
	draw_rect(menuw, menu_pause_pos, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT);
	draw_rect(menuw, menu_stop_pos,  MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT);

	wattrset(menuw, GET_PAIR_FOR(has_enough_colors(stgs.colors) ? MENU_PLAY_COLOR : MENU_INACTIVE_COLOR));
	draw_sprite(menuw, (SpriteInfo) { button_sprites[0], 5, 5 }, pos1, FALSE);

	wattrset(menuw, GET_PAIR_FOR(is_simulation_running(stgs.linked_sim) ? MENU_PAUSE_COLOR : MENU_INACTIVE_COLOR));
	draw_sprite(menuw, (SpriteInfo) { button_sprites[1], 5, 5 }, pos2, FALSE);
	
	if (has_simulation_started(stgs.linked_sim)) {
		wattrset(menuw, GET_PAIR_FOR(MENU_STOP_COLOR));
		draw_sprite(menuw, (SpriteInfo) { button_sprites[2], 5, 5 }, pos3, FALSE);
	} else {
		wattrset(menuw, GET_PAIR_FOR(!is_colors_empty(stgs.colors) ? MENU_CLEAR_COLOR : MENU_INACTIVE_COLOR));
		draw_sprite(menuw, (SpriteInfo) { button_sprites[3], 5, 5 }, pos3, FALSE);
	}
}
Esempio n. 8
0
void tooltip_update()
{
	if (!g_tooltip.tooltip_text) {
		tooltip_hide(0);
		return;
	}

	tooltip_update_geometry();
	if (just_shown) {
		if (!panel_horizontal)
			y -= height / 2; // center vertically
		just_shown = FALSE;
	}
	tooltip_adjust_geometry();
	XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height);

	// Stuff for drawing the tooltip
	cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height);
	cairo_t *c = cairo_create(cs);
	Color bc = g_tooltip.bg->fill_color;
	Border b = g_tooltip.bg->border;
	if (server.real_transparency) {
		clear_pixmap(g_tooltip.window, 0, 0, width, height);
		draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571);
		cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha);
	} else {
		cairo_rectangle(c, 0., 0, width, height);
		cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]);
	}
	cairo_fill(c);
	cairo_set_line_width(c, b.width);
	if (server.real_transparency)
		draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius);
	else
		cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width);
	cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha);
	cairo_stroke(c);

	Color fc = g_tooltip.font_color;
	cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha);
	PangoLayout *layout = pango_cairo_create_layout(c);
	pango_layout_set_font_description(layout, g_tooltip.font_desc);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
	pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
	PangoRectangle r1, r2;
	pango_layout_get_pixel_extents(layout, &r1, &r2);
	pango_layout_set_width(layout, width * PANGO_SCALE);
	pango_layout_set_height(layout, height * PANGO_SCALE);
	pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
	// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
	// vert.)
	cairo_move_to(c,
				  -r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
				  -r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
	pango_cairo_show_layout(c, layout);

	g_object_unref(layout);
	cairo_destroy(c);
	cairo_surface_destroy(cs);
}
Esempio n. 9
0
/// this function will print the given block and "childLevels" number of levels of its children under it.
// this is a recursive function.
// dest is the destination SDL_Surface that this will print to
// focus is the "top" block. "childLevels" of its children will be printed.
// highlight is the "selected" block or the "current" block.
// through the recursiveness, only the valid children will be printed.
short block_print_network_hierarchy(SDL_Surface *dest, struct blockData *focus, struct blockData *highlight, unsigned int childLevelsOrig, unsigned int childLevels, int x, int y, int size, Uint32 colorTop, Uint32 colorBot, Uint32 colorHighlight){
	
	static SDL_Rect highLightRect;
	
	if(dest == NULL) return 1;
	if(focus == NULL) return 2;
	// draw the focus block
	draw_rect(dest, x, y, size, size, 1, 0xff000000, color_mix_weighted(colorTop, colorBot, childLevels, childLevelsOrig-childLevels), 1);
	
	
	// quit if you have printed all of the necessary children.
	if(childLevels <= 0) return 0;
	
	int c;
	
	// print 9 more of this current block's children (if they exist)
	for(c=0; c<BLOCK_CHILDREN; c++){
		block_print_network_hierarchy(dest, focus->children[c], highlight, childLevelsOrig, childLevels-1, x + (c%((int)(BLOCK_LINEAR_SCALE_FACTOR)))*size/BLOCK_LINEAR_SCALE_FACTOR, y + (c/((int)(BLOCK_LINEAR_SCALE_FACTOR)))*size/BLOCK_LINEAR_SCALE_FACTOR, size/BLOCK_LINEAR_SCALE_FACTOR, colorTop, colorBot, colorHighlight);									
	}
	
	if(focus == highlight) draw_rect(dest, x, y, size, size, 1, colorHighlight, 0x00000000, 0);
	
	
	return 0;
}
Esempio n. 10
0
static void draw_io_buttons(void)
{
	Vector2i inner1 = { menu_load_pos.y+1, menu_load_pos.x+1 };
	Vector2i inner2 = { menu_save_pos.y+1, menu_save_pos.x+1 };

	wattrset(menuw, ui_pair);
	draw_rect(menuw, menu_load_pos, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT);
	draw_rect(menuw, menu_save_pos, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT);
	wattron(menuw, A_REVERSE);
	draw_rect(menuw, inner1, MENU_BUTTON_WIDTH-2, MENU_BUTTON_HEIGHT-2);
	draw_rect(menuw, inner2, MENU_BUTTON_WIDTH-2, MENU_BUTTON_HEIGHT-2);

	wattrset(menuw, fg_pair);
	mvwaddstr(menuw, inner1.y+1, inner1.x, " LOAD    ");
	mvwaddstr(menuw, inner1.y+2, inner1.x, "  FROM   ");
	mvwaddstr(menuw, inner1.y+3, inner1.x, "    FILE ");
	mvwaddstr(menuw, inner2.y+1, inner2.x, " SAVE    ");
	mvwaddstr(menuw, inner2.y+2, inner2.x, "   TO    ");
	mvwaddstr(menuw, inner2.y+3, inner2.x, "    FILE ");

	/* Draw status indicators */
	if (load_status != STATUS_NONE) {
		wattrset(menuw, GET_PAIR_FOR((load_status == STATUS_SUCCESS) ? COLOR_LIME : COLOR_RED));
		mvwvline(menuw, menu_load_pos.y, menu_load_pos.x+MENU_BUTTON_WIDTH, ACS_BLOCK, MENU_BUTTON_HEIGHT);
	}
	if (save_status != STATUS_NONE) {
		wattrset(menuw, GET_PAIR_FOR((save_status == STATUS_SUCCESS) ? COLOR_LIME : COLOR_RED));
		mvwvline(menuw, menu_save_pos.y, menu_save_pos.x+MENU_BUTTON_WIDTH, ACS_BLOCK, MENU_BUTTON_HEIGHT);
	}
}
Esempio n. 11
0
static void render(struct widget *w)
{
    struct widget_priv *priv = (struct widget_priv*) w->priv;
    struct canvas *ca = &w->ca;
    unsigned char i;
    unsigned int width = ca->width;
    int x;
    char buf[10];

    for (i = 0; i < 8; i++) {
        if ((w->cfg->props.mode == 0) || (w->cfg->props.mode == 1))
            sprintf(buf, "CH%u %4d", i+1, priv->ch_raw[i]);
        else
            sprintf(buf, "CH%u", i+1);
        draw_str(buf, 0, i*8+1, ca, 0);

        if ((w->cfg->props.mode == 0) || (w->cfg->props.mode == 2)) {
            x = priv->ch_raw[i] - 1000;
            if (x < 0)
                x = 0;
            else if (x > 1000)
                x = 1000;

            x = (x * (unsigned int) priv->bar_size) / 1000;

            draw_rect(width-priv->bar_size-1,      i*8, width-1, i*8+6, 3, ca);
            draw_rect(width-priv->bar_size,      i*8+1, width-2, i*8+5, 1, ca);

            draw_vline(width-priv->bar_size-1+x,   i*8+1, i*8+5, 1, ca);
            draw_vline(width-priv->bar_size-1+x-1, i*8+1, i*8+5, 3, ca);
            draw_vline(width-priv->bar_size-1+x+1, i*8+1, i*8+5, 3, ca);
        }
    }
}
Esempio n. 12
0
int main(int argc, char** argv)
{
	int i;

	init_graphics();

	char key;
	int x = (640-20)/2;
	int y = (480-20)/2;

	do
	{
		//draw a black rectangle to erase the old one
		draw_rect(x, y, 20, 20, Black);
		key = getkey();
		if(key == 'w') y-=10;
		else if(key == 's') y+=10;
		else if(key == 'a') x-=10;
		else if(key == 'd') x+=10;
		//draw a blue rectangle
		draw_rect(x, y, 20, 20, Blue);
		sleep_ms(20);
	} while(key != 'q');

	exit_graphics();

	return 0;

}
Esempio n. 13
0
/*
 * Draws the grid at zoom g->zoom and
 * centered at (g->cx, g->cy) on the grid
 * coordinate system.
 *
 * This function is in need of cleanup
 * especially for errors.
 * The 'for' loops seem duplicated,
 * except that sx += tile_size_x goes to sx -= tile_size_x,
 * same with the y axis. If there is a way to combine these,
 * the code would look so much better.
 */
void render(struct game *g)
{
	double tile_size_x = g->screen.width * g->grid.zoom / (GRID_NORMAL_SIZE * 100.0);
	double tile_size_y = g->screen.height * g->grid.zoom / (GRID_NORMAL_SIZE * 100.0);
	double num_tiles_w = GRID_NORMAL_SIZE * 100.0 / g->grid.zoom;
	double num_tiles_h = GRID_NORMAL_SIZE * 100.0 / g->grid.zoom;

	int i,j, sx, sy, w, h, cx, cy;
	w = round(tile_size_x) + 2;
	h = round(tile_size_y) + 2;
	cx = g->grid.cx;
	cy = g->grid.cy;
	for (i = 0, sx = (g->screen.width - tile_size_x) / 2; i < (num_tiles_w + 1)/ 2; i++, sx += tile_size_x) {
		for (j = 0, sy = (g->screen.height - tile_size_y) / 2; j < (num_tiles_h + 1) / 2; j++, sy += tile_size_y)
			draw_rect(g->screen.renderer, g->grid.data[cx + i][cy + j], sx-1, sy-1, w, h);
		for (j = 0, sy = (g->screen.height - tile_size_y) / 2; j < (num_tiles_h + 1) / 2; j++, sy -= tile_size_y)
			draw_rect(g->screen.renderer, g->grid.data[cx + i][cy - j], sx-1, sy-1, w, h);
	}
	for (i = 0, sx = (g->screen.width - tile_size_x) / 2; i < (num_tiles_w + 1)/ 2; i++, sx -= tile_size_x) {
		for (j = 0, sy = (g->screen.height - tile_size_y) / 2; j < (num_tiles_h + 1) / 2; j++, sy += tile_size_y)
			draw_rect(g->screen.renderer, g->grid.data[cx - i][cy + j], sx-1, sy-1, w, h);
		for (j = 0, sy = (g->screen.height - tile_size_y) / 2; j < (num_tiles_h + 1) / 2; j++, sy -= tile_size_y)
			draw_rect(g->screen.renderer, g->grid.data[cx - i][cy - j], sx-1, sy-1, w, h);
	}
}
Esempio n. 14
0
static void draw_tile(drawing *dr, game_drawstate *ds, game_state *state,
                      int x, int y, int tile, int flash_colour)
{
    if (tile == 0) {
        draw_rect(dr, x, y, TILE_SIZE, TILE_SIZE,
                  flash_colour);
    } else {
        int coords[6];
        char str[40];

        coords[0] = x + TILE_SIZE - 1;
        coords[1] = y + TILE_SIZE - 1;
        coords[2] = x + TILE_SIZE - 1;
        coords[3] = y;
        coords[4] = x;
        coords[5] = y + TILE_SIZE - 1;
        draw_polygon(dr, coords, 3, COL_LOWLIGHT, COL_LOWLIGHT);

        coords[0] = x;
        coords[1] = y;
        draw_polygon(dr, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);

        draw_rect(dr, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
                  TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
                  flash_colour);

        sprintf(str, "%d", tile);
        draw_text(dr, x + TILE_SIZE/2, y + TILE_SIZE/2,
                  FONT_VARIABLE, TILE_SIZE/3, ALIGN_VCENTRE | ALIGN_HCENTRE,
                  COL_TEXT, str);
    }
    draw_update(dr, x, y, TILE_SIZE, TILE_SIZE);
}
Esempio n. 15
0
void init(void) {
  window = window_create();
  window_stack_push(window, true /* Animated */);

  // TODO(dmnd) try another colour
  window_set_background_color(window, GColorBlack);

  // TODO(dmnd) try to remember what this does...
  // init both frames to 2
  draw_rect(0, 0, TILES_X, TILES_Y, 2);
  draw_rect(0, 0, TILES_X, TILES_Y, 2);

  // Init the layer for the display
  Layer *root_layer = window_get_root_layer(window);
  GRect frame = layer_get_frame(root_layer);
  display_layer = layer_create(frame);
  layer_set_update_proc(display_layer, &display_layer_update_cb);
  layer_add_child(root_layer, display_layer);

  unsigned char units;
  if (DEBUG) {
    units = SECOND_UNIT;
  } else {
    units = MINUTE_UNIT;
  }
  tick_timer_service_subscribe(units, &handle_minute_tick);
}
Esempio n. 16
0
void draw_rect_outline( float x, float y, float width, float height, float thickness ){
	glBegin( GL_POLYGON );
		draw_rect( x,y,width, thickness );
		draw_rect( x,y,thickness, height );		
		draw_rect( x+width,y,thickness, height );
		draw_rect( x,y+width,width, thickness );		
	glEnd();	
}
Esempio n. 17
0
static void
draw_rect_set(int y)
{
	draw_rect(10, y, 10, 10, -.75);
	draw_rect(30, y, 10, 10, -.25);
	draw_rect(50, y, 10, 10,  .25);
	draw_rect(70, y, 10, 10,  .75);
}
Esempio n. 18
0
void InterpolateVideo::draw_vectors(int processed)
{
// Draw arrows
	if(config.draw_vectors)
	{
		create_macroblocks();

		for(int i = 0; i < total_macroblocks; i++)
		{
			OpticFlowMacroblock *mb = macroblocks.get(i);
// 		    printf("InterpolateVideo::optic_flow %d x=%d y=%d dx=%d dy=%d\n",
// 		  	    __LINE__,
// 			    mb->x,
// 			    mb->y,
// 			    mb->dx / OVERSAMPLE,
// 			    mb->dy / OVERSAMPLE);

			if(processed)
			{
				draw_arrow(get_output(),
					mb->x,
					mb->y,
					mb->x - mb->dx / OVERSAMPLE,
					mb->y - mb->dy / OVERSAMPLE);

// debug
// 				if(mb->is_valid && mb->visible)
// 				{
// 					draw_arrow(get_output(),
// 						mb->x + 1,
// 						mb->y + 1,
// 						mb->x - mb->dx / OVERSAMPLE + 1,
// 						mb->y - mb->dy / OVERSAMPLE + 1);
// 				}
			}
			else
			{
				draw_pixel(get_output(),
					mb->x,
					mb->y);
			}
		}
		
// Draw center macroblock
		OpticFlowMacroblock *mb = macroblocks.get(
			x_macroblocks / 2 + y_macroblocks / 2 * x_macroblocks);
		draw_rect(get_output(),
			mb->x - config.macroblock_size / 2,
			mb->y - config.macroblock_size / 2,
			mb->x + config.macroblock_size / 2,
			mb->y + config.macroblock_size / 2);
		draw_rect(get_output(),
			mb->x - config.macroblock_size / 2 - config.search_radius,
			mb->y - config.macroblock_size / 2 - config.search_radius,
			mb->x + config.macroblock_size / 2 + config.search_radius,
			mb->y + config.macroblock_size / 2 + config.search_radius);
	}
}
Esempio n. 19
0
unsigned long callc vis_message(int id, int mdata, int sdata)
{
	if(id == 1 /* keys, lparam */)
	{
		switch(mdata)
		{
		case VK_RIGHT: /* add bars */
			bars_count++;
			draw_rect(vwx, vwy, vww, vwh, 0);
			return 1;

		case VK_LEFT: /* rem bars */
			bars_count--;
			if(bars_count < 1)bars_count = 1;
			draw_rect(vwx, vwy, vww, vwh, 0);
			return 1;

		case VK_UP: /* add bars ++ */
			bars_count += 10;
			draw_rect(vwx, vwy, vww, vwh, 0);
			return 1;

		case VK_DOWN: /* rem bars ++ */
			bars_count -= 10;
			if(bars_count < 1)bars_count = 1;
			draw_rect(vwx, vwy, vww, vwh, 0);
			return 1;

		case VK_NEXT:
			fallco++;
			return 1;

		case VK_PRIOR:
			if(fallco > 1)
				fallco--;
			return 1;

		case VK_SPACE:
			peak_mode_hold ^= 1;
			draw_rect(vwx, vwy, vww, vwh, 0);
			return 1;

		case VK_HOME:
			showfall ^= 1;
			break;

		case VK_END:
			showbars ^= 1;
			break;

		case VK_CONTROL:
			intensecolors ^= 1;
			break;
		}
	}

	return 0;
}
Esempio n. 20
0
  void draw()
  {
    if (duck)
      draw_rect(int(x - 16), int(y - 32) - 16, 32, 32, 150, 200, 150);
    else
      draw_rect(int(x - 16), int(y - 64) - 16, 32, 64, 150, 200, 150);

    FNT_Print(tty->font, screen, (int)x, (int)y-16, FNT_ALIGN_CENTER, "Hello\nWorld");
  }
Esempio n. 21
0
void draw_background (Area *a, cairo_t *c)
{
	if (a->bg->back.alpha > 0.0) {
		//printf("    draw_background (%d %d) RGBA (%lf, %lf, %lf, %lf)\n", a->posx, a->posy, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
		draw_rect(c, a->bg->border.width, a->bg->border.width, a->width-(2.0 * a->bg->border.width), a->height-(2.0*a->bg->border.width), a->bg->border.rounded - a->bg->border.width/1.571);
		cairo_set_source_rgba(c, a->bg->back.color[0], a->bg->back.color[1], a->bg->back.color[2], a->bg->back.alpha);
		cairo_fill(c);
	}

	if (a->bg->border.width > 0 && a->bg->border.alpha > 0.0) {
		cairo_set_line_width (c, a->bg->border.width);

		// draw border inside (x, y, width, height)
		draw_rect(c, a->bg->border.width/2.0, a->bg->border.width/2.0, a->width - a->bg->border.width, a->height - a->bg->border.width, a->bg->border.rounded);
		/*
		// convert : radian = degre * M_PI/180
		// definir le degrade dans un carre de (0,0) (100,100)
		// ensuite ce degrade est extrapoler selon le ratio width/height
		// dans repere (0, 0) (100, 100)
		double X0, Y0, X1, Y1, degre;
		// x = X * (a->width / 100), y = Y * (a->height / 100)
		double x0, y0, x1, y1;
		X0 = 0;
		Y0 = 100;
		X1 = 100;
		Y1 = 0;
		degre = 45;
		// et ensuite faire la changement d'unite du repere
		// car ce qui doit reste inchangee est les traits et pas la direction

		// il faut d'abord appliquer une rotation de 90 (et -180 si l'angle est superieur a  180)
		// ceci peut etre applique une fois pour toute au depart
		// ensuite calculer l'angle dans le nouveau repare
		// puis faire une rotation de 90
		x0 = X0 * ((double)a->width / 100);
		x1 = X1 * ((double)a->width / 100);
		y0 = Y0 * ((double)a->height / 100);
		y1 = Y1 * ((double)a->height / 100);

		x0 = X0 * ((double)a->height / 100);
		x1 = X1 * ((double)a->height / 100);
		y0 = Y0 * ((double)a->width / 100);
		y1 = Y1 * ((double)a->width / 100);

		cairo_pattern_t *linpat;
		linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
		cairo_pattern_add_color_stop_rgba (linpat, 0, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha);
		cairo_pattern_add_color_stop_rgba (linpat, 1, a->border.color[0], a->border.color[1], a->border.color[2], 0);
		cairo_set_source (c, linpat);
		*/
		cairo_set_source_rgba (c, a->bg->border.color[0], a->bg->border.color[1], a->bg->border.color[2], a->bg->border.alpha);

		cairo_stroke (c);
		//cairo_pattern_destroy (linpat);
	}
}
Esempio n. 22
0
static void draw_gradient(SkCanvas* canvas) {
    SkRect r = { 0, 0, SkIntToScalar(256), SkIntToScalar(32) };
    SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
    SkColor colors[] = { 0xFF000000, 0xFFFF0000 };
    SkPaint p;
    p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode));
    draw_rect(canvas, r, p);

    canvas->translate(0, SkIntToScalar(40));
    p.setDither(true);
    draw_rect(canvas, r, p);
}
Esempio n. 23
0
static void draw_block_box(fz_context *ctx, fz_html *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm)
{
	float x0, y0, x1, y1;
	float color[4];

	// TODO: background fill
	// TODO: border stroke

	float *border = box->border;
	float *padding = box->padding;

	x0 = box->x - padding[L];
	y0 = box->y - padding[T];
	x1 = box->x + box->w + padding[R];
	y1 = box->y + box->h + padding[B];

	if (y0 > page_bot || y1 < page_top)
		return;

	if (box->style.background_color.a > 0)
	{
		color[0] = box->style.background_color.r / 255.0f;
		color[1] = box->style.background_color.g / 255.0f;
		color[2] = box->style.background_color.b / 255.0f;
		color[3] = box->style.background_color.a / 255.0f;
		draw_rect(ctx, dev, ctm, color, x0, y0, x1, y1);
	}

	if (box->style.border_color.a > 0)
	{
		color[0] = box->style.border_color.r / 255.0f;
		color[1] = box->style.border_color.g / 255.0f;
		color[2] = box->style.border_color.b / 255.0f;
		color[3] = box->style.border_color.a / 255.0f;
		if (border[T] > 0)
			draw_rect(ctx, dev, ctm, color, x0 - border[L], y0 - border[T], x1 + border[R], y0);
		if (border[B] > 0)
			draw_rect(ctx, dev, ctm, color, x0 - border[L], y1, x1 + border[R], y1 + border[B]);
		if (border[L] > 0)
			draw_rect(ctx, dev, ctm, color, x0 - border[L], y0 - border[T], x0, y1 + border[B]);
		if (border[R] > 0)
			draw_rect(ctx, dev, ctm, color, x1, y0 - border[T], x1 + border[R], y1 + border[B]);
	}

	for (box = box->down; box; box = box->next)
	{
		switch (box->type)
		{
		case BOX_BLOCK: draw_block_box(ctx, box, page_top, page_bot, dev, ctm); break;
		case BOX_FLOW: draw_flow_box(ctx, box, page_top, page_bot, dev, ctm); break;
		}
	}
}
Esempio n. 24
0
void handle_init(AppContextRef ctx) {
  window_init(&window, "Illusion");
  window_stack_push(&window, true /* Animated */);

  // init both frames to 2
  draw_rect(0, 0, TILES_X, TILES_Y, 2);
  draw_rect(0, 0, TILES_X, TILES_Y, 2);

  // Init the layer for the display
  layer_init(&display_layer, window.layer.frame);
  display_layer.update_proc = &display_layer_update_cb;
  layer_add_child(&window.layer, &display_layer);
}
Esempio n. 25
0
void menu::draw_menu() {
	if (!is_open) return;
	if (current_index[current_menu] + 2 > option_count && current_menu == Players) current_index[current_menu] = option_count - 1;
	float difference = ((option_count > MAX_PP ? MAX_PP : option_count) * (.035 * 10)) / 10;
	draw_rect(x_axis, y_axis + .018, .205, .074, shader_color);
	draw_rect(x_axis, y_axis + .055 + difference / 2, .205, difference, background_color);
	draw_rect(x_axis, y_axis + .074 + difference, .205, .038, shader_color);
	draw_text(title, 1, 1, x_axis, y_axis - .024, white, center);
	draw_text(sub_title, 1, .55, x_axis, y_axis + .022, white, center);
	draw_text(creator_text, 1, .455, x_axis - .097, y_axis + difference + .058, white);
	draw_text((string)(current_index[current_menu] + 1) + "/" + (string)option_count, 1, .455, x_axis + .095, y_axis + difference + .058, white, right);
	draw_sprite("commonmenu", "arrowright", x_axis - .095, y_axis + .074 + (.035 * c_drawing_index), .022, .022, pointer_color);
	draw_instructions();
	draw_arrows();
}
Esempio n. 26
0
int callc fennec_visualization_initialize(struct general_visualization_data *sdata, string plgtitle)
{
	memcpy(&sfennec, sdata->shared, sizeof(struct fennec));
	memcpy(&visdata, sdata, sizeof(struct general_visualization_data));

	sdata->uninitialize = visualization_uninitialize;
	sdata->refresh      = visualization_refresh;
	sdata->settings     = visualization_settings;
	sdata->about        = visualization_about;

	sdata->fsettings.plugin_settings_getnum("vis.spectrum", "intense",   &intensecolors, 0, 0);
	sdata->fsettings.plugin_settings_getnum("vis.spectrum", "showfall",  &showfall, 0, 0);
	sdata->fsettings.plugin_settings_getnum("vis.spectrum", "showbars",  &showbars, 0, 0);
	sdata->fsettings.plugin_settings_getnum("vis.spectrum", "fallco",    &fallco, 0, 0);
	sdata->fsettings.plugin_settings_getnum("vis.spectrum", "barscount", &bars_count, 0, 0);

	str_cpy(plgtitle, uni("Spectrum Analyzer"));

	visdata.getdata(get_visual_dc, 0, &dc, 0);
	visdata.getdata(set_msg_proc, 0, vis_message, 0);
	visdata.getdata(get_visual, 0, &window_vis, 0);

	vwx = visdata.getdata(get_visual_x, 0, 0, 0);
	vwy = visdata.getdata(get_visual_y, 0, 0, 0);
	vww = visdata.getdata(get_visual_w, 0, 0, 0);
	vwh = visdata.getdata(get_visual_h, 0, 0, 0);

	draw_rect(vwx, vwy, vww, vwh, 0);

	timer_id = SetTimer(0, 0, 30, timer_display);

	col_bar_line = color_adjust(visdata.getdata(get_color, color_dark, 0, 0), 0.3);
	col_bar_fill = (COLORREF)visdata.getdata(get_color, color_dark, 0, 0);
	return 1;
}
Esempio n. 27
0
void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
{
	struct atyfb_par *par = (struct atyfb_par *) info->par;
	u32 color = rect->color, dx = rect->dx, width = rect->width, rotation = 0;

	if (par->asleep)
		return;
	if (!rect->width || !rect->height)
		return;
	if (!par->accel_flags) {
		cfb_fillrect(info, rect);
		return;
	}

	color |= (rect->color << 8);
	color |= (rect->color << 16);

	if (info->var.bits_per_pixel == 24) {
		/* In 24 bpp, the engine is in 8 bpp - this requires that all */
		/* horizontal coordinates and widths must be adjusted */
		dx *= 3;
		width *= 3;
		rotation = rotation24bpp(dx, DST_X_LEFT_TO_RIGHT);
	}

	wait_for_fifo(3, par);
	aty_st_le32(DP_FRGD_CLR, color, par);
	aty_st_le32(DP_SRC,
		    BKGD_SRC_BKGD_CLR | FRGD_SRC_FRGD_CLR | MONO_SRC_ONE,
		    par);
	aty_st_le32(DST_CNTL,
		    DST_LAST_PEL | DST_Y_TOP_TO_BOTTOM |
		    DST_X_LEFT_TO_RIGHT | rotation, par);
	draw_rect(dx, rect->dy, width, rect->height, par);
}
	bool GraphD3D9::add_bar( size_t thread_idx, size_t depth, const Insight::Token& t )
	{
		m_max_thread_idx = std::max(thread_idx, m_max_thread_idx);
				
		float start_ms		= float(double(t.time_enter - m_min_time) / double(m_cycles_per_ms));
		float stop_ms		= float(double(t.time_exit - m_min_time) / double(m_cycles_per_ms));

		float pos_x1 = start_ms;
		float pos_x2 = stop_ms;

		float pos_y1 = float(thread_idx) * g_thread_height + float(depth)*g_stack_height;
		float pos_y2 = (pos_y1 + g_bar_height) - float(depth)*g_stack_height;

		DWORD colour = m_colourman.calculate_colour(t.name);
		
		draw_rect(pos_x1, pos_y1, pos_x2, pos_y2, colour);

		BarInfo bi;
		bi.x1 = pos_x1;
		bi.x2 = pos_x2;
		bi.y1 = pos_y1;
		bi.y2 = pos_y2;
		bi.thread_idx = thread_idx;
		bi.name = t.name;

		m_bars.push(bi);

		return true;
	}
Esempio n. 29
0
static void draw_steps(void)
{
	static bool do_draw;
	Simulation *sim = stgs.linked_sim;
	size_t steps = sim ? sim->steps : 0;
	int len = (int)log10(steps) + 1;
	Vector2i tl = steps_pos;
	char digits[9], *d;

	if (steps <= 1) {
		do_draw = TRUE;
	} else if (!do_draw) {
		return;
	}

	wattrset(menuw, fg_pair);
	if (len > 8) {
		draw_sprite(menuw, (SpriteInfo) { inf_sprite, 31, 5 }, tl, TRUE);
		do_draw = FALSE;
		return;
	}

	sprintf(digits, "%8d", steps);
	for (d = digits; d < digits+8; d++) {
		if (*d != ' ') {
			int digit = *d - '0';
			wattroff(menuw, A_REVERSE);
			draw_sprite(menuw, (SpriteInfo) { digit_sprites[digit], 3, 5 }, tl, TRUE);
		} else {
			wattron(menuw, A_REVERSE);
			draw_rect(menuw, tl, 3, 5);
		}
		tl.x += 4;
	}
}
Esempio n. 30
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolShape::update(bool global){
	if(!global){
		clearTempPathContext(false);
	}
	if((get_active())&&(get_on_drag())){
		if(get_mnu_cmd()==kShapeRect){
			if(_ctr){
				draw_c_rect();
			}
			else{
				draw_rect();
			}
		}
		else{
			if(_ctr){
				draw_c_circle();
			}
			else{
				draw_circle();
			}
		}
	}
	if(!global){
		validTempPathContext();
	}
}