Example #1
0
void		sierpinski(int posx, int posy, t_param *param)
{
	int	x;
	int	y;
	int	i;

	x = -1;
	while (++x < WIDTH)
	{
		y = -1;
		while (++y < HEIGHT)
		{
			Z_I = abs(x - posx);
			Z_R = abs(y - posy);
			i = -1;
			while (((int)Z_I % 3 != 1 || (int)Z_R % 3 != 1) && ++i < ITER)
				fract_calc(param);
			if (i != ITER)
				img_put_pixel(param, x, y, mlx_get_color_value(MLX, 0));
			else
				img_put_pixel(param, x, y, mlx_get_color_value(MLX, 0 |
							i * PAL[COLOR]));
		}
	}
}
Example #2
0
void	mlx_ppti(void *mlx_ptr, t_img *img, t_point *pixel)
{
  unsigned int	i;
  unsigned int	color;
  char		*get;
  int		k;
  int		endian;

  k = 1;
  i = (img->sizeline) * (pixel->y);
  i = i + (img->bpp / 8) * (pixel->x);
  color = mlx_get_color_value(mlx_ptr, pixel->color);
  get = &color;
  if (img->endian == 0)
    endian = 1;
  else
    {
      k = (img->bpp) - 1;
      endian = -1;
    }
  while (k < (img->bpp / 8) && k >= 0)
    {
      (img->data)[i] = get[k - endian];
      k = k + endian;
      i++;
    }
}
Example #3
0
void mlx_image_put_pixel(t_id *s, int x, int y)
{	
	s->color = mlx_get_color_value (s->mlx, 0xFFFFFF);

	if (x > 0 && x <= W_X && y > 0 && y <= W_Y)
		*(unsigned int *)(s->data + ((int)s->bpp * x) + (s->s_line * y)) = s->color;
}
Example #4
0
unsigned int	calc(t_env *raytracer, int x, int y)
{
  int		i;
  unsigned int	color;
  t_list	*object;
  t_list	*inter;

  color = 0;
  inter = NULL;
  calc_vecteur_cam(&raytracer->camera, x, y);
  i = -1;
  while (++i < MAX)
    {
      object = raytracer->objects[i];
      while (object != NULL)
	{
	  (*(functions[i].inter_func))(&inter, object->data, raytracer->camera);
	  object = object->next;
	}
    }
  if (inter != NULL)
    color = ((t_intersection*)(inter->data))->color;
  free_list(&inter);
  return (mlx_get_color_value(raytracer->mlx_ptr, color));
}
Example #5
0
void	pixel_put(t_env *e, int x, int y, int color)
{
	unsigned int	new_color;

	new_color = mlx_get_color_value(e->mlx, color);
	e->data[y * e->sl + x * e->bpp / 8] = (new_color & 0xff);
	e->data[y * e->sl + x * e->bpp / 8 + 1] = (new_color & 0xff00) >> 8;
	e->data[y * e->sl + x * e->bpp / 8 + 2] = (new_color & 0xff0000) >> 16;
}
Example #6
0
void	fill(t_img *img, int x, int y, int color)
{
	void			*ptr;
	unsigned int	*pxl;
	unsigned int	col;

	col = mlx_get_color_value(img->mlx, color);
	ptr = img->data + y * img->lnsize + (img->bpp / 8) * x;
	pxl = ptr;
	*pxl = col;
}
Example #7
0
void	put_pixel_to_image(t_img *ptr, int x, int y, int color)
{
  int	i;

  if (ptr->endian == 0)
    {
      i = (ptr->sizeline * y) + (x * (ptr->bpp / 8));
      ptr->data[i] = mlx_get_color_value(ptr->mlx_ptr, color);
      ptr->data[i + 1] = mlx_get_color_value(ptr->mlx_ptr, color >> 8);
      ptr->data[i + 2] = mlx_get_color_value(ptr->mlx_ptr, color >> 16);
    }
Example #8
0
void	mlx_put_pixel_to_image(int x, int y, int color)
{
	unsigned int	new_color;
	int				i;
	t_win			*win;

	win = init_env();
	new_color = mlx_get_color_value(win->mlx, color);
	i = x * 4 + y * win->img->size_line;
	win->img->data[i] = (new_color & 0xFF);
	win->img->data[i + 1] = (new_color & 0xFF00) >> 8;
	win->img->data[i + 2] = (new_color & 0xFF0000) >> 16;
}
Example #9
0
File: image.c Project: ebaudet/RTV1
void		eb_put_pixel_to_img(t_img *img, int x, int y, int color)
{
	t_win			*env;
	unsigned int	mgcv;
	int				i;

	env = env_init();
	mgcv = mlx_get_color_value(env->mlx, color);
	i = x * 4 + y * img->size_line;
	img->data[i] = (mgcv & 0xFF);
	img->data[i + 1] = (mgcv & 0xFF00) >> 8;
	img->data[i + 2] = (mgcv & 0xFF0000) >> 16;
}
Example #10
0
void				ft_draw_background(t_data e)
{
	int				i;
	unsigned int	c;

	i = 0;
	c = mlx_get_color_value(e.ptr, CIEL);
	while (i <= (WIN_Y / 2) * e.sizeline)
	{
		e.data[i] = (c & 0xFF);
		e.data[i + 1] = (c & 0xFF00) >> 8;
		e.data[i + 2] = (c & 0xFF0000) >> 16;
		i = i + 4;
	}
	c = mlx_get_color_value(e.ptr, SOL);
	while (i <= WIN_Y *e.sizeline)
	{
		e.data[i] = (c &0xFF);
		e.data[i + 1] = (c & 0xFF00) >> 8;
		e.data[i + 2] = (c & 0xFF0000) >> 16;
		i = i + 4;
	}
}
Example #11
0
// Pixel put to img
int		mlx_ppti(t_image *t_img, int x, int y, int color)
{
  int		i;
  char		*ptr;
  unsigned int  color1;

  color1 = mlx_get_color_value(IMG->ptr_ini, color);
  ptr = (char *) &color1;
  i = (y * IMG->sizeline) + (x * (IMG->bpp / 8));
  IMG->data[i] = ptr[0];
  IMG->data[i + 1] = ptr[1];
  IMG->data[i + 2] = ptr[2];
  IMG->data[i + 3] = ptr[3];
  return (0);
}
Example #12
0
File: draw.c Project: gabkk/Project
void		my_pixel_timage(LG modx, LG mody, UI color, t_env *e)
{
	if (modx < e->width - 400 && mody < e->height && modx >= 0 && mody >= 0)
	{
		if (e->dat->bpp == 0 || e->dat->sizel == 0)
			return ;
		modx = modx * e->dat->bpp;
		mody = mody * e->dat->sizel;
		color = mlx_get_color_value(e->mlx, color);
		e->dat->addr[mody + modx] = color;
		e->dat->addr[mody + modx + 1] = color >> 8;
		e->dat->addr[mody + modx + 2] = color >> 16;
		e->dat->addr[mody + modx + 3] = 0;
	}
}
Example #13
0
t_color				read_color(t_env *e, char *str)
{
	t_color			col;
	int				color;
	unsigned int	coloru;

	color = 0;
	str += 2;
	color = htoi(str, 0);
	coloru = mlx_get_color_value(e->mlx, color);
	col.r = (unsigned char)(coloru);
	col.g = (unsigned char)(coloru >> 8);
	col.b = (unsigned char)(coloru >> 16);
	return (col);
}
Example #14
0
void	ft_mlx_window_pixel_put(t_window *win, int x, int y, int c)
{
	uint32_t	color;
	uint32_t	a;
	uint32_t	b;

	if (x < 0 || y < 0)
		return ;
	a = (uint32_t)x;
	b = (uint32_t)y;
	if (a < win->width && b < win->height)
	{
		color = mlx_get_color_value(win->mlx, c);
		mlx_pixel_put(win->mlx, win->win, a, b, color);
	}
}
Example #15
0
int		mlx_pixel_img(t_env *e, int x, int y, int color)
{
	int				i;
	unsigned int	color2;

	color2 = mlx_get_color_value(e->mlx, color);
	i = (y * e->sizeline) + (x * (e->bpp / 8));
	e->data[i] = (color2 & 0xFF);
	i++;
	if (e->bpp >= 16)
		e->data[i] = ((color2 & 0xFF00) >> 8);
	i++;
	if (e->bpp >= 32)
		e->data[i] = ((color2 & 0xFF0000) >> 16);
	return (0);
}
Example #16
0
int	color_map_2(unsigned char *data,int bpp,int sl,int w,int h,int endian, int type)
{
  int	x;
  int	y;
  int	opp;
  int	dec;
  int	color;
  int	color2;
  unsigned char *ptr;

  opp = bpp/8;
  printf("(opp : %d) ",opp);
  y = h;
  while (y--)
    {
      ptr = data+y*sl;
      x = w;
      while (x--)
        {
	  if (type==2)
	    color = (y*255)/w+((((w-x)*255)/w)<<16)
	      +(((y*255)/h)<<8);
	  else
	    color = (x*255)/w+((((w-x)*255)/w)<<16)+(((y*255)/h)<<8);
          color2 = mlx_get_color_value(mlx,color);
	  dec = opp;
	  while (dec--)
	    if (endian==local_endian)
	      {
		if (endian)
		  *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[4-opp+dec];
		else
		  *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[dec];
	      }
	    else
	      {
		if (endian)
		  *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[opp-1-dec];
		else
		  *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[3-dec];
	      }
        }
    }

}
Example #17
0
/*
** brief: this function will create our minimap
** @pr: the struct used to define the move, each ptr like the img etc...
*/
void		my_fill_minimap(t_ptr *pr)
{
  int		i;
  int		j;
  unsigned int	color;
  unsigned char	*minimap;

  color = mlx_get_color_value(pr->mlx, 0x000000);
  minimap = (unsigned char *)&color;
  j = -1;
  while (++j < HEIGHT_MINI)
    {
      i = -1;
      while (++i < WIDTH_MINI)
	my_put_pixel_to_mini(pr->mini_p, i, j, minimap);
    }
  _my_find_maze(pr);
  _my_find_player(pr);
}
Example #18
0
void	d_m(t_img *img)
{
	img->c = (t_cmplx){img->plan.x_a, img->plan.y_a};
	img->z = (t_cmplx){0, 0};
	img->j = 0;
	while (img->j < img->nb_i && (img->z.i * img->z.i + img->z.r * img->z.r)
			< 4)
	{
		img->tmp = img->z.r;
		img->z.r = img->z.r * img->z.r - img->z.i * img->z.i + img->c.r;
		img->z.i = 2 * img->tmp * img->z.i + img->c.i;
		++img->j;
	}
	if (img->j == img->nb_i)
		img->color = mlx_get_color_value(img->mlx_ptr, BLACK);
	else
		get_color(img);
	draw_pixel(img, img->x, img->y);
}
Example #19
0
static void	mlx_image_put_pixel(void *mlx, t_img *i, t_coordint p, t_rgb *c)
{
	if (i->e)
	{
		i->d[p.y * i->s + p.x * i->bp / 8] = mlx_get_color_value(mlx, c->r);
		i->d[p.y * i->s + p.x * i->bp / 8 + 1] = mlx_get_color_value(mlx, c->g);
		i->d[p.y * i->s + p.x * i->bp / 8 + 2] = mlx_get_color_value(mlx, c->b);
	}
	else
	{
		i->d[p.y * i->s + i->bp / 8 * p.x] = mlx_get_color_value(mlx, c->b);
		i->d[p.y * i->s + i->bp / 8 * p.x + 1] = mlx_get_color_value(mlx, c->g);
		i->d[p.y * i->s + i->bp / 8 * p.x + 2] = mlx_get_color_value(mlx, c->r);
	}
}
Example #20
0
/*
** brief it will color the "range" for our player
** @size: the player's length
** @x: the player's x_position
** @y: the player's y_position
** @pr: the struct used to define the move, each ptr like the img etc...
*/
static void	_my_fill_player(int size, int x, int y, t_ptr *pr)
{
  int		i;
  int		j;
  unsigned int	tmp;
  unsigned char	*color;

  tmp = mlx_get_color_value(pr->mlx, 0xFF0000);
  color = (unsigned char *)&tmp;
  j = (y * size);
  while (j < (y * size) + size)
    {
      i = (x * size);
      while (i < (x * size) + size)
	{
	  my_put_pixel_to_mini(pr->mini_p, i, j, color);
	  ++i;
	}
      ++j;
    }
}
Example #21
0
File: draw.c Project: Rirax/wolf3d
void	get_color(t_env *e, int y)
{
	if (y < e->drstart)
		e->color = mlx_get_color_value(e->mlx, 0xE1E6FA);
	else if (y >= e->drstart && y < e->drend)
	{
		if (e->side == 0)
			e->color = mlx_get_color_value(e->mlx, 0xE70739);
		else if (e->side == 1)
			e->color = mlx_get_color_value(e->mlx, 0x5EB6DD);
		else if (e->side == 2)
			e->color = mlx_get_color_value(e->mlx, 0xFFF168);
		else if (e->side == 3)
			e->color = mlx_get_color_value(e->mlx, 0x8FCF3C);
	}
	else if (y >= e->drend && y < WIN_HEIGHT)
		e->color = mlx_get_color_value(e->mlx, 0x795344);
}
Example #22
0
int		expose_hook(t_d *d)
{
	int		x = 0;
	int		y = 0;
	int		pos;

	printf("Enter in expose\n");
	if ((d->img = mlx_new_image(d->mlx, 500, 500)) == NULL)
		exitProg("Fail to init a new image in minilibx.\n");	
	d->strimg = mlx_get_data_addr(d->img, &(d->bpp), &(d->size_line), &(d->endian));
	d->color = mlx_get_color_value(d->mlx, 0xFFFAFA);
	while (x < 250)
	{
		put_pixel_in_img(d, x, y);
		x++;
		if (x == 250 && y < 250)
		{
			x = 0;
			y++;
		}
		/* == CA MARCHE
		   y = 0;
		   while (y < 250)
		   {
		   pos = y * d->size_line + 4 * x;
		   d->strimg[pos] = 255;
		   y++;

		   }
		   x++;*/
	}
	mlx_put_image_to_window(d->mlx, d->win, d->img, 0, 0);
	//mlx_destroy_image(d->mlx, d->img);
	printf("End of expose\n");
	return (0);
}
Example #23
0
void            pix_it(t_screen *screen, t_2d pix, t_color color, int f)
{
    color = filtre(color, f);
    save(screen->screensave, (int)pix.x, (int)pix.y,
         mlx_get_color_value(screen->mlx_ptr, color.i));
}
Example #24
0
void	*mlx_int_parse_xpm(t_xvar *xvar,void *info,int info_size,char *(*f)())
{
  int	pos;
  char	*line;
  char	**tab;
  char	*data;
  char	*clip_data;
  int	nc;
  int	opp;
  int	cpp;
  int	col;
  int	rgb_col;
  int	col_name;
  int	method;
  int	x;
  int	i;
  int	j;
  t_img	*img;
  t_xpm_col	*colors;
  int		*colors_direct;
  int	width;
  int	height;
  XImage	*clip_img;
  XGCValues	xgcv;
  Pixmap	clip_pix;

  colors = 0;
  colors_direct = 0;
  img = 0;
  tab = 0;
  pos = 0;
  if (!(line = f(info,&pos,info_size)) ||
      !(tab = mlx_int_str_to_wordtab(line)) || !(width = atoi(tab[0])) ||
      !(height = atoi(tab[1])) || !(nc = atoi(tab[2])) ||
      !(cpp = atoi(tab[3])) )
    RETURN;
  free(tab);
  tab = 0;

  method = 0;
  if (cpp<=2)
    {
      method = 1;
      if (!(colors_direct = malloc((cpp==2?65536:256)*sizeof(int))))
	RETURN;
    }
  else
    if (!(colors = malloc(nc*sizeof(*colors))))
      RETURN;

  clip_data = 0;

  i = nc;
  while (i--)
    {
      if (!(line = f(info,&pos,info_size)) ||
	  !(tab = mlx_int_str_to_wordtab(line+cpp)) )
	RETURN;
      j = 0;
      while (tab[j] && strcmp(tab[j++],"c"));

      if (!tab[j])
	RETURN;
      
      if ((rgb_col = mlx_int_get_text_rgb(tab[j], tab[j+1]))==-1)
	{
	  if (!(clip_data = malloc(4*width*height)) ||   /* ok, nice size .. */
	      !(clip_img = XCreateImage(xvar->display, xvar->visual,
					1, XYPixmap, 0, clip_data,
					width, height, 8, (width+7)/8)) )
	    RETURN;
	  memset(clip_data, 0xFF, 4*width*height);
	}

      if (method)
	colors_direct[mlx_int_get_col_name(line,cpp)] =
	  rgb_col>=0?mlx_get_color_value(xvar, rgb_col):rgb_col;
      else
	{
	  colors[i].name = mlx_int_get_col_name(line,cpp);
	  colors[i].col = rgb_col>=0?mlx_get_color_value(xvar,rgb_col):rgb_col;
	}
      free(tab);
    }

  if (!(img = mlx_new_image(xvar,width,height)))
    RETURN;
  opp = img->bpp/8;


  i = height;
  data = img->data;
  while (i--)
    {
      if (!(line = f(info,&pos,info_size)))
	RETURN;
      x = 0;
      while (x<width)
	{
	  col = 0;
	  col_name = mlx_int_get_col_name(line+cpp*x,cpp);
	  if (method)
	    col = colors_direct[col_name];
	  else
	    {
	      j = nc;
	      while (j--)
		if (colors[j].name==col_name)
		  {
		    col = colors[j].col;
		    j = 0;
		  }
	    }
	  if (col==-1)
	    XPutPixel(clip_img, x, height-1-i, 0);
	  else
	    mlx_int_xpm_set_pixel(img, data, opp, col, x);
	  x ++;
	}
      data += img->size_line;
    }
  if (clip_data)
    {
      if (!(clip_pix = XCreatePixmap(xvar->display, xvar->root,
					   width, height, 1)) )
	RETURN;
      img->gc = XCreateGC(xvar->display, clip_pix, 0, &xgcv);
      XPutImage(xvar->display, clip_pix, img->gc, clip_img,
		0, 0, 0, 0, width, height);
      XFreeGC(xvar->display, img->gc);
      xgcv.clip_mask = clip_pix;
      xgcv.function = GXcopy;
      xgcv.plane_mask = AllPlanes;
      img->gc = XCreateGC(xvar->display, xvar->root, GCClipMask|GCFunction|
			  GCPlaneMask, &xgcv);
      XSync(xvar->display, False);
      XDestroyImage(clip_img);
    }
  if (colors)
    free(colors);
  if (colors_direct)
    free(colors_direct);
  return (img);
}