Project

General

Profile

clipping_regions_1.txt

Sergey Ivanovskiy, 12/04/2015 12:18 PM

Download (3.73 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js'
2
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js	2015-11-26 08:08:46 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js	2015-12-04 17:10:15 +0000
4
@@ -275,7 +275,8 @@
5
 };
6
 
7
 /**
8
- * Adjust the origin for pixel drawing on the canvas.
9
+ * Adjusts the origin for pixel drawing on the canvas and transforms the stacked clipping regions
10
+ * by the given x and y factors in order to be consistent with the new coordinates origin.
11
  *
12
  * @param    {Number} x
13
  *           The translate along X-axis.
14
@@ -286,6 +287,21 @@
15
 {
16
    this.origin.x += x;
17
    this.origin.y += y;
18
+   
19
+   var last = 0;
20
+   while (last < this.state.length)
21
+   {
22
+      var s = this.state[last];
23
+      
24
+      if (s.clip != undefined)
25
+      {
26
+         s.clip.x -= x;
27
+         s.clip.y -= y;
28
+         //this.logger.log(last + " clipping regions translated by (" + x + ", " + y + ") = "
29
+         //                                                             + JSON.stringify(s.clip));
30
+      }
31
+      last = last + 1;
32
+   }
33
 };
34
 
35
 /**
36
@@ -349,9 +365,9 @@
37
  *           X coordinate of the left corner of the input region.
38
  * @param    {Number} ya
39
  *           Y coordinate of the top corner of the input region.
40
- * @param    {Number} x2
41
+ * @param    {Number} xb
42
  *           X coordinate of the right corner of the input region.
43
- * @param    {Number} y2
44
+ * @param    {Number} yb
45
  *           Y coordinate of the bottom corner of the input region.
46
  * 
47
  * @return   {left: xa, top: ya, right: xb, bottom: yb}
48
@@ -1150,7 +1166,6 @@
49
 {
50
    // find the previous clipping rectangle
51
    var prevClip = this.lastClippedRegion(false);
52
-   
53
    if (prevClip != undefined)
54
    {
55
       var prevR =
56
@@ -1240,26 +1255,10 @@
57
          prevClip.x += this.origin.x;
58
          prevClip.y += this.origin.y;
59
       }
60
-      else
61
-      {
62
-         // apply the translations to the previous clip, to make it relative to current origin
63
-         while (last < this.state.length)
64
-         {
65
-            var s = this.state[last];
66
-            
67
-            if (s.translate != undefined)
68
-            {
69
-               prevClip.x -= s.translate.x;
70
-               prevClip.y -= s.translate.y;
71
-            }
72
-            
73
-            last = last + 1;
74
-         }
75
-       }
76
-    }
77
-    
78
-    return prevClip;
79
-}
80
+   }
81
+   //this.logger.log("lastClippedRegion(" + toScreen + ") = " + JSON.stringify(prevClip));
82
+   return prevClip;
83
+};
84
 
85
 /**
86
  * Calculates the intersection of the given line segment with the last clipping region.
87
@@ -1306,7 +1305,7 @@
88
       ya = y2;
89
       yb = y1;
90
    }
91
-   
92
+   // {left : xa, top : ya, right : xb, bottom : yb}
93
    var clipped = this.clipRegion(xa, ya, xb, yb);
94
    if (clipped == null)
95
    {
96
@@ -1364,6 +1363,7 @@
97
          if (additional.hasOwnProperty(prop))
98
          {
99
             cur[prop] = additional[prop];
100
+            //this.logger.log("[" + prop + "] = " + JSON.stringify(additional[prop]));
101
          }
102
       }
103
    }
104

    
105
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
106
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-12-01 22:44:33 +0000
107
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-12-04 16:54:27 +0000
108
@@ -1081,7 +1081,7 @@
109
                   offset += 4;
110
                   yPoints[j] = p2j.socket.readInt32BinaryMessage(message, offset);
111
                }
112
-               
113
+//               extra = " xPoints: " + JSON.stringify(xPoints) + " yPoints: " + JSON.stringify(yPoints);
114
                this.canvasRenderer.strokePolygon(this.ctx, xPoints, yPoints, numPoints,
115
                      this.canvasRenderer.rawColor, true);
116
                break;
117