Пример #1
0
int print_one_chess(int x, int y)
{
	int c_x = x;
	int c_y = y;

	if((x < 100) || (x > (30*29+100)))
	{
		choose_color(x, y);
		return 1;	
	}
	if((y < 40) || (y > (30*23+40)))
	{
		choose_color(x, y);
		return 1;
	}

	x = (x-100)%30;
	y = (y-40)%30;

	c_x += ((x>15) ? (30-x) : -x);
	c_y += ((y>15) ? (30-y) : -y);

	fb_circle(c_x, c_y, 13, color_choice);

	return 0;
}
Пример #2
0
static void	draw_point_x(t_all *all)
{
	int		x;
	int		y;
	float	tmp_x1;
	float	tmp_x2;
	float	tmp_y1;

	y = -1;
	while (MAP[++y])
	{
		x = -1;
		tmp_x1 = ECART;
		while (MAP[y][++x] && MAP[y][x + 1])
		{
			tmp_x2 = tmp_x1 + ECART;
			tmp_y1 = y * ECART + ECART;
			all->apoint->x1 = (tmp_x1 - tmp_y1) + SW;
			all->apoint->x2 = (tmp_x2 - tmp_y1) + SW;
			all->apoint->y1 = ((tmp_x1 + tmp_y1) / 2 + SH) * COEFY - Z1;
			all->apoint->y2 = ((tmp_x2 + tmp_y1) / 2 + SH) * COEFY - Z2X;
			choose_color(all, Z1, Z2X);
			bres(all);
			tmp_x1 = tmp_x2;
		}
	}
}
Пример #3
0
static void	draw_point_y(t_all *all)
{
	int		x;
	int		y;
	float	tmp_x1;
	float	tmp_y1;
	float	tmp_y2;

	y = -1;
	tmp_y1 = ECART;
	while (MAP[++y] && MAP[y + 1])
	{
		x = -1;
		tmp_y2 = tmp_y1 + ECART;
		while (MAP[y][++x] && MAP[y + 1][x])
		{
			tmp_x1 = x * ECART + ECART;
			all->apoint->x1 = (tmp_x1 - tmp_y1) + SW;
			all->apoint->x2 = (tmp_x1 - tmp_y2) + SW;
			all->apoint->y1 = ((tmp_x1 + tmp_y1) / 2 + SH) * COEFY - Z1;
			all->apoint->y2 = ((tmp_x1 + tmp_y2) / 2 + SH) * COEFY - Z2Y;
			choose_color(all, Z1, Z2Y);
			bres(all);
		}
		tmp_y1 = tmp_y2;
	}
}
Пример #4
0
static void		brot_algo(t_env *env, int xx, int yy)
{
    while (((env->lim->z_r * env->lim->z_r) + (env->lim->z_i * env->lim->z_i))
            < 4 && (env->lim->i < env->lim->it_max))
    {
        env->lim->tmp = env->lim->z_r;
        env->lim->z_r = env->lim->z_r * env->lim->z_r
                        - env->lim->z_i * env->lim->z_i + env->lim->c_r;
        env->lim->z_i = 2 * env->lim->z_i * env->lim->tmp + env->lim->c_i;
        env->lim->i++;
    }
    if (env->lim->i == env->lim->it_max)
    {
        choose_color(env->color, (env->lim->i * 10 / env->lim->it_max), 0, 0);
        img_put_pixel(env, xx, yy, color_in_int(env->color));
    }
    else
    {
        choose_color(env->color, 0, (env->lim->i * 255 * env->lim->it_max),
                     (env->lim->i * 255 * env->lim->it_max));
        img_put_pixel(env, xx, yy, color_in_int(env->color));
    }
}
Пример #5
0
int		key_hook(int keycode, t_env *e)
{
	if (keycode == 99)
		choose_color(e);
	if (keycode == 32)
	{
		e->mouse_x = 0;
		e->mouse_y = 0;
		e->zoom = 1;
		expose_hook(e);
	}
	if (keycode == 65307)
		exit (0);
	if (keycode == 102)
		e->move = (e->move + 1) % 2;
	return (0);
}
Пример #6
0
void	draw_line(t_point *a, t_point *b, t_tool *tools)
{
	int		color;
	t_math	*m;

	m = malloc(sizeof(*m));
	color = choose_color(tools, a, b);
	m->x = a->x;
	m->y = a->y;
	m->dx = b->x - a->x;
	m->dy = b->y - a->y;
	m->xinc = (m->dx > 0) ? 1 : -1;
	m->yinc = (m->dy > 0) ? 1 : -1;
	m->dx = abs(m->dx);
	m->dy = abs(m->dy);
	mlx_pixel_put(tools->mlx_ptr, tools->mlx_win, m->x, m->y, color);
	if (m->dx > m->dy)
		horizontal_case(m, tools, color);
	else
		vertical_case(m, tools, color);
}
Пример #7
0
void makecube(int u, int d, int f, int b, int r, int l){
 
  glBegin(GL_QUADS);
  choose_color(u);
  glVertex3f(-T, T,-T);
  glVertex3f( T, T,-T);
  glVertex3f( T, T, T);
  glVertex3f(-T, T, T);
  
  choose_color(d);
  glVertex3f(-T,-T,-T);
  glVertex3f( T,-T,-T);
  glVertex3f( T,-T, T);
  glVertex3f(-T,-T, T);
    
  choose_color(f);
  glVertex3f(-T,-T, T);
  glVertex3f( T,-T, T);
  glVertex3f( T, T, T);
  glVertex3f(-T, T, T);
  
  choose_color(b);
  glVertex3f(-T,-T,-T);
  glVertex3f( T,-T,-T);
  glVertex3f( T, T,-T);
  glVertex3f(-T, T,-T);
  
  choose_color(r);
  glVertex3f( T,-T,-T);
  glVertex3f( T, T,-T);
  glVertex3f( T, T, T);
  glVertex3f( T,-T, T);
  
  choose_color(l);
  glVertex3f(-T,-T,-T);
  glVertex3f(-T, T,-T);
  glVertex3f(-T, T, T);
  glVertex3f(-T,-T, T);
  
  glEnd();

}
Пример #8
0
int
handle_main_ray(struct application *ap, register struct partition *PartHeadp,
		struct seg *segp)
{
    register struct partition *pp;
    register struct hit *hitp; /* which hit */

    struct application a2;
    struct cell me;
    struct cell below;
    struct cell left;

    struct cell above;
    struct cell right;

    double intensity = 1.0;

    int edge = 0;
    int cpu;
    int oc = 1;

    RGBpixel col;

    RT_APPLICATION_INIT(&a2);
    memset(&me, 0, sizeof(struct cell));
    memset(&below, 0, sizeof(struct cell));
    memset(&left, 0, sizeof(struct cell));

    cpu = ap->a_resource->re_cpu;

    if (PartHeadp == NULL || segp == NULL) {
	/* The main shotline missed.  pack the application struct
	 */
	me.c_ishit    = 0;
	me.c_dist   = MISS_DIST;
	me.c_id	    = MISS_ID;
	me.c_region = 0;
	VSETALL(me.c_hit, MISS_DIST);
	VSETALL(me.c_normal, 0);
	VMOVE(me.c_rdir, ap->a_ray.r_dir);
    } else {
	pp = PartHeadp->pt_forw;
	hitp = pp->pt_inhit;
	/*
	 * Stuff the information for this cell.
	 */
	me.c_ishit    = 1;
	me.c_id = pp->pt_regionp->reg_regionid;
	me.c_dist = hitp->hit_dist;
	me.c_region = pp->pt_regionp;
	VMOVE(me.c_rdir, ap->a_ray.r_dir);
	VJOIN1(me.c_hit, ap->a_ray.r_pt, hitp->hit_dist, ap->a_ray.r_dir);
	RT_HIT_NORMAL(me.c_normal, hitp,
		      pp->pt_inseg->seg_stp, &(ap->a_ray), pp->pt_inflip);
    }

    /*
     * Now, fire a ray for both the cell below and if necessary, the
     * cell to the left.
     */
    a2.a_hit = rayhit2;
    a2.a_miss = raymiss2;
    a2.a_onehit = 1;
    a2.a_rt_i = ap->a_rt_i;
    a2.a_resource = ap->a_resource;
    a2.a_logoverlap = ap->a_logoverlap;

    VSUB2(a2.a_ray.r_pt, ap->a_ray.r_pt, dy_model); /* below */
    VMOVE(a2.a_ray.r_dir, ap->a_ray.r_dir);
    a2.a_uptr = (void *)&below;
    rt_shootray(&a2);

    if (ap->a_x == 0) {
	/*
	 * For the first pixel in a scanline, we have to shoot to the
	 * left.  For each pixel afterword, we save the current cell
	 * info to be used as the left side cell info for the
	 * following pixel
	 */
	VSUB2(a2.a_ray.r_pt, ap->a_ray.r_pt, dx_model); /* left */
	VMOVE(a2.a_ray.r_dir, ap->a_ray.r_dir);
	a2.a_uptr = (void *)&left;
	rt_shootray(&a2);
    } else {
	left.c_ishit = saved[cpu]->c_ishit;
	left.c_id = saved[cpu]->c_id;
	left.c_dist = saved[cpu]->c_dist;
	left.c_region = saved[cpu]->c_region;
	VMOVE(left.c_rdir, saved[cpu]->c_rdir);
	VMOVE(left.c_hit, saved[cpu]->c_hit);
	VMOVE(left.c_normal, saved[cpu]->c_normal);
    }

    if (both_sides) {
	VADD2(a2.a_ray.r_pt, ap->a_ray.r_pt, dy_model); /* above */
	VMOVE(a2.a_ray.r_dir, ap->a_ray.r_dir);
	a2.a_uptr = (void *)&above;
	rt_shootray(&a2);

	VADD2(a2.a_ray.r_pt, ap->a_ray.r_pt, dx_model); /* right */
	VMOVE(a2.a_ray.r_dir, ap->a_ray.r_dir);
	a2.a_uptr = (void *)&right;
	rt_shootray(&a2);
    }


    /*
     * Is this pixel an edge?
     */
    if (both_sides) {
	edge = is_edge(&intensity, ap, &me, &left, &below, &right, &above);
    } else {
	edge = is_edge(&intensity, ap, &me, &left, &below, NULL, NULL);
    }

    /*
     * Does this pixel occlude the second geometry?  Note that we must
     * check on edges as well since right side and top edges are
     * actually misses.
     */
    if (occlusion_mode != OCCLUSION_MODE_NONE)
	if (me.c_ishit || edge)
	    oc = occludes(ap, &me);

    /*
     * Perverse Pixel Painting Paradigm(tm) If a pixel should be
     * written to the fb, writeable is set.
     */
    if (occlusion_mode == OCCLUSION_MODE_EDGES)
	writeable[cpu][ap->a_x] = (edge && oc);
    else if (occlusion_mode == OCCLUSION_MODE_HITS)
	writeable[cpu][ap->a_x] = ((me.c_ishit || edge) && oc);
    else if (occlusion_mode == OCCLUSION_MODE_DITHER) {
	if (edge && oc)
	    writeable[cpu][ap->a_x] = 1;
	else if (me.c_ishit && oc) {
	    /*
	     * Dither mode.
	     *
	     * For occluding non-edges, only write every other pixel.
	     */
	    if (oc == 1 && ((ap->a_x + ap->a_y) % 2) == 0)
		writeable[cpu][ap->a_x] = 1;
	    else if (oc == 2)
		writeable[cpu][ap->a_x] = 1;
	    else
		writeable[cpu][ap->a_x] = 0;
	} else {
	    writeable[cpu][ap->a_x] = 0;
	}
    } else {
	if (edge)
	    writeable[cpu][ap->a_x] = 1;
	else
	    writeable[cpu][ap->a_x] = 0;
    }

    if (edge) {
	if (both_sides) {
	    choose_color(col, intensity, &me, &left, &below, &right, &above);
	} else {
	    choose_color(col, intensity, &me, &left, &below, NULL, NULL);
	}

	scanline[cpu][ap->a_x*3+RED] = col[RED];
	scanline[cpu][ap->a_x*3+GRN] = col[GRN];
	scanline[cpu][ap->a_x*3+BLU] = col[BLU];
    } else {
	scanline[cpu][ap->a_x*3+RED] = bgcolor[RED];
	scanline[cpu][ap->a_x*3+GRN] = bgcolor[GRN];
	scanline[cpu][ap->a_x*3+BLU] = bgcolor[BLU];
    }

    /*
     * Save the cell info for the next pixel.
     */
    saved[cpu]->c_ishit = me.c_ishit;
    saved[cpu]->c_id = me.c_id;
    saved[cpu]->c_dist = me.c_dist;
    saved[cpu]->c_region = me.c_region;
    VMOVE(saved[cpu]->c_rdir, me.c_rdir);
    VMOVE(saved[cpu]->c_hit, me.c_hit);
    VMOVE(saved[cpu]->c_normal, me.c_normal);

    return edge;
}
Пример #9
0
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
	LOGFONT lf={0,};
	CHOOSEFONT cf={sizeof(cf),hwnd,0,&lf,0,
		CF_EFFECTS|CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT,
		0,};
	CHARFORMAT fmt={sizeof(fmt),};
	CHOOSECOLOR cs;

    switch (id)
	{
		case IDM_ABOUT:
			MessageBox(hwnd,"Sex v0.1\n"
				            "Copyright (C) 1998, Nullsoft Inc.","About sex",MB_OK);
		return;
		case IDM_PASTE:
            SendMessage(hwnd_rich, WM_PASTE, 0, 0);
		return;
		case IDM_COPY:
            SendMessage(hwnd_rich, WM_COPY, 0, 0);
        return;
		case IDM_CUT:
            SendMessage(hwnd_rich, WM_CUT, 0, 0);
        return;
		case IDM_CLOSE:
			SendMessage(hwnd,WM_CLOSE,0,0);
		return;
		case IDM_QUIT:
			DestroyWindow(hwnd);
		return;
		case IDM_FONT:
			{
				get_font (&lf, &fmt, &cf);
				
				if (ChooseFont(&cf))
				{
                    set_font (&lf, &fmt, &cf, FALSE, FALSE, FALSE, FALSE, FALSE);
				}
			}
		return;
		case IDM_BGCOLOR:
			{
				if (choose_color(&cs, hwnd))
				{
					config_color=cs.rgbResult;
					config_write();
					SendMessage(hwnd_rich,EM_SETBKGNDCOLOR,FALSE,config_color);
				}
			}
		return;
        case IDM_FGCOLOR:
            {
				get_font (&lf, &fmt, &cf);

				if (choose_color(&cs, hwnd))
				{
                    set_font (&lf, &fmt, &cf, FALSE, FALSE, FALSE, TRUE, cs.rgbResult);
                }
            }
		return;
        case IDM_UNDERLINE:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, FALSE, FALSE, TRUE, FALSE, 0);
            }
		return;
        case IDM_ITALIC:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, FALSE, TRUE, FALSE, FALSE, 0);
            }
		return;
        case IDM_BOLD:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, TRUE, FALSE, FALSE, FALSE, 0);
            }
		return;
        case IDM_WORDWRAP:
            {
                if (word_wrap)
                {
                    ModifyStyle(hwnd_rich, 0 ,WS_HSCROLL|ES_AUTOHSCROLL,  0 );
                    word_wrap = 0;
                }
                else
                {
                    ModifyStyle(hwnd_rich, WS_HSCROLL|ES_AUTOHSCROLL, 0 , 0 );
                    word_wrap = 1;
                }
            }
		return;
        case IDM_REDL:
            {
                if (config_icon != 1)
                {
					choose_icon(1);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLUEL:
            {
                if (config_icon != 2)
                {
					choose_icon(2);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLACKL:
            {
                if (config_icon != 3)
                {
					choose_icon(3);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLUER:
            {
                if (config_icon != 4)
                {
					choose_icon(4);
					change_icon(hwnd);
                }
            }
		return;
    }
}