Example #1
0
int			ft_draw(t_mlx *mlx)
{
	int	x;
	int	y;
	int color;

	y = 0;
	while (y < WIN_H)
	{
		x = 0;
		while (x < WIN_W)
		{
			if (mlx->f->nb == 1)
				color = ft_color(ft_julia(mlx, x, y), mlx);
			else if (mlx->f->nb == 2)
				color = ft_color(ft_mandelbrot(mlx, x, y), mlx);
			else if (mlx->f->nb == 3)
				color = ft_color(ft_tricorn(mlx, x, y), mlx);
			put_pixel(mlx->f, x, y, color);
			x++;
		}
		y++;
	}
	mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->f->img, 0, 0);
	return (0);
}
Example #2
0
static void	ft_sub2bres(t_bre *bre, t_env *e, int z1, int z2)
{
	int i;
	int j;
	int inc1;
	int inc2;

	mlx_pixel_put(e->mlx, e->win, bre->x, bre->y, ft_color(z1, e));
	j = 2 * bre->difx - bre->dify;
	inc1 = 2 * (bre->difx - bre->dify);
	inc2 = 2 * bre->difx;
	i = 0;
	while (i++ < bre->dify)
	{
		if (j >= 0)
		{
			bre->x += bre->incx;
			j += inc1;
		}
		else
			j += inc2;
		bre->y += bre->incy;
		if (i <= bre->dify / 2)
			mlx_pixel_put(e->mlx, e->win, bre->x, bre->y, ft_color(z1, e));
		if (i > bre->dify / 2)
			mlx_pixel_put(e->mlx, e->win, bre->x, bre->y, ft_color(z2, e));
	}
}
Example #3
0
void	ft_trace_c(unsigned int i, char c)
{
	ft_color("32");
	ft_putstr("trace char n°");
	ft_putnbr(i);
	ft_putstr(" = (");
	ft_putchar(c);
	ft_putstr(").\n");
	ft_color("37");
}
Example #4
0
void	ft_trace_i(unsigned int i, int nb)
{
	ft_color("34");
	ft_putstr("trace int n°");
	ft_putnbr(i);
	ft_putstr(" = ");
	ft_putnbr(nb);
	ft_putstr(".\n");
	ft_color("37");
}
Example #5
0
static void	aff(int i, t_glob *g, char *s)
{
	if (ft_strlen(s) == 1)
	{
		mlx_string_put(g->e->mlx, g->e->win, g->e->x_0 + 6, g->e->y_0 + 15,
					ft_color(g, i), "0");
		mlx_string_put(g->e->mlx, g->e->win, g->e->x_0 + 16, g->e->y_0 + 15,
					ft_color(g, i), s);
	}
	else
		mlx_string_put(g->e->mlx, g->e->win, g->e->x_0 + 6, g->e->y_0 + 15,
					ft_color(g, i), s);
}
Example #6
0
void	draw(void *mlx, void *win, t_rgb *rgb, t_env *env)
{
	double			x;
	double			y;
	double			x_temp;
	unsigned int	max_iteration;
	unsigned int	iteration;
	unsigned int	xz;
	unsigned int	yz;
	int				color;

	x = 0.0;
	y = 0.0;
	x_temp = 0.0;
	iteration = 0;
	max_iteration = 1000;
	while (x * x + y * y < 2 * 2  && iteration < max_iteration)
	{
		x_temp = x * x - y * y + xz;
		y = 2 * x * y + yz;
		x = x_temp;
		iteration = iteration + 1;
		color = ft_color(x);
		put_pixel_image(env, x, y, color);
	}
}
Example #7
0
void	ft_printf_loop(t_var *var, char *str, va_list *ap)
{
	while (str[var->i] != '\0')
	{
		if (str[var->i] == '%')
		{
			str = is_precision_flag(&str[var->i], ap, var);
			var->i = 0;
			var->negativ = 0;
			var->s_precision = 0;
			var->s_precp = 0;
		}
		else if (str[var->i] == '{')
		{
			str = ft_color(&str[var->i]);
			var->i = 0;
		}
		else if (str[var->i] == '#')
		{
			str = ft_multiple_base(&str[var->i], ap);
			var->i = 0;
		}
		else
			ft_putchar_printf(str[var->i]);
		var->i++;
	}
}
Example #8
0
void	draw(t_env *env, int **tab)
{
    int color;
    int l;
    int c;

    l = 0;
    while (l < env->nblignes)
    {
        c = 0;
        while (c < env->nbcases[l])
        {
            color = ft_color(tab[l][c]);
            if (c < env->nbcases[l] - 1)
                draw_line(env, coord(c * env->ecart_w, l * env->ecart_w,
                                     tab[l][c] * env->ecart_h), coord((c + 1) * env->ecart_w,
                                             l * env->ecart_w, tab[l][c + 1] * env->ecart_h), color);
            if (l > 0 && c < env->nbcases[l - 1])
                draw_line(env, coord(c * env->ecart_w, l * env->ecart_w,
                                     tab[l][c] * env->ecart_h), coord(c * env->ecart_w,
                                             (l - 1) * env->ecart_w, tab[l - 1][c] * env->ecart_h), color);
            c++;
        }
        l++;
    }
}
Example #9
0
int				ft_printf(const char *format, ...)
{
	va_list		pa;
	int			i;
	int			r_val;

	i = -1;
	r_val = 0;
	va_start(pa, format);
	if (format == NULL)
		return (-1);
	while (format[++i])
	{
		(format[i] == '{') ? ft_color(format, &i) : 0;
		if (!format[i] || (format[i] == '%' && ft_undef(format, i + 1) == 0))
			return (r_val);
		format[i] == '%' && format[i + 1] == '\0' ? r_val-- : 0;
		format[i] == '%' ? 0 : ft_putchar(format[i]);
		if (format[i] == '%' && format[i + 1] && ft_undef(format, i + 1)
			&& (i = ft_printf_conv((char *)format, &pa, &r_val, i + 1)) == -1)
			return (-1);
		r_val++;
	}
	va_end(pa);
	return (r_val);
}
Example #10
0
File: color.c Project: rmicolon/fdf
double			ft_zit(double *z, double varz, double pts, t_fdf *fdf)
{
	int		col;

	*z = *z + (varz / pts);
	if (fdf->cswitch == 0)
		col = ft_color_2(round(*z), fdf);
	else
		col = ft_color(round(*z));
	return (col);
}
Example #11
0
void	ft_gateau(int dx, int dy, t_mlx_env *mlx_e)
{
	int	e;

	e = dx;
	dx = e * 2;
	dy = dy * 2;
	while (mlx_e->xy[2] < mlx_e->xy[3])
	{
		mlx_pixel_put(mlx_e->mlx, mlx_e->win,
					mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
		if ((e = e - dy) < 0)
		{
			mlx_e->xy[4]++;
			e = e + dx;
		}
		mlx_e->xy[2]++;
	}
	mlx_pixel_put(mlx_e->mlx, mlx_e->win,
				mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
}
Example #12
0
void	ft_gateau_lie(int dx, int dy, t_mlx_env *mlx_e)
{
	int	e;

	e = dy;
	dy = e * 2;
	dx = dx * 2;
	while (mlx_e->xy[4] > mlx_e->xy[5])
	{
		mlx_pixel_put(mlx_e->mlx, mlx_e->win,
					mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
		if ((e = e + dx) > 0)
		{
			mlx_e->xy[2]++;
			e = e + dy;
		}
		mlx_e->xy[4]--;
	}
	mlx_pixel_put(mlx_e->mlx, mlx_e->win,
					mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
}
Example #13
0
void	ft_gateau_lieb(int dy, int dx, t_mlx_env *mlx_e)
{
	int	e;

	e = dx;
	dx = e * 2;
	dy = dy * 2;
	while (mlx_e->xy[2] > mlx_e->xy[3])
	{
		mlx_pixel_put(mlx_e->mlx, mlx_e->win,
					mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
		if ((e = e + dy) > 0)
		{
			mlx_e->xy[4]++;
			e = e + dx;
		}
		mlx_e->xy[2]--;
	}
	mlx_pixel_put(mlx_e->mlx, mlx_e->win,
				mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
}
Example #14
0
void send_selected(t_list *lc)
{
	t_list *tmp;

	tmp = lc;
	while (tmp != NULL)
	{
		if (tmp->indice & SELECTED)
			ft_color(tmp->name, " ", "", 1);
		tmp = tmp->next;
	}
}
Example #15
0
void	ft_gateaub(int dy, int dx, t_mlx_env *mlx_e)
{
	int	e;

	e = dy;
	dy = e * 2;
	dx = dx * 2;
	while (mlx_e->xy[4] < mlx_e->xy[5])
	{
		mlx_pixel_put(mlx_e->mlx, mlx_e->win,
					mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
		if ((e = e - dx) < 0)
		{
			mlx_e->xy[2]++;
			e = e + dy;
		}
		mlx_e->xy[4]++;
	}
	mlx_pixel_put(mlx_e->mlx, mlx_e->win,
				mlx_e->xy[4], mlx_e->xy[2], ft_color(mlx_e));
}
Example #16
0
/**************************************************************************
  Make a text tag for the selected text.
**************************************************************************/
void inputline_make_tag(GtkEntry *entry, enum text_tag_type type)
{
  char buf[MAX_LEN_MSG];
  GtkEditable *editable = GTK_EDITABLE(entry);
  gint start_pos, end_pos;
  gchar *selection;

  if (!gtk_editable_get_selection_bounds(editable, &start_pos, &end_pos)) {
    /* Let's say the selection starts and ends at the current position. */
    start_pos = end_pos = gtk_editable_get_position(editable);
  }

  selection = gtk_editable_get_chars(editable, start_pos, end_pos);

  if (type == TTT_COLOR) {
    /* Get the color arguments. */
    char fg_color_text[32], bg_color_text[32];
    GdkColor *fg_color = g_object_get_data(G_OBJECT(entry), "fg_color");
    GdkColor *bg_color = g_object_get_data(G_OBJECT(entry), "bg_color");

    if (!fg_color && !bg_color) {
      goto CLEAN_UP;
    }

    color_to_string(fg_color, fg_color_text, sizeof(fg_color_text));
    color_to_string(bg_color, bg_color_text, sizeof(bg_color_text));

    if (0 == featured_text_apply_tag(selection, buf, sizeof(buf),
                                     TTT_COLOR, 0, FT_OFFSET_UNSET,
                                     ft_color(fg_color_text,
                                              bg_color_text))) {
      goto CLEAN_UP;
    }
  } else if (0 == featured_text_apply_tag(selection, buf, sizeof(buf),
                                          type, 0, FT_OFFSET_UNSET)) {
    goto CLEAN_UP;
  }

  /* Replace the selection. */
  gtk_editable_delete_text(editable, start_pos, end_pos);
  end_pos = start_pos;
  gtk_editable_insert_text(editable, buf, -1, &end_pos);
  gtk_editable_select_region(editable, start_pos, end_pos);

CLEAN_UP:
  g_free(selection);
}
Example #17
0
/****************************************************************************
  Return selected colors (for highlighting chat).
****************************************************************************/
struct ft_color option_dialog::get_color(struct option *poption) {

  QPalette pal;
  QColor col1, col2;
  QWidget *w;
  QPushButton* but;

  w = reinterpret_cast<QPushButton *>(option_get_gui_data(poption));
  but = w->findChild<QPushButton *>("text_color");
  pal = but->palette();
  col1 =  pal.color(QPalette::Button);
  but = w->findChild<QPushButton *>("text_background");
  pal = but->palette();
  col2 =  pal.color(QPalette::Button);

  return ft_color(col1.name().toUtf8().data(), col2.name().toUtf8().data());
}
Example #18
0
void			ft_draw_pt2d(t_env *env)
{
	int		i;

	i = 0;
	while (env->pt2d[i].x != 0)
	{
		ft_pixel_put_img(env, (env->pt2d[i].x + env->xvar),
			(env->pt2d[i].y + env->yvar), ft_color(env->pt2d[i]));
		if (i > 0 && env->pt2d[i].line == env->pt2d[i - 1].line)
			ft_draw(env->pt2d[i - 1], env->pt2d[i], env);
		if (env->pt2d[i].stay_high != NULL)
			ft_draw(env->pt2d[i], env->pt2d[i].stay_high[0], env);
		i++;
	}
	mlx_put_image_to_window(env->mlx, env->win, env->img.img_ptr, 0, 0);
	return ;
}
Example #19
0
static int		ft_add_color(char *fmt, int i, t_printf *conv)
{
	int		a;

	a = i;
	while (fmt[a] != '}' && fmt[a] != '%' && fmt[a] != '\0')
		a++;
	if (fmt[a] == '}')
		return (ft_color(fmt, i, a - i + 1, conv));
	else
	{
		conv->arg = ft_new_arg(conv->arg);
		conv->arg->value = ft_strsub(fmt, i, a - i);
		conv->arg->size = a - i;
		conv->return_value += a - i;
		return (a);
	}
}
Example #20
0
void		ft_gen_fract(double (*fct)(t_env *, int, int), t_env *e)
{
	int		i;
	int		j;
	int		color;
	double	d;

	i = -1;
	while (++i <= e->height)
	{
		j = -1;
		while (++j <= e->width)
		{
			d = fct(e, i, j);
			color = ft_color(d, e);
			ft_put_pixel_to_image(e, j, i, color);
		}
	}
}
Example #21
0
/* ************************************************************************** */
/*                                                          LE - /            */
/*                                                              /             */
/*   ft_getparams.c                                   .::    .:/ .      .::   */
/*                                                 +:+:+   +:    +:  +:+:+    */
/*   By: jjanin-r <*****@*****.**>                +:+   +:    +:    +:+     */
/*                                                 #+#   #+    #+    #+#      */
/*   Created: 2017/12/14 15:21:15 by jjanin-r     #+#   ##    ##    #+#       */
/*   Updated: 2018/01/29 22:20:35 by jjanin-r    ###    #+. /#+    ###.fr     */
/*                                                         /                  */
/*                                                        /                   */
/* ************************************************************************** */

#include "libftprintf.h"

int		ft_getparams(const char *restrict format, t_param **begin, va_list ap)
{
	char	*str;
	int		clen;

	str = ft_strdup(format);
	clen = ft_colorlen(str);
	str = ft_color(str);
	if ((ft_strchr(str, '%')) == NULL)
		ft_nomod(begin, &str, ft_strlen(str), str);
	else
		ft_mod(begin, &str, ap, 0);
	ft_strdel(&str);
	return (clen);
}