コード例 #1
0
ファイル: interpolatevideo.C プロジェクト: knutj/cinelerra
void InterpolateVideo::draw_line(VFrame *frame, int x1, int y1, int x2, int y2)
{
	int w = labs(x2 - x1);
	int h = labs(y2 - y1);
//printf("InterpolateVideo::draw_line 1 %d %d %d %d\n", x1, y1, x2, y2);

	if(!w && !h)
	{
		draw_pixel(frame, x1, y1);
	}
	else
	if(w > h)
	{
// Flip coordinates so x1 < x2
		if(x2 < x1)
		{
			y2 ^= y1;
			y1 ^= y2;
			y2 ^= y1;
			x1 ^= x2;
			x2 ^= x1;
			x1 ^= x2;
		}
		int numerator = y2 - y1;
		int denominator = x2 - x1;
		for(int i = x1; i < x2; i++)
		{
			int y = y1 + (int64_t)(i - x1) * (int64_t)numerator / (int64_t)denominator;
			draw_pixel(frame, i, y);
		}
	}
	else
	{
// Flip coordinates so y1 < y2
		if(y2 < y1)
		{
			y2 ^= y1;
			y1 ^= y2;
			y2 ^= y1;
			x1 ^= x2;
			x2 ^= x1;
			x1 ^= x2;
		}
		int numerator = x2 - x1;
		int denominator = y2 - y1;
		for(int i = y1; i < y2; i++)
		{
			int x = x1 + (int64_t)(i - y1) * (int64_t)numerator / (int64_t)denominator;
			draw_pixel(frame, x, i);
		}
	}
//printf("InterpolateVideo::draw_line 2\n");
}
コード例 #2
0
ファイル: library.c プロジェクト: Chris-grant1995/CS1550
void draw_rect(int x1, int y1, int width, int height, color_t c) {
    int vert =0;
    int hori = 0;
    for(hori = x1; hori < width+x1; hori++) {
        draw_pixel(hori,y1,c);
        draw_pixel(hori,y1+height,c);
    }
    for(vert =y1; vert<height+y1; vert++) {
        draw_pixel(x1, vert, c);
        draw_pixel(x1+width, vert,c);
    }
}
コード例 #3
0
ファイル: draw.c プロジェクト: pchickey/arrow-watch
void
draw_line(
	color24_t c,
	uint32_t x0,
	uint32_t y0,
	uint32_t x1,
	uint32_t y1
)
{
	const int32_t dx = abs(x1 - x0);
	const int32_t dy = abs(y1 - y0);

	const int32_t sx = x0 < x1 ? 1 : -1;
	const int32_t sy = y0 < y1 ? 1 : -1;
	int32_t err = dx - dy;

#if VSCREEN_SHIFT != 0
	uint32_t last_px = -1;
	uint32_t last_py = -1;
#endif

	while(1)
	{
#if VSCREEN_SHIFT != 0
		uint32_t px = x0 >> VSCREEN_SHIFT;
		uint32_t py = y0 >> VSCREEN_SHIFT;
		if (px != last_px || py != last_py)
		{
			last_px = px;
			last_py = py;
			draw_pixel(c, x0, y0);
		}
#else
		draw_pixel(c, x0, y0);
#endif

		if (x0 == x1 && y0 == y1)
			break;
		int32_t e2 = 2 * err;
		if (e2 > -dy)
		{
			err -= dy;
			x0 += sx;
		}
		if (e2 < +dx)
		{
			err += dx;
			y0 += sy;
		}
	}
}
コード例 #4
0
ファイル: library.c プロジェクト: D-Land/operating-systems
void draw_rect(int x1, int y1, int width, int height, color_t c){
  int x = 0;
  int y = 0;

  for(x = x1; x <= width+1; x++){
    draw_pixel(x, y1, c);
    draw_pixel(x, y1 + height, c);
  }

  for(y = y1; y <= height+2; y++){
    draw_pixel(x1, y, c);
    draw_pixel(x1 + width, y, c);
  }
}
コード例 #5
0
ファイル: pattern_peak_spike.cpp プロジェクト: moonfall/lush
bool Pattern_peak_spike::display()
{
#undef LOG_PEAKS
#ifdef LOG_PEAKS
    const int max_dots = 64;
    char dots[max_dots + 2];
    memset(dots, ' ', sizeof(dots));
    dots[max_dots] = '|';
    dots[max_dots + 1] = '\0';
    memset(dots, '.', get_mapped_peak(max_dots));
    Serial.printf("peak %5u %s\n", get_peak(), dots);
#endif

    Colour c = make_hue(g_hue.get());

    int leds = get_mapped_peak(LED_COUNT / 2);

#define FADE_PEAK
#ifdef FADE_PEAK
    static Value held_leds(0, 0, LED_COUNT / 2);
    held_leds.set_velocity(-10, 60);
    if (leds > held_leds.get()) {
	held_leds.set(leds);
    }
    leds = held_leds.get();
#endif

    // Start drawing out from the bottom middle both up and horizontally.
    int start_x = COLUMN_COUNT / 2;
    int start_y = ROW_COUNT - 1;
    int x = start_x;
    int y = start_y;
    for (int led = 0; led < leds; ++led) {
	draw_pixel(x, y, c);
	draw_pixel(flip_x(x), y, c);
	++x;
	++y;
	if (x >= COLUMN_COUNT || y >= ROW_COUNT) {
	    --start_y;
	    if (start_y < 0) {
		start_y = 0;
		++start_x;
	    }
	    x = start_x;
	    y = start_y;
	}
    }

    return true;
}
コード例 #6
0
ファイル: breakmeggy.c プロジェクト: nelfin/yameggyjros
static void inline draw_blocks(uint8_t blocks[][4]) {
    uint8_t i, j;
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 4; j++) {
            if (blocks[i][j]) {
                draw_pixel(2*i, j+4, cff5500);
                draw_pixel(2*i+1, j+4, cff5500);
            } else {
                draw_pixel(2*i, j+4, c000000);
                draw_pixel(2*i+1, j+4, c000000);
            }
        }
    }
}
コード例 #7
0
ファイル: SDL_lib.cpp プロジェクト: jirkadanek/bombic2
/**
 * @param surface cíl
 * @param x1 počáteční souřadnice úsečky
 * @param y1 počáteční souřadnice
 * @param x2 koncové souřadnice úsečky
 * @param y2 koncové souřadnice úsečky
 * @param color barva úsečky
 */
void draw_line(SDL_Surface* surface, int x1, int y1, int x2, int y2, SDL_Color color){
	// pres parametrickou rovnici usecky
	// kazdy bod Z usecky AB se spocita
	// Z = A + (B-A)t
	// pro 0<= t <= 1
	int length, w=(x2-x1), h=(y2-y1), t;
	// length= sqrt(w^2+h^2);
		length= w*w + h*h;
		for( t=0 ; t*t<length ; ++t); length=t;
	// vhodne zdrobnely parametr vykresli dostatecne mnoho pixelu
	if(length){
		for( t=0 ; t<=length ; ++t )
			draw_pixel(surface, x1 + w*t/length, y1 + h*t/length ,color);
	} else	draw_pixel(surface, x1, y1 ,color);
}
コード例 #8
0
void print_character(uint16_t *colour_ptr, uint32_t x, uint32_t y, volatile unsigned char *fb) {
  for (int i = 0; i < CHAR_WIDTH; ++i) {
    for (int j = 0; j < CHAR_HEIGHT; ++j) {
      draw_pixel(x + j, y + i, fb, colour_ptr[j + (i * CHAR_WIDTH)]);
    }
  }
}
コード例 #9
0
ファイル: Canvas.cpp プロジェクト: niesteszeck/Cosa
void
Canvas::fill_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height)
{
    for (uint8_t i = 0; i < width; i++)
        for (uint8_t j = 0; j < height; j++)
            draw_pixel(x + i, y + j);
}
コード例 #10
0
ファイル: main.c プロジェクト: flightcrank/demo-effects
void smooth_buffer(struct pixel_buffer* pix) {

	int x,y;
	
	for (x = 0; x < pix->width; x++) {
		
		for (y = 0; y < pix->height; y++) {
			
			int left = (x - 1) % pix->width;
			int right = (x + 1) % pix->width;
			int up 	= (y - 1) % pix->height;
			int down = (y + 1) % pix->height;

			if (left < 0) {
				
				left = left + pix->width;
			}
			
			if (up < 0) {
				
				up = up + pix->height;
			}

			Uint32 val = (get_pixel(pix, x, up) + get_pixel(pix, x, down) + get_pixel(pix, left, y) + get_pixel(pix, right, y)) / 4;
			
			draw_pixel(pix, x, y, val);
		}
	}
}
コード例 #11
0
ファイル: julia.c プロジェクト: aputman-Raptor/fract-ol
static void	fract_j(t_env *env, t_fract fr)
{
	double	rn1;
	double	in1;
	double	rn;
	double	in;
	int		a;

	rn1 = 2.0 * (fr.x - env->win_x / 2) / (0.5 * env->zoom * env->win_x) +
		env->pos_x;
	in1 = (fr.y - env->win_y / 2) / (0.5 * env->zoom * env->win_y) + env->pos_y;
	a = -1;
	while (++a < (env->iter - 1))
	{
		rn = rn1;
		in = in1;
		rn1 = (rn * rn) - (in * in) + fr.rc;
		in1 = 2 * rn * in + fr.ic;
		if ((rn1 * rn1 + in1 * in1) > 4)
			break ;
	}
	get_color_palette(env, env->color, a, env->pal);
	if ((fr.x >= 0 && fr.x < env->win_x) && (fr.y >= 0 && fr.y < env->win_y)
			&& a < (env->iter - 1))
		draw_pixel(env, fr.x, fr.y, env->color);
}
コード例 #12
0
ファイル: rc_render.c プロジェクト: mimusangel/wolf3d
static void	draw_wall(t_event *e, t_raycast *rc, t_vec2 *p, int line_height)
{
	int	color;
	int id;

	if (!e->texture_mode)
	{
		if (rc->side)
			color = rc->step.y > 0 ? 0xff0000 : 0xffff00;
		else
			color = rc->step.x > 0 ? 0x00ff00 : 0x00ffff;
	}
	else
	{
		id = e->game.map[rc->map.y][rc->map.x];
		rc->tex.y = (p->y * 2 - e->height + line_height)
			* (e->textures[id].height / 2) / line_height;
		color = e->textures[id].data[rc->tex.y
			* e->textures[id].width + rc->tex.x];
		if (rc->side)
			color = color_fusion(color, 0x0f0f0f);
		else
			color = color_fusion(color, 0x1f1f1f);
	}
	draw_pixel(e, p->x, p->y, color);
	free(p);
}
コード例 #13
0
ファイル: anim.c プロジェクト: doremi/sdl
static inline void draw_xy(int x, int y,
			unsigned char r,
			unsigned char g,
			unsigned char b)
{
	draw_pixel(x + centerX, centerY - y, r, g, b);
}
コード例 #14
0
ファイル: main.cpp プロジェクト: Siemko/PIU
	void press_event(MouseEvent ev)
	{
		pressed = true;
		draw_pixel(ev.x, ev.y);
		last_x = ev.x;
		last_y = ev.y;
	}
コード例 #15
0
void draw_bitmap(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint16_t *sprite, volatile unsigned char *fb) {
  for (int i = 0; i < width; ++i) {
    for (int j = 0; j < height; ++j) {
      draw_pixel(x + i, y + j, fb, sprite[i + (width * j)]);
    }
  }
}
コード例 #16
0
ファイル: gui_snake.c プロジェクト: BioDesignRealWorld/CHDK
static void draw_element(int x,int y,const char element[8][8],char angle){
  x = x * SNAKE_ELEMENT_SIZE;
  y = y * SNAKE_ELEMENT_SIZE;
  int xx,yy;
  for(xx=0;xx<SNAKE_ELEMENT_SIZE;xx++)
    for(yy=0;yy<SNAKE_ELEMENT_SIZE;yy++){
      char c = COLOR_RED;
      char col = 0;

      if(angle == 0) col = element[yy][xx];
      if(angle == 1) col = element[xx][7-yy];
      if(angle == 2) col = element[xx][yy];
      if(angle == 3) col = element[yy][7-xx];
      if(angle == 4) col = element[7-xx][yy];
      switch(col){
        case 'R': c = COLOR_RED; break;
        case 'G': c = COLOR_GREEN; break;
        case 'B': c = COLOR_BLACK; break;
        case 'b': c = COLOR_BLUE; break;
        case 'Y': c = COLOR_YELLOW; break;
        case 'O': c = 0x28; break;
        default: c = COLOR_WHITE; break;
      };
      draw_pixel( x+xx, y+yy, c );
    }
}
コード例 #17
0
void draw_blank_tile(int x_pos, int y_pos, volatile unsigned char *fb) {
  for (int y = 0; y < 8; ++y) {
    for (int x = 0; x < 8; ++x) {
      draw_pixel(x + x_pos + X_OFFSET_GAME, y + y_pos + Y_OFFSET_GAME, fb, 0);
    }
  }
}
コード例 #18
0
void draw_score_sprite(int point, int offset, ghost *ghost_ptr, volatile unsigned char *fb) {
  Sprite *score = (Sprite *) malloc(sizeof(Sprite));
  score->height = 16;
  score->width = 16;
  switch(point) {
    case 200:
      score->bitmap = points_200;
      break;
    case 400:
      score->bitmap = points_400;
      break;
    case 800:
      score->bitmap = points_800;
      break;
    case 1600:
      score->bitmap = points_1600;
      break;
  }
  int x_pos = ghost_ptr->x;
  int y_pos = ghost_ptr->y + offset;
  x_pos -= 9;
  y_pos -= 9;
  int width = score->width;
  int height = score->height;
  for (int y = 0; y < height; ++y) {
    for (int x = 0; x < width; ++x) {
      if(*(score->bitmap + x + (y * width))) {
        draw_pixel(x + x_pos + X_OFFSET_GAME, y + y_pos + Y_OFFSET_GAME, fb, *(score->bitmap + x + (y * width)));
      }
    }
  }
  free(score);
}
コード例 #19
0
ファイル: globals.c プロジェクト: boerge42/rpi_gui
// ********************************************
void jpeg_output(const char * fname, int x0, int y0, int dx, int dy)
{
	struct jpeg_decompress_struct cinfo;
	struct jpeg_error_mgr jerr;
	FILE *infile;
	JSAMPARRAY buffer;
	int i,j,x=x0,y=y0;
	
	cinfo.err = jpeg_std_error(&jerr);
	jpeg_create_decompress(&cinfo);
	if((infile = fopen(fname,"rb")) == NULL) {
		printf("Error: can't open file: %s\n", fname);
		return;
	}
	jpeg_stdio_src(&cinfo, infile);
	jpeg_read_header(&cinfo, TRUE);
	jpeg_start_decompress(&cinfo);
	buffer=(*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, cinfo.output_width*cinfo.output_components, 1);	
	i=cinfo.output_width*cinfo.output_components*sizeof(char);
	while(cinfo.output_scanline < cinfo.output_height) {
		jpeg_read_scanlines(&cinfo, buffer, 1);
		j=0;
		while(j<=i)	{
			if ((x<(x0+dx))&&((y<(y0+dy))))
				draw_pixel(x, y, buffer[0][j],buffer[0][j+1],buffer[0][j+2]);
			j+=3;
			x++;
		}
		y++;
		x=x0;
	}	
	jpeg_finish_decompress(&cinfo);
	jpeg_destroy_decompress(&cinfo);
	fclose(infile);
}
コード例 #20
0
ファイル: FBDraw.c プロジェクト: tolma488/metro-spb
void draw_filled_rect_buffer(GBitmap *buffer, GRect rect, GColor color) {
    for(int x = rect.origin.x; x < rect.origin.x + rect.size.w; x++){
        for(int y = rect.origin.y; y < rect.origin.y + rect.size.h; y++){
            draw_pixel(buffer, GPoint(x, y), color);
        }
    }
}
コード例 #21
0
ファイル: FontEngine.c プロジェクト: Gucan/h3_lichee
__s32 draw_cursor(__u32 ori_x, __u32 ori_y , __u32 color)
{
	__u32 i, j;
	__u8  *p;
	__u8  alpha[64];    //alpha
	SFTE_Bitmap         *bitmap;

    bitmap = &(face->glyph->bitmap);
	p = (__u8 *)bitmap->buffer;

	ori_x += face->glyph->bitmap_left;
	ori_y += font->base_psize + font->bbox_ymin - face->glyph->bitmap_top;

	for( i = 0;  i < bitmap->rows; i++ )
    {
		for( j = 0;  j < bitmap->width;  j++ )
		{
			if( bitmap->pitch > 0 )
				alpha[j] = p[ i * bitmap->pitch + j ];
			else
				alpha[j] = p[ ( bitmap->rows - 1 - i ) * -(bitmap->pitch) + j ];
		}
		draw_pixel( ori_x, ori_y + i, bitmap->width, alpha, color);
    }

    return  face->glyph->advance.x >> 6;
}
コード例 #22
0
ファイル: lissa.c プロジェクト: OPSF/uClinux
void draw_lissajous(void)
{
	float t, a, b, d, n, ap, bp;
	int x, y;
	
	static struct {int x, y;} keep[400];
	
	int pos=0;
	
	
	n = M_PIf;
	d = 0.1;
	
	ap = screen_width/2;
	bp = screen_width/2;
	a = screen_width / M_PIf;
	b = screen_height / M_PIf;
	
	
	for (t=0.0; t<50.0; t+=0.04) {
		x = ap + a * cos(t);
		y = bp + b * sin(n * t - d);
		
		draw_rectangle(keep[pos].x-1, keep[pos].y-1, keep[pos].x+1, keep[pos].y+1, 0);
		keep[pos].x = x;
		keep[pos].y = y;
		pos = (pos + 1) % 100;;

		draw_rectangle(x-1, y-1, x+1, y+1, 1);
		draw_pixel(x, y, 0);

	}
}
コード例 #23
0
ファイル: gui_space.c プロジェクト: barryk/CHDK-SD1200
static void gui_space_draw_icon () {
    coord x;
    color cl = conf.space_color;
    int perc = get_space_perc();
    if (conf.space_warn_type == 0){
    cl = (perc<=conf.space_perc_warn)?conf.osd_color_warn:(conf.space_color);
    }
    if (conf.space_warn_type == 1){
    cl = (GetFreeCardSpaceKb()/1024<=conf.space_mb_warn)?conf.osd_color_warn:(conf.space_color);
    }
    if (conf.space_warn_type == 2){
    cl = conf.space_color;
    }
    int i;
    int le = 23;//length
    int wi = 15;//width
 
    draw_line(conf.space_icon_pos.x+5,      conf.space_icon_pos.y,       conf.space_icon_pos.x+le,     conf.space_icon_pos.y,       COLOR_BLACK);  // outer top
    draw_line(conf.space_icon_pos.x+6,      conf.space_icon_pos.y+1,     conf.space_icon_pos.x+le-1,   conf.space_icon_pos.y+1,     MAKE_COLOR(cl, cl));  // inner top
    draw_line(conf.space_icon_pos.x,        conf.space_icon_pos.y+5,     conf.space_icon_pos.x,        conf.space_icon_pos.y+wi,    COLOR_BLACK);  // outer left
    draw_line(conf.space_icon_pos.x+1,      conf.space_icon_pos.y+6,     conf.space_icon_pos.x+1,      conf.space_icon_pos.y+wi-1,  MAKE_COLOR(cl, cl));  // inner left
    draw_line(conf.space_icon_pos.x,        conf.space_icon_pos.y+wi,    conf.space_icon_pos.x+le,     conf.space_icon_pos.y+wi,    COLOR_BLACK);  // outer bottom
    draw_line(conf.space_icon_pos.x+1,      conf.space_icon_pos.y+wi-1,  conf.space_icon_pos.x+le-1,   conf.space_icon_pos.y+wi-1,  MAKE_COLOR(cl, cl));  // inner bottom
    draw_line(conf.space_icon_pos.x+le,     conf.space_icon_pos.y,       conf.space_icon_pos.x+le,     conf.space_icon_pos.y+wi,    COLOR_BLACK);  // outer right
    draw_line(conf.space_icon_pos.x+le-1,   conf.space_icon_pos.y+1,     conf.space_icon_pos.x+le-1,   conf.space_icon_pos.y+wi-1,  MAKE_COLOR(cl, cl));  // inner right
    draw_line(conf.space_icon_pos.x+5,      conf.space_icon_pos.y,       conf.space_icon_pos.x,        conf.space_icon_pos.y+5,     COLOR_BLACK);  // edge
    draw_line(conf.space_icon_pos.x+5,      conf.space_icon_pos.y+1,     conf.space_icon_pos.x+1,      conf.space_icon_pos.y+5,     MAKE_COLOR(cl, cl));  // edge
    draw_line(conf.space_icon_pos.x+6,      conf.space_icon_pos.y+1,     conf.space_icon_pos.x+1,      conf.space_icon_pos.y+6,     MAKE_COLOR(cl, cl));  // edge
 
    // memory fill
    x=le-(perc*(le-3)/100)-2;
    if (x>5) draw_line(conf.space_icon_pos.x+6,      conf.space_icon_pos.y+2,     conf.space_icon_pos.x+x,      conf.space_icon_pos.y+2,     COLOR_BLACK);
    if (x>2) draw_line(conf.space_icon_pos.x+x+1,    conf.space_icon_pos.y+2,     conf.space_icon_pos.x+le-2,   conf.space_icon_pos.y+2,     MAKE_COLOR(cl, cl));
    else     draw_line(conf.space_icon_pos.x+4,      conf.space_icon_pos.y+2,     conf.space_icon_pos.x+le-2,   conf.space_icon_pos.y+2,     MAKE_COLOR(cl, cl));
    for(i=3;i<7;i++){                                                                                                                                               //          /--------------|
        if (x>7-i) draw_pixel(conf.space_icon_pos.x+8-i,     conf.space_icon_pos.y+i,     COLOR_BLACK);                                                             //        /  1st for loop  |
        if (x>7-i) draw_pixel(conf.space_icon_pos.x+x,       conf.space_icon_pos.y+i,     COLOR_BLACK);                                                             //      /__________________|
        draw_line(conf.space_icon_pos.x+x+1,                 conf.space_icon_pos.y+i,     conf.space_icon_pos.x+le-2,     conf.space_icon_pos.y+i,     MAKE_COLOR(cl, cl));//     |                   |
    }                                                                                                                                                               //     |     2nd for loop  |
    for(i=7;i<wi-2;i++){                                                                                                                                            //     |                   |
        if (x>1) draw_pixel(conf.space_icon_pos.x+2,         conf.space_icon_pos.y+i,     COLOR_BLACK);                                                             //     |-------------------|
        if (x>1) draw_pixel(conf.space_icon_pos.x+x,         conf.space_icon_pos.y+i,     COLOR_BLACK);
        draw_line(conf.space_icon_pos.x+x+1,                 conf.space_icon_pos.y+i,     conf.space_icon_pos.x+le-2,     conf.space_icon_pos.y+i,     MAKE_COLOR(cl, cl));
    }
    if (x>1) draw_line(conf.space_icon_pos.x+2,      conf.space_icon_pos.y+wi-2,    conf.space_icon_pos.x+x,      conf.space_icon_pos.y+wi-2,    COLOR_BLACK);
    draw_line(conf.space_icon_pos.x+x+1,             conf.space_icon_pos.y+wi-2,    conf.space_icon_pos.x+le-2,   conf.space_icon_pos.y+wi-2,    MAKE_COLOR(cl, cl));
}
コード例 #24
0
ファイル: render.c プロジェクト: arthurmaurer/42-RT
void	render(t_rt *rt)
{
	int			x;
	int			y;
	float		increment_x;
	float		increment_y;
	t_camera	*camera;
	t_ray		ray;
	t_hit		hit;

	if (rt->rendered)
	{
		mlx_update(rt->gfx);
		return ;
	}

	camera = rt->scene->active_camera;

	if (camera == NULL)
		die("No main camera set.");
	
	increment_x = camera->viewplane.width / camera->resolution_width;
	increment_y = camera->viewplane.height / camera->resolution_height;

	vec3_copy(&ray.origin, &camera->position);

	y = 0;
	while (y < rt->height)
	{
		x = 0;
		while (x < rt->width)
		{
			set_ray_direction(&ray, camera, increment_x * x, increment_y * y);
			raycast(&ray, &hit, 2, NULL);

			if (hit.object != NULL)
				draw_pixel(rt->gfx, x, y, vec3_to_color(&hit.color));
			else
				draw_pixel(rt->gfx, x, y, 0x333333);
			x++;
		}
		y++;
	}

	rt->rendered = 1;
	mlx_update(rt->gfx);
}
コード例 #25
0
void draw_vline(coord x, coord y, int len, color cl)
{
    if ((x < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return;
    if (y < 0) { len += y; y = 0; }
    if ((y + len) > camera_screen.height) len = camera_screen.height - y;
    for (; len>0; len--, y++)
        draw_pixel(x, y, cl);
}
コード例 #26
0
ファイル: interpolatevideo.C プロジェクト: knutj/cinelerra
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);
	}
}
コード例 #27
0
ファイル: irobot.c プロジェクト: kleopatra999/mess-svn
static void draw_line(running_machine &machine, UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col)
{
	irobot_state *state = machine.driver_data<irobot_state>();
    int dx,dy,sx,sy,cx,cy;

    dx = abs(x1-x2);
    dy = abs(y1-y2);
    sx = (x1 <= x2) ? 1: -1;
    sy = (y1 <= y2) ? 1: -1;
    cx = dx/2;
    cy = dy/2;

    if (dx>=dy)
    {
        for (;;)
        {
        	if (x1 >= state->m_ir_xmin && x1 < state->m_ir_xmax && y1 >= state->m_ir_ymin && y1 < state->m_ir_ymax)
	             draw_pixel (x1, y1, col);
             if (x1 == x2) break;
             x1 += sx;
             cx -= dy;
             if (cx < 0)
             {
                  y1 += sy;
                  cx += dx;
             }
        }
    }
    else
    {
        for (;;)
        {
        	if (x1 >= state->m_ir_xmin && x1 < state->m_ir_xmax && y1 >= state->m_ir_ymin && y1 < state->m_ir_ymax)
	            draw_pixel (x1, y1, col);
            if (y1 == y2) break;
            y1 += sy;
            cy -= dx;
            if (cy < 0)
            {
                 x1 += sx;
                 cy += dy;
            }
        }
    }
}
コード例 #28
0
ファイル: surface.hpp プロジェクト: nzinov/ray-tracer
 void draw() {
     log("Begin drawing");
     for (int x = 0; x < width; ++x) {
         for (int y = 0; y < height; ++y) {
             draw_pixel(x, y, buffer[x][y]);
         }
     }
     log("End drawing");
 }
コード例 #29
0
ファイル: console.c プロジェクト: vanvught/OpenILDA
/**
 *
 * @param c
 * @param x
 * @param y
 * @param fore
 * @param back
 */
inline static void draw_char(const int c, const int x, int y, const uint16_t fore, const uint16_t back) {
	int i, j;
	uint8_t line;
	unsigned char *p = FONT + (c * (int) CHAR_H);

	for (i = 0; i < CHAR_H; i++) {
		line = (uint8_t) *p++;
		for (j = x; j < (CHAR_W + x); j++) {
			if ((line & 0x1) != 0) {
				draw_pixel(j, y, fore);
			} else {
				draw_pixel(j, y, back);
			}
			line >>= 1;
		}
		y++;
	}
}
コード例 #30
0
void draw_background(Sprite *sprite, int offset, volatile unsigned char *fb) {
  int width = sprite->width;
  int height = sprite->height;
  for (int y = 0; y < height; ++y) {
    for (int x = 0; x < width; ++x) {
      draw_pixel(x + X_OFFSET, y + Y_OFFSET + offset, fb, *(sprite->bitmap + x + (y * width)));
    }
  }
}