예제 #1
0
int			mlx_putline(t_mlxdata *data, t_ipoint a, t_ipoint b)
{
	int x;

	if (a.x > WIDTH || b.x > WIDTH || a.y > HEIGHT || b.y > HEIGHT
		|| a.x < 0 || b.x < 0 || a.y < 0 || b.y < 0)
		return (0);
	b.color = a.color;
	if (ft_abs(b.y - a.y) > ft_abs(b.x - a.x))
	{
		if (a.y > b.y)
			swap_points(&a, &b);
		swap_xy(&a);
		swap_xy(&b);
		x = a.x;
		while (x <= b.x)
		{
			mlx_putpxl_img(data->img,
						(int)(a.y + ((b.y - a.y) * (x - a.x)) / (b.x - a.x)),
						(int)x, a.color);
			x++;
		}
	}
	else
		mlx_putlinetwo(data, a, b);
	return (1);
}
예제 #2
0
WG_PRIVATE wg_status
fix_pane_veticles(Cd_pane *pane_dimention)
{
    Wg_point2d *screen[PANE_VERTICLES_NUM];
    wg_int     l = 0;
    Cd_pane pd;

    screen[V0] = &pane_dimention->v1;
    screen[V1] = &pane_dimention->v2;
    screen[V2] = &pane_dimention->v3;
    screen[V3] = &pane_dimention->v4;

    sort_pane_verticles(screen, PANE_VERTICLES_NUM, 
            pane_dimention->orientation);

    l = abs(screen[V0]->x - screen[V1]->x);
    if (l > PANE_VERT_MARGIN_IN_PIX){
        return WG_FAILURE;
    }

    l = abs(screen[V2]->x - screen[V3]->x);
    if (l > PANE_VERT_MARGIN_IN_PIX){
        return WG_FAILURE;
    }

    if (screen[V0]->y > screen[V1]->y){
       swap_points(&screen[V0], &screen[V1]);
    }

    if (screen[V2]->y > screen[V3]->y){
       swap_points(&screen[V2], &screen[V3]);
    }
   
    pd.v4 = *screen[V1];
    pd.v1 = *screen[V0];
    pd.v3 = *screen[V3];
    pd.v2 = *screen[V2];
    pd.orientation = pane_dimention->orientation;

    *pane_dimention = pd;

    return WG_SUCCESS;
}
예제 #3
0
int			mlx_putlinetwo(t_mlxdata *data, t_ipoint a, t_ipoint b)
{
	int x;

	if (a.x > b.x)
		swap_points(&a, &b);
	x = a.x;
	while (x <= b.x)
	{
		mlx_putpxl_img(data->img, (int)x,
						(int)(a.y + ((b.y - a.y) * (x - a.x)) / (b.x - a.x)),
						a.color);
		x++;
	}
	return (1);
}
예제 #4
0
static void LADDER3PT(const f2elm_t xP, const f2elm_t xQ, const f2elm_t xPQ, const digit_t* m, const unsigned int AliceOrBob, point_proj_t R, const f2elm_t A)
{
    point_proj_t R0 = {0}, R2 = {0};
    f2elm_t A24 = {0};
    digit_t mask;
    int i, nbits, bit, swap, prevbit = 0;

    if (AliceOrBob == ALICE) {
        nbits = OALICE_BITS;
    } else {
        nbits = OBOB_BITS;
    }

    // Initializing constant
    fpcopy((digit_t*)&Montgomery_one, A24[0]);
    fp2add(A24, A24, A24);
    fp2add(A, A24, A24);
    fp2div2(A24, A24);  
    fp2div2(A24, A24); // A24 = (A+2)/4

    // Initializing points
    fp2copy(xQ, R0->X);
    fpcopy((digit_t*)&Montgomery_one, (digit_t*)R0->Z);
    fp2copy(xPQ, R2->X);
    fpcopy((digit_t*)&Montgomery_one, (digit_t*)R2->Z);
    fp2copy(xP, R->X);
    fpcopy((digit_t*)&Montgomery_one, (digit_t*)R->Z);
    fpzero((digit_t*)(R->Z)[1]);

    // Main loop
    for (i = 0; i < nbits; i++) {
        bit = (m[i >> LOG2RADIX] >> (i & (RADIX-1))) & 1;
        swap = bit ^ prevbit;
        prevbit = bit;
        mask = 0 - (digit_t)swap;

        swap_points(R, R2, mask);
        xDBLADD(R0, R2, R->X, A24);
        fp2mul_mont(R2->X, R->Z, R2->X);
    }
}