📄 voids.c
字号:
} } my_trace("finisned join_nbrs_on_top\n");}/***************************************************************************//* join_nbrs_below - refills erased voids based on the intersection of *//* slope trajectories measured from two neighboring character pieces *//* that touch the line from below. *//***************************************************************************/join_nbrs_below(lm, lrs, lre, rm, rrs, rre, fsy, tsy, ebin, sw, nsw, msw, cdata, w, h)float lm, rm;int lrs, lre, rrs, rre;int *fsy, *tsy, *ebin, *sw, nsw, msw;unsigned char *cdata;int w, h;{ int i, ix, iy, ty, by; int lx, rx, limit; my_trace("entered join_nbrs_below\n"); /* form the bounding box within which intersections will be accepted */ lx = min(lre+1, nsw-1); rx = max(0, rrs-1); my_trace2("void from %d to %d\n", lx, rx); ty = min(fsy[lx], fsy[rx]); by = max(tsy[lx], tsy[rx]); /* set a limit on the length of the void to avoid rediculous unerasures */ limit = max(sround(CURVE_VOID_FCTR*msw), MIN_CURVE_VOID); /* to be compatible: */ /* the left nbr slope must be negative and right nbr slope must be positive */ if(((lm == MAXFLOAT) || (lm <= 0)) && (rm >= 0) && /* to account for annomalies in the measured slopes: */ /* one side is not permitted to be "perfectly" vertical with the other */ /* side "perfectly" horizontal */ ((lm != MAXFLOAT) || (rm != 0.0)) && ((rm != MAXFLOAT) || (lm != 0.0)) && /* the length of the void must not exceed the limit */ ((rx - lx + 1) < limit) && /* an intersection between the two slopes must exist (ie. slopes not parallel) */ (pt_intersect(&ix, &iy, lx, tsy[lx], lm, rx, tsy[rx], rm))){ my_trace3("left line: pt = (%d, %d) slope = %f\n", lx, fsy[lx], lm); my_trace3("right line: pt = (%d, %d) slope = %f\n", rx, fsy[rx], rm); my_trace2("intersection at (%d, %d)\n", ix, iy); /* if intersection point is within the rectangular region of acceptance ... */ if((is_in_range(ix, lx, rx) && (is_in_range(iy, ty, by)))){ /* unerase the void */ my_trace("unerase void\n"); for(i = lx; i <= rx; i++){ if(sw[i] != 0) draw_slice_hori(1, i, fsy[i], tsy[i], cdata, w, h); ebin[i] = UNERASED; } } } my_trace("finished join_nbrs_below\n");}/***************************************************************************//* right_vert_clear - checks to see if right edge is vertically clear of *//* character data above and below. *//***************************************************************************/right_vert_clear(rs, re, fsy, tsy, msw, nsw, cdata, w, h)int rs, re, *fsy, *tsy, msw, nsw;unsigned char *cdata;int w, h;{ int x, sy, ey, slimit; slimit = step_limit(msw); x = re+1; if(x >= w) return(FALSE); sy = max(0, fsy[x] - slimit); ey = min(h-1, tsy[x] + slimit); if(sub_column_eq(0, x, sy, ey, cdata, w, h)) return(TRUE); else return(FALSE);}/***************************************************************************//* left_vert_clear - checks to see if left edge is vertically clear of *//* character data above and below. *//***************************************************************************/left_vert_clear(rs, re, fsy, tsy, msw, nsw, cdata, w, h)int rs, re, *fsy, *tsy, msw, nsw;unsigned char *cdata;int w, h;{ int x, sy, ey, slimit; slimit = step_limit(msw); x = rs-1; if(x < 0) return(FALSE); sy = max(0, fsy[x] - slimit); ey = min(h-1, tsy[x] + slimit); if(sub_column_eq(0, x, sy, ey, cdata, w, h)) return(TRUE); else return(FALSE);}/***************************************************************************//* top_left_hori_clear - checks to see if top-left edge of character piece *//* is horizontally clear of character data. *//***************************************************************************/top_left_hori_clear(rs, re, fsy, tsy, msw, nsw, cdata, w, h)int rs, re, *fsy, *tsy, msw, nsw;unsigned char *cdata;int w, h;{ int x, ex, y, slimit, rlen; rlen = re - rs + 1; slimit = min(rlen, step_limit(msw)); x = rs; y = fsy[x]-1; if(y < 0) return(FALSE); ex = min(x+slimit, w-1); if(sub_row_eq(0, x, ex, y, cdata, w, h)) return(TRUE); else return(FALSE);}/***************************************************************************//* bottom_left_hori_clear - checks to see if bottom-left edge of character *//* piece is horizontally clear of character data. *//***************************************************************************/bottom_left_hori_clear(rs, re, fsy, tsy, msw, nsw, cdata, w, h)int rs, re, *fsy, *tsy, msw, nsw;unsigned char *cdata;int w, h;{ int x, ex, y, slimit, rlen; rlen = re - rs + 1; slimit = min(rlen, step_limit(msw)); x = rs; y = tsy[x]+1; if(y >= h) return(FALSE); ex = min(x+slimit, w-1); if(sub_row_eq(0, x, ex, y, cdata, w, h)) return(TRUE); else return(FALSE);}/***************************************************************************//* bottom_right_hori_clear - checks to see if bottom-right edge of char *//* is horizontally clear of character data. *//***************************************************************************/bottom_right_hori_clear(rs, re, fsy, tsy, msw, nsw, cdata, w, h)int rs, re, *fsy, *tsy, msw, nsw;unsigned char *cdata;int w, h;{ int x, sx, y, slimit, rlen; rlen = re - rs + 1; slimit = min(rlen, step_limit(msw)); x = re; y = tsy[x]+1; if(y >= h) return(FALSE); sx = max(0, x-slimit); if(sub_row_eq(0, sx, x, y, cdata, w, h)) return(TRUE); else return(FALSE);}/***************************************************************************//* top_right_hori_clear - checks to see if top-right edge of character *//* piece is horizontally clear of character data. *//***************************************************************************/top_right_hori_clear(rs, re, fsy, tsy, msw, nsw, cdata, w, h)int rs, re, *fsy, *tsy, msw, nsw;unsigned char *cdata;int w, h;{ int x, sx, y, slimit, rlen; rlen = re - rs + 1; slimit = min(rlen, step_limit(msw)); x = re; y = fsy[x]-1; if(y < 0) return(FALSE); sx = max(0, x-slimit); if(sub_row_eq(0, sx, x, y, cdata, w, h)) return(TRUE); else return(FALSE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -