Esempio n. 1
0
static void
print_abort_error(const char *etype, const char *emsg)
{
  fprintf(stderr, _("%s%s%s: %s%s:%s\n %s\n"),
          color_get(COLOR_PROG), dpkg_get_progname(), color_reset(),
          color_get(COLOR_ERROR), etype, color_reset(), emsg);
}
Esempio n. 2
0
void
print_fatal_error(const char *emsg, const void *data)
{
  fprintf(stderr, "%s%s:%s %s%s:%s %s\n",
          color_get(COLOR_PROG), dpkg_get_progname(), color_reset(),
          color_get(COLOR_ERROR), _("error"), color_reset(), emsg);
}
Esempio n. 3
0
void	assign_x(t_env *env, t_2d_ray *ray, double *distx, t_2d_pnt cursor)
{
	*distx =
		sqrt(pow(cursor.x - ray->o.x, 2) + pow(cursor.y - ray->o.y, 2));
	ray->inter = cursor;
	ray->col = 1;
	env->dist = *distx;
	if (env->ev_color == 1)
		env->color =
			env->map.color[(int)(cursor.y / BLOCK)][(int)(cursor.x / BLOCK)];
	else if (ray->dir.x > 0)
		env->color = color_get(255, 165, 0, 0);
	else
		env->color = color_get(0, 255, 0, 0);
}
Esempio n. 4
0
t_env		*wolf3d_init(int ac, char **av)
{
	t_env *env;

	if (!(env = (t_env*)malloc(sizeof(t_env))))
		wolf3d_exit(&env, "wolf3d_init: malloc");
	env->color = color_get(255, 255, 255, 0);
	env->dist = 0;
	env->ac = ac;
	env->av = av;
	env->ray.dir.x = 0;
	env->ray.inter.x = 0;
	env->ev_draw_map = 0;
	env->ev_color = 0;
	env->i = 0;
	wolf3d_map_load(env);
	if (wolf3d_player_init(env) == 0)
		wolf3d_exit(&env, "Place a '#' in map to have a spawn !");
	if (((env)->mlx = mlx_init()) == NULL)
		wolf3d_exit(&env, "wolf3d_init: mlx_init");
	if ((env->win = mlx_new_window(env->mlx, WIDTH, HEIGHT, TITLE)) == NULL)
		wolf3d_exit(&env, "wolf3d_init: mlx_new_window");
	(env)->img = NULL;
	img_clear(env);
	init_texture(env);
	return (env);
}
Esempio n. 5
0
void	wolf3d_player_draw(t_env *env)
{
	int		i;
	int		j;

	j = 0;
	while (j < PLAYER_SIZE)
	{
		i = -1;
		while (++i < PLAYER_SIZE)
		{
			img_putline(env,
					(t_2d_pnt){env->player.pos.x + i, env->player.pos.y + j},
					(t_2d_pnt){env->player.pos.x + env->player.view_dir.x + i,
					env->player.pos.y + env->player.view_dir.y + j},
					color_convert(color_get(255, 0, 255, 0)));
			img_putpixel(env,
					env->player.pos.x + i,
					env->player.pos.y + j,
					0xffffff);
			img_putpixel(env,
					(env->player.pos.x + env->player.view_dir.x) + i,
					(env->player.pos.y + env->player.view_dir.y) + j,
					0xff00ff);
		}
		++j;
	}
}
Esempio n. 6
0
void
do_internerr(const char *file, int line, const char *func, const char *fmt, ...)
{
  va_list args;

  va_start(args, fmt);
  error_context_errmsg_format(fmt, args);
  va_end(args);

  fprintf(stderr, "%s%s:%s:%d:%s:%s %s%s:%s %s\n", color_get(COLOR_PROG),
          dpkg_get_progname(), file, line, func, color_reset(),
          color_get(COLOR_ERROR), _("internal error"), color_reset(),
          econtext->errmsg);

  abort();
}
Esempio n. 7
0
int color_get_global_bg(struct grc_s *grc)
{
    if (NULL == grc)
        return -1;

    return color_get(grc->color, COLOR_BG);
}
Esempio n. 8
0
/***
 * Font setup.
 */
static void parse_color ( Display *display, char *bg, Color *col )
{
    unsigned int val = 0;
    val        = color_get ( display, bg, "white" );
    col->alpha = ( ( val & 0xFF000000 ) >> 24 ) / 256.0;
    col->red   = ( ( val & 0x00FF0000 ) >> 16 ) / 256.0;
    col->green = ( ( val & 0x0000FF00 ) >> 8  ) / 256.0;
    col->blue  = ( ( val & 0x000000FF )       ) / 256.0;
}
Esempio n. 9
0
void	assign_y(t_env *env, t_2d_ray *ray, double *disty, t_2d_pnt cursor)
{
	*disty =
		sqrt(pow(cursor.x - ray->o.x, 2) + pow(cursor.y - ray->o.y, 2));
	if (ray->inter.x == -1 || (*disty <= env->dist))
	{
		ray->inter = cursor;
		ray->col = 2;
		if (env->ev_color == 1)
			env->color =
				env->map.color[(int)(cursor.y / BLOCK)]
								[(int)(cursor.x / BLOCK)];
		else if (ray->dir.y > 0)
			env->color = color_get(0, 0, 255, 0);
		else
			env->color = color_get(255, 255, 0, 0);
		env->dist = *disty;
	}
}
Esempio n. 10
0
static Property* rofi_theme_convert_get_color ( const char *color, const char *name )
{
    Color    c  = color_get ( color );
    Property *p = rofi_theme_property_create ( P_COLOR );
    p->name              = g_strdup ( name );
    p->value.color.alpha = c.alpha;
    p->value.color.red   = c.red;
    p->value.color.green = c.green;
    p->value.color.blue  = c.blue;

    return p;
}
Esempio n. 11
0
static void	exeption_x(t_env *env, t_2d_ray *ray)
{
	t_2d_pnt	cursor;

	cursor = ray->o;
	if (ray->dir.y > 0)
		cursor.y = (int)((int)(cursor.y / BLOCK) * BLOCK) + BLOCK;
	else
		cursor.y = (int)((int)(cursor.y / BLOCK) * BLOCK) - 0.00001;
	while (!wolf3d_map_is_wall(env, cursor))
		cursor.y += (ray->dir.y > 0) ? BLOCK : -BLOCK;
	env->dist =
		sqrt(pow(ray->o.x - cursor.x, 2) + pow(ray->o.y - cursor.y, 2));
	if (env->ev_color == 1)
		env->color =
			env->map.color[(int)(cursor.y / BLOCK)][(int)(cursor.x / BLOCK)];
	else if (ray->dir.y > 0)
		env->color = color_get(0, 0, 255, 0);
	else
		env->color = color_get(255, 255, 0, 0);
	ray->col = 2;
}
Esempio n. 12
0
File: draw.c Progetto: Krboo/fractol
int				draw(t_env env)
{
	int		color;
	int		pixel;
	int		x;
	int		y;

	y = 0;
	while (y < H)
	{
		x = 0;
		while (x < W)
		{
			pixel = ft_fractal(env, x, y);
			color = color_get(pixel, env);
			pixel_put(env, x, y, color);
			x++;
		}
		y++;
	}
	mlx_put_image_to_window(env.mlx, env.win, env.img.ptr, 0, 0);
	display(env);
	return (0);
}
Esempio n. 13
0
// Xft text box, optionally editable
textbox* textbox_create(Window parent, bitmap flags, short x, short y, short w, short h, char *font, char *fg, char *bg, char *text, char *prompt)
{
	textbox *tb = allocate_clear(sizeof(textbox));

	tb->flags = flags;
	tb->parent = parent;

	tb->x = x; tb->y = y; tb->w = MAX(1, w); tb->h = MAX(1, h);
	tb->window = XCreateSimpleWindow(display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, color_get(bg));

	// need to preload the font to calc line height
	textbox_font(tb, font, fg, bg);

	tb->prompt = strdup(prompt ? prompt: "");
	textbox_text(tb, text ? text: "");

	// auto height/width modes get handled here
	textbox_moveresize(tb, tb->x, tb->y, tb->w, tb->h);

	// edit mode controls
	if (tb->flags & TB_EDITABLE)
	{
		tb->xim = XOpenIM(display, NULL, NULL, NULL);
		tb->xic = XCreateIC(tb->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, tb->window, XNFocusWindow, tb->window, NULL);
	}

	return tb;
}
Esempio n. 14
0
int main ( int argc, char **argv )
{

    // Get DISPLAY
    const char *display_str = getenv ( "DISPLAY" );
    if ( !( display = XOpenDisplay ( display_str ) ) ) {
        fprintf ( stderr, "cannot open display!\n" );
        return EXIT_FAILURE;
    }

    TASSERT( display != NULL );
    Screen *screen = DefaultScreenOfDisplay ( display );
    Window root    = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
    Window mw = XCreateSimpleWindow ( display, root, 0, 0, 200, 100,
                                           config.menu_bw,
                                           color_get ( display, config.menu_bc ),
                                           color_get ( display, config.menu_bg ) );
    TASSERT( mw != None );

    textbox_setup ( config.menu_bg, config.menu_fg, 
                    config.menu_hlbg, config.menu_hlfg ); 
    textbox *box = textbox_create(mw , TB_EDITABLE|TB_AUTOWIDTH|TB_AUTOHEIGHT, 0,0, -1, -1, NORMAL, "test");
    TASSERT( box != NULL );

    textbox_cursor_end ( box );
    TASSERT ( box->cursor == 4); 
    textbox_cursor ( box, -1 );
    TASSERT ( box->cursor == 0 ); 
    textbox_cursor ( box, 8 );
    TASSERT ( box->cursor == 4 ); 
    textbox_cursor ( box, 2 );
    TASSERT ( box->cursor == 2 ); 
    textbox_insert ( box, 3, "bo");
    TASSERT ( strcmp(box->text, "tesbot") == 0 ); 
    textbox_cursor_end ( box );
    TASSERT ( box->cursor == 6); 

    TASSERT( textbox_get_width( box) > 0 );
    TASSERT( textbox_get_height( box) > 0 );

    TASSERT( textbox_get_width( box) >= textbox_get_font_width( box)  );
    TASSERT( textbox_get_height( box) >= textbox_get_font_height( box)  );

    TASSERT( textbox_get_estimated_char_width ( box) > 0 );

    textbox_cursor_bkspc ( box );
    TASSERT ( strcmp(box->text, "tesbo") == 0 ); 
    TASSERT ( box->cursor == 5); 

    textbox_cursor_dec ( box );
    TASSERT ( box->cursor == 4); 
    textbox_cursor_del ( box );
    TASSERT ( strcmp(box->text, "tesb") == 0 ); 
    textbox_cursor_dec ( box );
    TASSERT ( box->cursor == 3); 
    textbox_cursor_inc ( box );
    TASSERT ( box->cursor == 4); 
    textbox_cursor_inc ( box );
    TASSERT ( box->cursor == 4); 
    // Cursor after delete section.
    textbox_delete ( box, 0, 1 );
    TASSERT ( strcmp(box->text, "esb") == 0 ); 
    TASSERT ( box->cursor == 3); 
    // Cursor before delete.
    textbox_text( box, "aap noot mies");
    TASSERT ( strcmp(box->text, "aap noot mies") == 0 ); 
    textbox_cursor( box, 3 );
    TASSERT ( box->cursor == 3); 
    textbox_delete ( box, 3, 6 );
    TASSERT ( strcmp(box->text, "aapmies") == 0 ); 
    TASSERT ( box->cursor == 3); 

    // Cursor within delete
    textbox_text( box, "aap noot mies");
    TASSERT ( strcmp(box->text, "aap noot mies") == 0 ); 
    textbox_cursor( box, 5 );
    TASSERT ( box->cursor == 5); 
    textbox_delete ( box, 3, 6 );
    TASSERT ( strcmp(box->text, "aapmies") == 0 ); 
    TASSERT ( box->cursor == 3); 
    // Cursor after delete. 
    textbox_text( box, "aap noot mies");
    TASSERT ( strcmp(box->text, "aap noot mies") == 0 ); 
    textbox_cursor( box, 11 );
    TASSERT ( box->cursor == 11); 
    textbox_delete ( box, 3, 6 );
    TASSERT ( strcmp(box->text, "aapmies") == 0 ); 
    TASSERT ( box->cursor == 5); 


    textbox_font ( box, HIGHLIGHT );
    textbox_draw( box );

    textbox_show( box );
    textbox_move ( box, 12, 13);
    TASSERT ( box->x == 12 );
    TASSERT ( box->y == 13 );
    textbox_hide( box );

    textbox_free(box);
    textbox_cleanup();
    XDestroyWindow ( display, mw);
    XCloseDisplay ( display );
}