Correct polygon's direction for overriding.
authorKoichi KAMICHI <kamichi@fonts.jp>
Fri, 13 Feb 2004 02:20:50 +0000 (02:20 +0000)
committerKoichi KAMICHI <kamichi@fonts.jp>
Fri, 13 Feb 2004 02:20:50 +0000 (02:20 +0000)
kagecgi/kagecd.c

index 2b820f2..61087eb 100755 (executable)
@@ -10,7 +10,6 @@ void cdDrawCurve(int x1, int y1,
        double rad, t;\r
        double x, y, v;\r
        double ix, iy, ia, ib, ir;\r
-       int ox1, oy1, ox2, oy2;\r
        int count, tt;\r
        int delta;\r
        double deltad;\r
@@ -97,7 +96,7 @@ void cdDrawCurve(int x1, int y1,
                \r
                //line SUICHOKU by vector\r
                if(ix != 0 && iy != 0){\r
-                       ir = atan(iy / ix * -1.0);\r
+                       ir = atan(iy / ix * -1);\r
                        ia = sin(ir) * (double)(kMinWidthT);\r
                        ib = cos(ir) * (double)(kMinWidthT);\r
                }\r
@@ -120,26 +119,17 @@ void cdDrawCurve(int x1, int y1,
                ia = ia * deltad;\r
                ib = ib * deltad;\r
                \r
-               //swap if two lines are crossing\r
-               if(((x + ia) - ox1) * ((x + ia) - ox1) +\r
-                       ((y + ib) - oy1) * ((y + ib) - oy1) >\r
-                       ((x - ia) - ox1) * ((x - ia) - ox1) +\r
-                       ((y - ib) - oy1) * ((y - ib) - oy1) && count != 0){\r
-                       ia = ia * -1;\r
-                       ib = ib * -1;\r
+               //reverse if vector is going 2nd/3rd quadrants\r
+               if(ix <= 0){\r
+                 ia = ia * -1;\r
+                 ib = ib * -1;\r
                }\r
                \r
-               //copy as an old point\r
-               ox1 = x + ia;\r
-               oy1 = y + ib;\r
-               ox2 = x - ia;\r
-               oy2 = y - ib;\r
-               \r
                //copy to polygon structuer\r
-               poly[count].X = x + ia;\r
-               poly[count].Y = y + ib;\r
-               poly[(1000 / kRate + 1) * 2 - 1 - count].X = x - ia;\r
-               poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y - ib;\r
+               poly[count].X = x - ia;\r
+               poly[count].Y = y - ib;\r
+               poly[(1000 / kRate + 1) * 2 - 1 - count].X = x + ia;\r
+               poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y + ib;\r
                count += 1;\r
        }\r
        \r
@@ -553,27 +543,18 @@ void cdDrawCurve(int x1, int y1,
                                        ib = kWidth;\r
                                }\r
                        }\r
-                       \r
-                       //if it is crossing, swap each other\r
-                       if(((x + ia) - ox1) * ((x + ia) - ox1) +\r
-                               ((y + ib) - oy1) * ((y + ib) - oy1) >\r
-                               ((x - ia) - ox1) * ((x - ia) - ox1) +\r
-                               ((y - ib) - oy1) * ((y - ib) - oy1) && count != 0){\r
-                               ia = ia * -1;\r
-                               ib = ib * -1;\r
+\r
+                       //reverse if vector is going 2nd/3rd quadrants\r
+                       if(ix <= 0){\r
+                         ia = ia * -1;\r
+                         ib = ib * -1;\r
                        }\r
-                       \r
-                       //save old points for calculate crossing\r
-                       ox1 = x + ia;\r
-                       oy1 = y + ib;\r
-                       ox2 = x - ia;\r
-                       oy2 = y - ib;\r
-                       \r
+               \r
                        //save to polygon\r
-                       poly[count].X = x + ia;\r
-                       poly[count].Y = y + ib;\r
-                       poly[(1000 / kRate + 1) * 2 - 1 - count].X = x - ia;\r
-                       poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y - ib;\r
+                       poly[count].X = x - ia;\r
+                       poly[count].Y = y - ib;\r
+                       poly[(1000 / kRate + 1) * 2 - 1 - count].X = x + ia;\r
+                       poly[(1000 / kRate + 1) * 2 - 1 - count].Y = y + ib;\r
                        count += 1;\r
                }\r
                \r
@@ -992,14 +973,14 @@ void cdDrawLine(int tx1, int ty1, int tx2, int ty2, int ta1, int ta2){
                        if(a1 % 10 == 3){ y1 = y1 - kWidth * kKakato; }\r
                        if(a2 % 10 == 3){ y2 = y2 + kWidth * kKakato; }\r
                        \r
-                       poly[0].X = x1 - kWidth;\r
-                       poly[0].Y = y1;\r
-                       poly[1].X = x2 - kWidth;\r
-                       poly[1].Y = y2;\r
-                       poly[2].X = x2 + kWidth;\r
-                       poly[2].Y = y2;\r
-                       poly[3].X = x1 + kWidth;\r
+                       poly[3].X = x1 - kWidth;\r
                        poly[3].Y = y1;\r
+                       poly[2].X = x2 - kWidth;\r
+                       poly[2].Y = y2;\r
+                       poly[1].X = x2 + kWidth;\r
+                       poly[1].Y = y2;\r
+                       poly[0].X = x1 + kWidth;\r
+                       poly[0].Y = y1;\r
                        \r
                        icPolygon(poly, 4);\r
                }\r