89 /* |
89 /* |
90 * Fonction de déclaration des courbes. |
90 * Fonction de déclaration des courbes. |
91 */ |
91 */ |
92 searchCanvas.prototype.onPointerIn = function(mainPointerX, mainPointerY, secondPointerX, secondPointerY) |
92 searchCanvas.prototype.onPointerIn = function(mainPointerX, mainPointerY, secondPointerX, secondPointerY) |
93 { |
93 { |
|
94 if(this.mosaic.currentMode != 'MOSAIC' && this.mosaic.currentMode != 'FILTER') |
|
95 { |
|
96 mainPointerX -= 130; |
|
97 mainPointerY -= 60; |
|
98 } |
|
99 |
94 //On obtient les coordonnées du pointeur principal en px. |
100 //On obtient les coordonnées du pointeur principal en px. |
95 mainPointerX = Math.floor(mainPointerX); |
101 mainPointerX = Math.floor(mainPointerX); |
96 mainPointerY = Math.floor(mainPointerY); |
102 mainPointerY = Math.floor(mainPointerY); |
97 |
103 |
98 //On forme le contour la courbe principale. |
104 //On forme le contour la courbe principale. |
107 this.mainPath.strokeColor = '#02FEFF'; |
113 this.mainPath.strokeColor = '#02FEFF'; |
108 this.mainPath.strokeWidth = 10; |
114 this.mainPath.strokeWidth = 10; |
109 this.mainPath.strokeCap = 'round'; |
115 this.mainPath.strokeCap = 'round'; |
110 this.mainPath.strokeJoin = 'round'; |
116 this.mainPath.strokeJoin = 'round'; |
111 |
117 |
112 this.direction = new paper.Path(); |
118 /*this.direction = new paper.Path(); |
113 this.direction.strokeColor = '#FF0000'; |
119 this.direction.strokeColor = '#FF0000'; |
114 this.direction.strokeWidth = 5; |
120 this.direction.strokeWidth = 5; |
115 this.direction.strokeCap = 'round'; |
121 this.direction.strokeCap = 'round'; |
116 this.direction.strokeJoin = 'round'; |
122 this.direction.strokeJoin = 'round';*/ |
117 |
123 |
118 //Si on a un pointeur secondaire |
124 //Si on a un pointeur secondaire |
119 if(secondPointerX && secondPointerY) |
125 if(secondPointerX && secondPointerY) |
120 { |
126 { |
121 //On obtient les coordonnées du pointeur secondaire en px. |
127 //On obtient les coordonnées du pointeur secondaire en px. |
148 */ |
154 */ |
149 searchCanvas.prototype.onPointerMove = function(mainPointerX, mainPointerY, secondPointerX, secondPointerY) |
155 searchCanvas.prototype.onPointerMove = function(mainPointerX, mainPointerY, secondPointerX, secondPointerY) |
150 { |
156 { |
151 // console.log('MOVE'); |
157 // console.log('MOVE'); |
152 |
158 |
|
159 if(this.mosaic.currentMode != 'MOSAIC' && this.mosaic.currentMode != 'FILTER') |
|
160 { |
|
161 mainPointerX -= 130; |
|
162 mainPointerY -= 60; |
|
163 } |
|
164 |
153 if(!this.mainPointerLastX || !this.mainPointerLastY) |
165 if(!this.mainPointerLastX || !this.mainPointerLastY) |
154 { |
166 { |
155 this.mainPointerLastX = mainPointerX; |
167 this.mainPointerLastX = mainPointerX; |
156 this.mainPointerLastY = mainPointerY; |
168 this.mainPointerLastY = mainPointerY; |
157 } |
169 } |
171 this.mainPath.add(mainPoint); |
183 this.mainPath.add(mainPoint); |
172 this.mainPath.smooth(); |
184 this.mainPath.smooth(); |
173 |
185 |
174 //this.direction.remove(); |
186 //this.direction.remove(); |
175 // console.log(this.mainPointerLastX, this.mainPointerLastY); |
187 // console.log(this.mainPointerLastX, this.mainPointerLastY); |
176 var directionPoint = new paper.Point(this.mainPointerLastX, this.mainPointerLastY); |
188 /*var directionPoint = new paper.Point(this.mainPointerLastX, this.mainPointerLastY); |
177 var directionPointEnd = new paper.Point((mainPointerX - this.mainPointerLastX) * 2 + mainPointerX, (mainPointerY - this.mainPointerLastY) * 2 + mainPointerY); |
189 var directionPointEnd = new paper.Point((mainPointerX - this.mainPointerLastX) * 2 + mainPointerX, (mainPointerY - this.mainPointerLastY) * 2 + mainPointerY); |
178 this.direction.add(directionPoint); |
190 this.direction.add(directionPoint); |
179 this.direction.add(directionPointEnd); |
191 this.direction.add(directionPointEnd); |
180 this.direction.smooth(); |
192 this.direction.smooth();*/ |
181 |
193 |
182 //Variables de construction de la courbe secondaire. |
194 //Variables de construction de la courbe secondaire. |
183 var secondPoint, secondDelta, secondStep, secondStepStroke, secondTop, secondBottom, secondTopStroke, secondBottomStroke; |
195 var secondPoint, secondDelta, secondStep, secondStepStroke, secondTop, secondBottom, secondTopStroke, secondBottomStroke; |
184 |
196 |
185 //Si on a un pointeur secondaire. |
197 //Si on a un pointeur secondaire. |
229 this.mainPath.remove(); |
241 this.mainPath.remove(); |
230 |
242 |
231 this.mainPointerLastX = 0; |
243 this.mainPointerLastX = 0; |
232 this.mainPointerLastY = 0; |
244 this.mainPointerLastY = 0; |
233 |
245 |
234 this.direction.remove(); |
246 // this.direction.remove(); |
235 |
247 |
236 this.detector.reinit(); |
248 this.detector.reinit(); |
237 |
249 |
238 //Si on a un second pointeur, on réinitialise la courbe secondaire. |
250 //Si on a un second pointeur, on réinitialise la courbe secondaire. |
239 if(this.secondPathStroke) |
251 if(this.secondPathStroke) |