-/* this function clear or draw a line on the screen USED BY TOOLLINEUPDATE */
-void ToolLine(GtkWidget *widget, int x1, int y1, int x2, int y2, int draw) {
- int udx, udy, dx, dy, error, loop, xadd, yadd;
-
- dx = x2 - x1; /* x delta */
- dy = y2 - y1; /* y delta */
-
- udx = abs(dx); /* unsigned x delta */
- udy = abs(dy); /* unsigned y delta */
-
- if (dx < 0) { xadd = -1; } else { xadd = 1; } /* set directions */
- if (dy < 0) { yadd = -1; } else { yadd = 1; }
-
- error = 0;
- loop = 0;
- if (udx > udy) { /* delta X > delta Y */
- do {
- error += udy;
-
- if (error >= udx) { /* is time to move up or down? */
- error -= udx;
- y1 += yadd;
- }
- loop++;
- if (draw == 1) {
- SetPoint(widget,x1,y1,0);
- } else {
- /* now clearing line before drawing new one, we must check */
- /* if there is a point in oldBitmap which saves bitmap before */
- /* we starting drawing new line */
- if (!GSM_IsPointBitmap(&oldBitmap,x1,y1)) {
- ClearPoint(widget,x1,y1,0);
- }
- }
- x1 += xadd; /* move horizontally */
- } while (loop < udx); /* repeat for x length */
- } else {
- do {
- error += udx;
- if (error >= udy) { /* is time to move left or right? */
- error -= udy;
- x1 += xadd;
- }
- loop++;
- if (draw == 1) {
- SetPoint(widget,x1,y1,0);
- } else {
- /* check comment in delta X > delta Y */
- if (!GSM_IsPointBitmap(&oldBitmap,x1,y1)) {
- ClearPoint(widget,x1,y1,0);
- }
- }
- y1 += yadd; /* move vertically */
- } while (loop < udy); /* repeat for y length */
- }
-}
+ x = (double)x1;
+ for (i = y1;i <= y2;i++) {
+ if (!GSM_IsPointBitmap(&oldBitmap,(int)x,i)) ClearPoint(widget,(int)x,i,0);
+ x += delta;
+ }
+ }
+
+ if (abs(toolStartX-column) >= abs(toolStartY-row)) {
+ if (toolStartX > column) {
+ x1 = column;
+ x2 = toolStartX;
+ y1 = row;
+ y2 = toolStartY;
+ } else {
+ x1 = toolStartX;
+ x2 = column;
+ y1 = toolStartY;
+ y2 = row;
+ }