Exemplo n.º 1
0
void trace_update_extents(DNATrace *t, int *x0p, int *xnp) {
    int ind, pos, x1, fw, cfw, new_x1;
    int min =  999999;
    int max = -999999;
    int x0 = *x0p, xn = *xnp;
    int new_x0, new_xn;
    
    if (t->Ned <= 0)
	return;

    if (x0 < 0) x0 = 0;
    if (x0 >= t->read->NPoints) x0 = t->read->NPoints-1;
    x1 = x0 + xn < t->read->NPoints ? x0+xn : t->read->NPoints - 1;
    x1 = t->tracePos[x1] + 1;
    if (x1 >= t->read->NBases) x1--;
    x1 = t->read->basePos[x1];
    ind = t->tracePosE[x0];       /* Index of first base on screen */

    fw = t->font_width/2 + 1;
    cfw = t->conf_font_width;

    while (ind < t->read->NBases && (pos = trace_get_pos(t, ind)) <= x1) {
	pos = point_to_pixel(t, pos) - fw;
	if (pos < min)
	    min = pos;
	if (pos + cfw > max)
	    max = pos + cfw;
	ind++;
    }

    new_x0 = (int)pixel_to_point(t, min-cfw/2-1);
    new_xn = (int)pixel_to_point(t, max+cfw/2+1) - new_x0;

    x1 = x0 + xn;
    new_x1 = new_x0 + new_xn;
    x0 = MIN(x0, new_x0);
    x1 = MAX(x1, new_x1);
    xn = x1 - x0;

    if (x0 < 0) {
	xn += x0;
	x0 = 0;
    }
    if (x0 + xn > t->read->NPoints)
	xn = t->read->NPoints - x0;

    *x0p = x0;
    *xnp = xn;
}
Exemplo n.º 2
0
int pixel_to_base(DNATrace *tracePtr, int pixel, int allow_end) {
    int cur, nearest, dist, t;
    int pos = pixel_to_point(tracePtr, pixel - tracePtr->borderWidth - 1);

    if (pos < 0)
	pos = 0;

    if (pos >= tracePtr->read->NPoints)
	pos = tracePtr->read->NPoints -1;

    nearest = tracePtr->tracePosE[pos];

    if (!allow_end) {
	while (nearest < tracePtr->Ned- 1) {
	    nearest++;
	    if (tracePtr->edPos[nearest])
		break;
	}
    } else {
	while (nearest < tracePtr->Ned) {
	    nearest++;
	    if (tracePtr->edPos[nearest])
		break;
	}
    }

    dist = trace_get_pos(tracePtr, nearest) - pos;
    if (dist < 0)
	dist = 9999;

    cur = nearest;
    do {
	cur--;

	if (cur >= 0) {
	    t = trace_get_pos(tracePtr, cur) - pos;

	    if (t <= 0)
		t = 9999;

	    if (t < dist) {
		dist = t;
		nearest = cur;
	    }
	}
    } while (cur >= 0 && t != 9999);

    return nearest;
}
Exemplo n.º 3
0
void mandelbrot_get_point(FRACTAL *fractal, int px, int py, double *zx, double *zy, double *cx, double *cy)
{
    *zx = 0.0;
    *zy = 0.0;
    pixel_to_point(fractal->window, px, py, cx, cy);
}