├── ur.jpg
├── demo
├── favicon.ico
├── resource
│ ├── assets
│ │ ├── bg.jpg
│ │ └── egret_icon.png
│ ├── config
│ │ └── description.json
│ └── default.res.json
├── template
│ └── runtime
│ │ ├── native_loader.js
│ │ ├── runtime_loader.js
│ │ └── native_require.js
├── egretProperties.json
├── src
│ ├── LoadingUI.ts
│ ├── Main.ts
│ └── GesturePanel.ts
└── index.html
├── README.md
└── libs
└── bin
└── ur
├── ur.d.ts
├── ur.min.js
└── ur.js
/ur.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RichLiu1023/UnistrokeRecognizer/HEAD/ur.jpg
--------------------------------------------------------------------------------
/demo/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RichLiu1023/UnistrokeRecognizer/HEAD/demo/favicon.ico
--------------------------------------------------------------------------------
/demo/resource/assets/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RichLiu1023/UnistrokeRecognizer/HEAD/demo/resource/assets/bg.jpg
--------------------------------------------------------------------------------
/demo/resource/assets/egret_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RichLiu1023/UnistrokeRecognizer/HEAD/demo/resource/assets/egret_icon.png
--------------------------------------------------------------------------------
/demo/template/runtime/native_loader.js:
--------------------------------------------------------------------------------
1 | require("launcher/native_require.js");
2 |
3 | egret_native.egtMain = function () {
4 | egret_native.nativeType = "native";
5 |
6 | egret_native.egretInit();
7 | egret_native.egretStart();
8 | };
9 |
--------------------------------------------------------------------------------
/demo/template/runtime/runtime_loader.js:
--------------------------------------------------------------------------------
1 | require("launcher/native_require.js");
2 |
3 | egret_native.egtMain = function () {
4 | egret_native.nativeType = "runtime";
5 |
6 | egret_native.egretInit();
7 | egret_native.egretStart();
8 | };
--------------------------------------------------------------------------------
/demo/resource/config/description.json:
--------------------------------------------------------------------------------
1 | [
2 | "Open-source,Free,Multi-platform",
3 | "Push Game Forward",
4 | "HTML5 Game Engine"
5 | ]
--------------------------------------------------------------------------------
/demo/resource/default.res.json:
--------------------------------------------------------------------------------
1 | {
2 | "groups":[
3 | {
4 | "keys":"bg_jpg,egret_icon_png,description_json",
5 | "name":"preload"
6 | }],
7 | "resources":[
8 | {
9 | "name":"bg_jpg",
10 | "type":"image",
11 | "url":"assets/bg.jpg"
12 | },
13 | {
14 | "name":"egret_icon_png",
15 | "type":"image",
16 | "url":"assets/egret_icon.png"
17 | },
18 | {
19 | "name":"description_json",
20 | "type":"json",
21 | "url":"config/description.json"
22 | }]
23 | }
--------------------------------------------------------------------------------
/demo/egretProperties.json:
--------------------------------------------------------------------------------
1 | {
2 | "native": {
3 | "path_ignore": []
4 | },
5 | "publish": {
6 | "web": 0,
7 | "native": 1,
8 | "path": "bin-release"
9 | },
10 | "egret_version": "3.1.6",
11 | "modules": [
12 | {
13 | "name": "egret"
14 | },
15 | {
16 | "name": "game"
17 | },
18 | {
19 | "name": "tween"
20 | },
21 | {
22 | "name": "res"
23 | },
24 | {
25 | "name": "ur",
26 | "path": "../libs"
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UnistrokeRecognizer
2 | 单笔手写识别、手势识别
3 |
4 | 根据 http://depts.washington.edu/aimgroup/proj/dollar/index.html 修改版
5 |
6 | 此版本可以在 `Egret` 中直接使用。
7 |
8 | 
9 |
10 | Demo 使用`Egret`,可以自定义手势。
11 |
12 |
13 | ```
14 | //自定义手势添加
15 | addGesture(name: string, points: Point[]): void;
16 | /**
17 | * 识别
18 | * @param points
19 | * @param useProtractor true:用量角器(快).false:黄金分割搜索
20 | * @returns {Result}
21 | * @constructor
22 | */
23 | recognize(points: Point[], useProtractor: boolean): Result;
24 | ```
25 |
26 | ==>>顺便点颗星
27 |
--------------------------------------------------------------------------------
/demo/template/runtime/native_require.js:
--------------------------------------------------------------------------------
1 |
2 | var game_file_list = [
3 | //以下为自动修改,请勿修改
4 | //----auto game_file_list start----
5 | "libs/modules/egret/egret.js",
6 | "libs/modules/egret/egret.native.js",
7 | "libs/modules/game/game.js",
8 | "libs/modules/game/game.native.js",
9 | "libs/modules/tween/tween.js",
10 | "libs/modules/res/res.js",
11 | "libs/modules/ur/ur.js",
12 | "bin-debug/GesturePanel.js",
13 | "bin-debug/LoadingUI.js",
14 | "bin-debug/Main.js",
15 | //----auto game_file_list end----
16 | ];
17 |
18 | var window = this;
19 |
20 | egret_native.setSearchPaths([""]);
21 |
22 | egret_native.requireFiles = function () {
23 | for (var key in game_file_list) {
24 | var src = game_file_list[key];
25 | require(src);
26 | }
27 | };
28 |
29 | egret_native.egretInit = function () {
30 | egret_native.requireFiles();
31 | egret.TextField.default_fontFamily = "/system/fonts/DroidSansFallback.ttf";
32 | //egret.dom为空实现
33 | egret.dom = {};
34 | egret.dom.drawAsCanvas = function () {
35 | };
36 | };
37 |
38 | egret_native.egretStart = function () {
39 | var option = {
40 | //以下为自动修改,请勿修改
41 | //----auto option start----
42 | entryClassName: "Main",
43 | frameRate: 30,
44 | scaleMode: "showAll",
45 | contentWidth: 640,
46 | contentHeight: 1136,
47 | showPaintRect: false,
48 | showFPS: false,
49 | fpsStyles: "x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9",
50 | showLog: true,
51 | logFilter: "",
52 | maxTouches: 2,
53 | textureScaleFactor: 1
54 | //----auto option end----
55 | };
56 |
57 | egret.native.NativePlayer.option = option;
58 | egret.runEgret();
59 | egret_native.Label.createLabel(egret.TextField.default_fontFamily, 20, "", 0);
60 | egret_native.EGTView.preSetOffScreenBufferEnable(true);
61 | };
--------------------------------------------------------------------------------
/demo/src/LoadingUI.ts:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////////////////////////////////////////////////////
2 | //
3 | // Copyright (c) 2014-present, Egret Technology.
4 | // All rights reserved.
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above copyright
11 | // notice, this list of conditions and the following disclaimer in the
12 | // documentation and/or other materials provided with the distribution.
13 | // * Neither the name of the Egret nor the
14 | // names of its contributors may be used to endorse or promote products
15 | // derived from this software without specific prior written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
18 | // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
23 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | //
28 | //////////////////////////////////////////////////////////////////////////////////////
29 |
30 | class LoadingUI extends egret.Sprite {
31 |
32 | public constructor() {
33 | super();
34 | this.createView();
35 | }
36 |
37 | private textField:egret.TextField;
38 |
39 | private createView():void {
40 | this.textField = new egret.TextField();
41 | this.addChild(this.textField);
42 | this.textField.y = 300;
43 | this.textField.width = 480;
44 | this.textField.height = 100;
45 | this.textField.textAlign = "center";
46 | }
47 |
48 | public setProgress(current:number, total:number):void {
49 | this.textField.text = `Loading...${current}/${total}`;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Egret
6 |
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
58 |
59 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/libs/bin/ur/ur.d.ts:
--------------------------------------------------------------------------------
1 | declare module ur {
2 | class Point {
3 | x: number;
4 | y: number;
5 | constructor(x?: any, y?: any);
6 | }
7 | class Rectangle {
8 | x: number;
9 | y: number;
10 | width: number;
11 | height: number;
12 | constructor(x: any, y: any, w: any, h: any);
13 | }
14 | class Result {
15 | /**
16 | * 如果匹配到则为识别名字,否则返回'No match'
17 | */
18 | name: any;
19 | /**
20 | * 匹配度
21 | */
22 | score: any;
23 | constructor(name: any, score: any);
24 | }
25 | /**
26 | * Create by richliu1023
27 | * @date 2016-08-24
28 | * @email richliu1023@gmail.com
29 | * @github https://github.com/RichLiu1023
30 | * @description
31 | * @url:http://depts.washington.edu/aimgroup/proj/dollar/index.html
32 | * 手写单笔识别
33 | */
34 | class UnistrokeRecognize {
35 | Origin: Point;
36 | private Diagonal;
37 | private HalfDiagonal;
38 | private _NumPoints;
39 | private _SquareSize;
40 | private _AngleRange;
41 | private _AnglePrecision;
42 | private _Phi;
43 | private Unistrokes;
44 | /**
45 | * 黄金分割比率
46 | * @param value
47 | * @constructor
48 | */
49 | Phi: number;
50 | SquareSize: number;
51 | /**
52 | * @returns {number} 弧度
53 | * @constructor
54 | */
55 | /**
56 | * @param value 角度
57 | * @constructor
58 | */
59 | AngleRange: number;
60 | AnglePrecision: number;
61 | /**
62 | * 最大点数默认64
63 | * @param value
64 | * @constructor
65 | */
66 | NumPoints: number;
67 | constructor();
68 | static create(): UnistrokeRecognize;
69 | private Unistroke(name, points);
70 | /**
71 | * 识别
72 | * @param points
73 | * @param useProtractor true:用量角器(快).false:黄金分割搜索
74 | * @returns {Result}
75 | * @constructor
76 | */
77 | recognize(points: Point[], useProtractor: boolean): Result;
78 | addGesture(name: string, points: Point[]): void;
79 | deleteAllGestures(): void;
80 | /**
81 | * 通过name获取Gesture信息
82 | * @param name 如果不传值,则返回所有的信息
83 | * @returns {any}
84 | */
85 | getGesture(name?: string): Array<{
86 | Name: string;
87 | Points: Point[];
88 | Vector: Point[];
89 | }>;
90 | private Resample(points, n);
91 | private IndicativeAngle(points);
92 | private RotateBy(points, radians);
93 | private ScaleTo(points, size);
94 | private TranslateTo(points, pt);
95 | private Vectorize(points);
96 | private OptimalCosineDistance(v1, v2);
97 | private DistanceAtBestAngle(points, T, a, b, threshold);
98 | private DistanceAtAngle(points, T, radians);
99 | private Centroid(points);
100 | private BoundingBox(points);
101 | private PathDistance(pts1, pts2);
102 | private PathLength(points);
103 | private Distance(p1, p2);
104 | private Deg2Rad(d);
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/libs/bin/ur/ur.min.js:
--------------------------------------------------------------------------------
1 | var ur;!function(t){var i=function(){function t(t,i){this.x=t||0,this.y=i||0}var i=(__define,t);i.prototype;return t}();t.Point=i,egret.registerClass(i,"ur.Point");var n=function(){function t(t,i,n,e){this.x=t,this.y=i,this.width=n,this.height=e}var i=(__define,t);i.prototype;return t}();t.Rectangle=n,egret.registerClass(n,"ur.Rectangle");var e=function(){function t(t,i){this.name=t,this.score=i}var i=(__define,t);i.prototype;return t}();t.Result=e,egret.registerClass(e,"ur.Result");var s=function(){function t(){this.Origin=new i,this.Diagonal=0,this.HalfDiagonal=0,this._NumPoints=64,this._SquareSize=0,this._AngleRange=this.Deg2Rad(45),this._AnglePrecision=this.Deg2Rad(2),this._Phi=0,this.Unistrokes=[],this.SquareSize=250,this.AnglePrecision=2,this.AngleRange=45,this.Phi=.5*(-1+Math.sqrt(5)),this.NumPoints=64}var s=__define,r=t,h=r.prototype;return s(h,"Phi",function(){return this._Phi},function(t){this._Phi=t}),s(h,"SquareSize",function(){return this._SquareSize},function(t){this._SquareSize=t,this.Diagonal=Math.sqrt(this._SquareSize*this._SquareSize+this._SquareSize*this._SquareSize),this.HalfDiagonal=.5*this.Diagonal}),s(h,"AngleRange",function(){return this._AngleRange},function(t){this._AngleRange=this.Deg2Rad(t)}),s(h,"AnglePrecision",function(){return this._AnglePrecision},function(t){this._AnglePrecision=this.Deg2Rad(t)}),s(h,"NumPoints",function(){return this._NumPoints},function(t){this._NumPoints=t}),t.create=function(){return new t},h.Unistroke=function(t,i){var n={};n.Name=t,n.Points=this.Resample(i,this._NumPoints);var e=this.IndicativeAngle(n.Points);return n.Points=this.RotateBy(n.Points,-e),n.Points=this.ScaleTo(n.Points,this._SquareSize),n.Points=this.TranslateTo(n.Points,this.Origin),n.Vector=this.Vectorize(n.Points),n},h.recognize=function(t,i){t=this.Resample(t,this._NumPoints);var n=this.IndicativeAngle(t);t=this.RotateBy(t,-n),t=this.ScaleTo(t,this._SquareSize),t=this.TranslateTo(t,this.Origin);for(var s=this.Vectorize(t),r=+(1/0),h=-1,a=0;ao&&(r=o,h=a)}return-1==h?new e("No match",0):new e(this.Unistrokes[h].Name,i?1/r:1-r/this.HalfDiagonal)},h.addGesture=function(t,i){this.Unistrokes[this.Unistrokes.length]=this.Unistroke(t,i)},h.deleteAllGestures=function(){this.Unistrokes.length=0},h.getGesture=function(t){var i=[];if(!t)return this.Unistrokes;for(var n=this.Unistrokes.length,e=0;n>e;e++)this.Unistrokes[e].Name==t&&i.push(this.Unistrokes[e]);return i},h.Resample=function(t,n){var e=this.PathLength(t)/(n-1),s=0,r=[t[0]];if(0>=e)return r;for(var h=1;h=e){var o=t[h-1].x+(e-s)/a*(t[h].x-t[h-1].x),u=t[h-1].y+(e-s)/a*(t[h].y-t[h-1].y),g=new i(o,u);r[r.length]=g,t.splice(h,0,g),s=0}else s+=a}return r.length==n-1&&(r[r.length]=new i(t[t.length-1].x,t[t.length-1].y)),r},h.IndicativeAngle=function(t){var i=this.Centroid(t);return Math.atan2(i.y-t[0].y,i.x-t[0].x)},h.RotateBy=function(t,n){for(var e=this.Centroid(t),s=Math.cos(n),r=Math.sin(n),h=new Array,a=0;as;)o>h?(e=a,a=r,o=h,r=this._Phi*n+(1-this._Phi)*e,h=this.DistanceAtAngle(t,i,r)):(n=r,r=a,h=o,a=(1-this._Phi)*n+this._Phi*e,o=this.DistanceAtAngle(t,i,a));return Math.min(h,o)},h.DistanceAtAngle=function(t,i,n){var e=this.RotateBy(t,n);return this.PathDistance(e,i.Points)},h.Centroid=function(t){for(var n=0,e=0,s=0;s= I) {
200 | var qx = points[i - 1].x + ((I - D) / d) * (points[i].x - points[i - 1].x);
201 | var qy = points[i - 1].y + ((I - D) / d) * (points[i].y - points[i - 1].y);
202 | var q = new Point(qx, qy);
203 | newpoints[newpoints.length] = q; // append new point 'q'
204 | points.splice(i, 0, q); // insert 'q' at position i in points s.t. 'q' will be the next i
205 | D = 0.0;
206 | }
207 | else
208 | D += d;
209 | }
210 | if (newpoints.length == n - 1)
211 | newpoints[newpoints.length] = new Point(points[points.length - 1].x, points[points.length - 1].y);
212 | return newpoints;
213 | };
214 | p.IndicativeAngle = function (points) {
215 | var c = this.Centroid(points);
216 | return Math.atan2(c.y - points[0].y, c.x - points[0].x);
217 | };
218 | p.RotateBy = function (points, radians) {
219 | var c = this.Centroid(points);
220 | var cos = Math.cos(radians);
221 | var sin = Math.sin(radians);
222 | var newpoints = new Array();
223 | for (var i = 0; i < points.length; i++) {
224 | var qx = (points[i].x - c.x) * cos - (points[i].y - c.y) * sin + c.x;
225 | var qy = (points[i].x - c.x) * sin + (points[i].y - c.y) * cos + c.y;
226 | newpoints[newpoints.length] = new Point(qx, qy);
227 | }
228 | return newpoints;
229 | };
230 | p.ScaleTo = function (points, size) {
231 | var B = this.BoundingBox(points);
232 | var newpoints = [];
233 | for (var i = 0; i < points.length; i++) {
234 | var qx = points[i].x * (size / B.width);
235 | var qy = points[i].y * (size / B.height);
236 | newpoints[newpoints.length] = new Point(qx, qy);
237 | }
238 | return newpoints;
239 | };
240 | p.TranslateTo = function (points, pt) {
241 | var c = this.Centroid(points);
242 | var newpoints = [];
243 | for (var i = 0; i < points.length; i++) {
244 | var qx = points[i].x + pt.x - c.x;
245 | var qy = points[i].y + pt.y - c.y;
246 | newpoints[newpoints.length] = new Point(qx, qy);
247 | }
248 | return newpoints;
249 | };
250 | p.Vectorize = function (points) {
251 | var sum = 0.0;
252 | var vector = [];
253 | for (var i = 0; i < points.length; i++) {
254 | vector[vector.length] = points[i].x;
255 | vector[vector.length] = points[i].y;
256 | sum += points[i].x * points[i].x + points[i].y * points[i].y;
257 | }
258 | var magnitude = Math.sqrt(sum);
259 | for (var i = 0; i < vector.length; i++)
260 | vector[i] /= magnitude;
261 | return vector;
262 | };
263 | p.OptimalCosineDistance = function (v1, v2) {
264 | var a = 0.0;
265 | var b = 0.0;
266 | for (var i = 0; i < v1.length; i += 2) {
267 | a += v1[i] * v2[i] + v1[i + 1] * v2[i + 1];
268 | b += v1[i] * v2[i + 1] - v1[i + 1] * v2[i];
269 | }
270 | var angle = Math.atan(b / a);
271 | return Math.acos(a * Math.cos(angle) + b * Math.sin(angle));
272 | };
273 | p.DistanceAtBestAngle = function (points, T, a, b, threshold) {
274 | var x1 = this._Phi * a + (1.0 - this._Phi) * b;
275 | var f1 = this.DistanceAtAngle(points, T, x1);
276 | var x2 = (1.0 - this._Phi) * a + this._Phi * b;
277 | var f2 = this.DistanceAtAngle(points, T, x2);
278 | while (Math.abs(b - a) > threshold) {
279 | if (f1 < f2) {
280 | b = x2;
281 | x2 = x1;
282 | f2 = f1;
283 | x1 = this._Phi * a + (1.0 - this._Phi) * b;
284 | f1 = this.DistanceAtAngle(points, T, x1);
285 | }
286 | else {
287 | a = x1;
288 | x1 = x2;
289 | f1 = f2;
290 | x2 = (1.0 - this._Phi) * a + this._Phi * b;
291 | f2 = this.DistanceAtAngle(points, T, x2);
292 | }
293 | }
294 | return Math.min(f1, f2);
295 | };
296 | p.DistanceAtAngle = function (points, T, radians) {
297 | var newpoints = this.RotateBy(points, radians);
298 | return this.PathDistance(newpoints, T.Points);
299 | };
300 | p.Centroid = function (points) {
301 | var x = 0.0, y = 0.0;
302 | for (var i = 0; i < points.length; i++) {
303 | x += points[i].x;
304 | y += points[i].y;
305 | }
306 | x /= points.length;
307 | y /= points.length;
308 | return new Point(x, y);
309 | };
310 | p.BoundingBox = function (points) {
311 | var minX = +Infinity, maxX = -Infinity, minY = +Infinity, maxY = -Infinity;
312 | for (var i = 0; i < points.length; i++) {
313 | minX = Math.min(minX, points[i].x);
314 | minY = Math.min(minY, points[i].y);
315 | maxX = Math.max(maxX, points[i].x);
316 | maxY = Math.max(maxY, points[i].y);
317 | }
318 | return new Rectangle(minX, minY, maxX - minX, maxY - minY);
319 | };
320 | p.PathDistance = function (pts1, pts2) {
321 | var d = 0.0;
322 | for (var i = 0; i < pts1.length; i++)
323 | d += this.Distance(pts1[i], pts2[i]);
324 | return d / pts1.length;
325 | };
326 | p.PathLength = function (points) {
327 | var d = 0.0;
328 | for (var i = 1; i < points.length; i++)
329 | d += this.Distance(points[i - 1], points[i]);
330 | return d;
331 | };
332 | p.Distance = function (p1, p2) {
333 | var dx = p2.x - p1.x;
334 | var dy = p2.y - p1.y;
335 | return parseFloat(Math.sqrt(dx * dx + dy * dy).toFixed(2));
336 | };
337 | p.Deg2Rad = function (d) {
338 | return (d * Math.PI / 180.0);
339 | };
340 | return UnistrokeRecognize;
341 | }());
342 | ur.UnistrokeRecognize = UnistrokeRecognize;
343 | egret.registerClass(UnistrokeRecognize,'ur.UnistrokeRecognize');
344 | })(ur || (ur = {}));
345 |
346 |
347 |
--------------------------------------------------------------------------------
/demo/src/GesturePanel.ts:
--------------------------------------------------------------------------------
1 | import DisplayObject = egret.DisplayObject;
2 | import DisplayObjectContainer = egret.DisplayObjectContainer;
3 | /**
4 | * Create by richliu1023
5 | * @date 2016-08-24
6 | * @email richliu1023@gmail.com
7 | * @github https://github.com/RichLiu1023
8 | * @description a simple explanation
9 | */
10 | class GesturePanel extends DisplayObjectContainer {
11 |
12 | private _mousePoints:ur.Point[];
13 | private _currentPoint:ur.Point;
14 | private _layer:egret.Sprite;
15 | private gestureUtil:ur.UnistrokeRecognize = ur.UnistrokeRecognize.create();
16 |
17 | public constructor() {
18 | super();
19 | }
20 |
21 | init():void {
22 | this._layer = new egret.Sprite();
23 | this.addChild( this._layer );
24 | this.gestureUtil.addGesture( "triangle",
25 | new Array( new ur.Point( 137, 139 ), new ur.Point( 135, 141 ), new ur.Point( 133, 144 ), new ur.Point( 132, 146 ), new ur.Point( 130, 149 ), new ur.Point( 128, 151 ), new ur.Point( 126, 155 ), new ur.Point( 123, 160 ), new ur.Point( 120, 166 ), new ur.Point( 116, 171 ), new ur.Point( 112, 177 ), new ur.Point( 107, 183 ), new ur.Point( 102, 188 ), new ur.Point( 100, 191 ), new ur.Point( 95, 195 ), new ur.Point( 90, 199 ), new ur.Point( 86, 203 ), new ur.Point( 82, 206 ), new ur.Point( 80, 209 ), new ur.Point( 75, 213 ), new ur.Point( 73, 213 ), new ur.Point( 70, 216 ), new ur.Point( 67, 219 ), new ur.Point( 64, 221 ), new ur.Point( 61, 223 ), new ur.Point( 60, 225 ), new ur.Point( 62, 226 ), new ur.Point( 65, 225 ), new ur.Point( 67, 226 ), new ur.Point( 74, 226 ), new ur.Point( 77, 227 ), new ur.Point( 85, 229 ), new ur.Point( 91, 230 ), new ur.Point( 99, 231 ), new ur.Point( 108, 232 ), new ur.Point( 116, 233 ), new ur.Point( 125, 233 ), new ur.Point( 134, 234 ), new ur.Point( 145, 233 ), new ur.Point( 153, 232 ), new ur.Point( 160, 233 ), new ur.Point( 170, 234 ), new ur.Point( 177, 235 ), new ur.Point( 179, 236 ), new ur.Point( 186, 237 ), new ur.Point( 193, 238 ), new ur.Point( 198, 239 ), new ur.Point( 200, 237 ), new ur.Point( 202, 239 ), new ur.Point( 204, 238 ), new ur.Point( 206, 234 ), new ur.Point( 205, 230 ), new ur.Point( 202, 222 ), new ur.Point( 197, 216 ), new ur.Point( 192, 207 ), new ur.Point( 186, 198 ), new ur.Point( 179, 189 ), new ur.Point( 174, 183 ), new ur.Point( 170, 178 ), new ur.Point( 164, 171 ), new ur.Point( 161, 168 ), new ur.Point( 154, 160 ), new ur.Point( 148, 155 ), new ur.Point( 143, 150 ), new ur.Point( 138, 148 ), new ur.Point( 136, 148 ) ) );
26 | this.gestureUtil.addGesture( "x",
27 | new Array( new ur.Point( 87, 142 ), new ur.Point( 89, 145 ), new ur.Point( 91, 148 ), new ur.Point( 93, 151 ), new ur.Point( 96, 155 ), new ur.Point( 98, 157 ), new ur.Point( 100, 160 ), new ur.Point( 102, 162 ), new ur.Point( 106, 167 ), new ur.Point( 108, 169 ), new ur.Point( 110, 171 ), new ur.Point( 115, 177 ), new ur.Point( 119, 183 ), new ur.Point( 123, 189 ), new ur.Point( 127, 193 ), new ur.Point( 129, 196 ), new ur.Point( 133, 200 ), new ur.Point( 137, 206 ), new ur.Point( 140, 209 ), new ur.Point( 143, 212 ), new ur.Point( 146, 215 ), new ur.Point( 151, 220 ), new ur.Point( 153, 222 ), new ur.Point( 155, 223 ), new ur.Point( 157, 225 ), new ur.Point( 158, 223 ), new ur.Point( 157, 218 ), new ur.Point( 155, 211 ), new ur.Point( 154, 208 ), new ur.Point( 152, 200 ), new ur.Point( 150, 189 ), new ur.Point( 148, 179 ), new ur.Point( 147, 170 ), new ur.Point( 147, 158 ), new ur.Point( 147, 148 ), new ur.Point( 147, 141 ), new ur.Point( 147, 136 ), new ur.Point( 144, 135 ), new ur.Point( 142, 137 ), new ur.Point( 140, 139 ), new ur.Point( 135, 145 ), new ur.Point( 131, 152 ), new ur.Point( 124, 163 ), new ur.Point( 116, 177 ), new ur.Point( 108, 191 ), new ur.Point( 100, 206 ), new ur.Point( 94, 217 ), new ur.Point( 91, 222 ), new ur.Point( 89, 225 ), new ur.Point( 87, 226 ), new ur.Point( 87, 224 ) ) );
28 | this.gestureUtil.addGesture( "rectangle",
29 | new Array( new ur.Point( 78, 149 ), new ur.Point( 78, 153 ), new ur.Point( 78, 157 ), new ur.Point( 78, 160 ), new ur.Point( 79, 162 ), new ur.Point( 79, 164 ), new ur.Point( 79, 167 ), new ur.Point( 79, 169 ), new ur.Point( 79, 173 ), new ur.Point( 79, 178 ), new ur.Point( 79, 183 ), new ur.Point( 80, 189 ), new ur.Point( 80, 193 ), new ur.Point( 80, 198 ), new ur.Point( 80, 202 ), new ur.Point( 81, 208 ), new ur.Point( 81, 210 ), new ur.Point( 81, 216 ), new ur.Point( 82, 222 ), new ur.Point( 82, 224 ), new ur.Point( 82, 227 ), new ur.Point( 83, 229 ), new ur.Point( 83, 231 ), new ur.Point( 85, 230 ), new ur.Point( 88, 232 ), new ur.Point( 90, 233 ), new ur.Point( 92, 232 ), new ur.Point( 94, 233 ), new ur.Point( 99, 232 ), new ur.Point( 102, 233 ), new ur.Point( 106, 233 ), new ur.Point( 109, 234 ), new ur.Point( 117, 235 ), new ur.Point( 123, 236 ), new ur.Point( 126, 236 ), new ur.Point( 135, 237 ), new ur.Point( 142, 238 ), new ur.Point( 145, 238 ), new ur.Point( 152, 238 ), new ur.Point( 154, 239 ), new ur.Point( 165, 238 ), new ur.Point( 174, 237 ), new ur.Point( 179, 236 ), new ur.Point( 186, 235 ), new ur.Point( 191, 235 ), new ur.Point( 195, 233 ), new ur.Point( 197, 233 ), new ur.Point( 200, 233 ), new ur.Point( 201, 235 ), new ur.Point( 201, 233 ), new ur.Point( 199, 231 ), new ur.Point( 198, 226 ), new ur.Point( 198, 220 ), new ur.Point( 196, 207 ), new ur.Point( 195, 195 ), new ur.Point( 195, 181 ), new ur.Point( 195, 173 ), new ur.Point( 195, 163 ), new ur.Point( 194, 155 ), new ur.Point( 192, 145 ), new ur.Point( 192, 143 ), new ur.Point( 192, 138 ), new ur.Point( 191, 135 ), new ur.Point( 191, 133 ), new ur.Point( 191, 130 ), new ur.Point( 190, 128 ), new ur.Point( 188, 129 ), new ur.Point( 186, 129 ), new ur.Point( 181, 132 ), new ur.Point( 173, 131 ), new ur.Point( 162, 131 ), new ur.Point( 151, 132 ), new ur.Point( 149, 132 ), new ur.Point( 138, 132 ), new ur.Point( 136, 132 ), new ur.Point( 122, 131 ), new ur.Point( 120, 131 ), new ur.Point( 109, 130 ), new ur.Point( 107, 130 ), new ur.Point( 90, 132 ), new ur.Point( 81, 133 ), new ur.Point( 76, 133 ) ) );
30 | this.gestureUtil.addGesture( "circle",
31 | new Array( new ur.Point( 127, 141 ), new ur.Point( 124, 140 ), new ur.Point( 120, 139 ), new ur.Point( 118, 139 ), new ur.Point( 116, 139 ), new ur.Point( 111, 140 ), new ur.Point( 109, 141 ), new ur.Point( 104, 144 ), new ur.Point( 100, 147 ), new ur.Point( 96, 152 ), new ur.Point( 93, 157 ), new ur.Point( 90, 163 ), new ur.Point( 87, 169 ), new ur.Point( 85, 175 ), new ur.Point( 83, 181 ), new ur.Point( 82, 190 ), new ur.Point( 82, 195 ), new ur.Point( 83, 200 ), new ur.Point( 84, 205 ), new ur.Point( 88, 213 ), new ur.Point( 91, 216 ), new ur.Point( 96, 219 ), new ur.Point( 103, 222 ), new ur.Point( 108, 224 ), new ur.Point( 111, 224 ), new ur.Point( 120, 224 ), new ur.Point( 133, 223 ), new ur.Point( 142, 222 ), new ur.Point( 152, 218 ), new ur.Point( 160, 214 ), new ur.Point( 167, 210 ), new ur.Point( 173, 204 ), new ur.Point( 178, 198 ), new ur.Point( 179, 196 ), new ur.Point( 182, 188 ), new ur.Point( 182, 177 ), new ur.Point( 178, 167 ), new ur.Point( 170, 150 ), new ur.Point( 163, 138 ), new ur.Point( 152, 130 ), new ur.Point( 143, 129 ), new ur.Point( 140, 131 ), new ur.Point( 129, 136 ), new ur.Point( 126, 139 ) ) );
32 | this.gestureUtil.addGesture( "check",
33 | new Array( new ur.Point( 91, 185 ), new ur.Point( 93, 185 ), new ur.Point( 95, 185 ), new ur.Point( 97, 185 ), new ur.Point( 100, 188 ), new ur.Point( 102, 189 ), new ur.Point( 104, 190 ), new ur.Point( 106, 193 ), new ur.Point( 108, 195 ), new ur.Point( 110, 198 ), new ur.Point( 112, 201 ), new ur.Point( 114, 204 ), new ur.Point( 115, 207 ), new ur.Point( 117, 210 ), new ur.Point( 118, 212 ), new ur.Point( 120, 214 ), new ur.Point( 121, 217 ), new ur.Point( 122, 219 ), new ur.Point( 123, 222 ), new ur.Point( 124, 224 ), new ur.Point( 126, 226 ), new ur.Point( 127, 229 ), new ur.Point( 129, 231 ), new ur.Point( 130, 233 ), new ur.Point( 129, 231 ), new ur.Point( 129, 228 ), new ur.Point( 129, 226 ), new ur.Point( 129, 224 ), new ur.Point( 129, 221 ), new ur.Point( 129, 218 ), new ur.Point( 129, 212 ), new ur.Point( 129, 208 ), new ur.Point( 130, 198 ), new ur.Point( 132, 189 ), new ur.Point( 134, 182 ), new ur.Point( 137, 173 ), new ur.Point( 143, 164 ), new ur.Point( 147, 157 ), new ur.Point( 151, 151 ), new ur.Point( 155, 144 ), new ur.Point( 161, 137 ), new ur.Point( 165, 131 ), new ur.Point( 171, 122 ), new ur.Point( 174, 118 ), new ur.Point( 176, 114 ), new ur.Point( 177, 112 ), new ur.Point( 177, 114 ), new ur.Point( 175, 116 ), new ur.Point( 173, 118 ) ) );
34 | this.gestureUtil.addGesture( "caret",
35 | new Array( new ur.Point( 79, 245 ), new ur.Point( 79, 242 ), new ur.Point( 79, 239 ), new ur.Point( 80, 237 ), new ur.Point( 80, 234 ), new ur.Point( 81, 232 ), new ur.Point( 82, 230 ), new ur.Point( 84, 224 ), new ur.Point( 86, 220 ), new ur.Point( 86, 218 ), new ur.Point( 87, 216 ), new ur.Point( 88, 213 ), new ur.Point( 90, 207 ), new ur.Point( 91, 202 ), new ur.Point( 92, 200 ), new ur.Point( 93, 194 ), new ur.Point( 94, 192 ), new ur.Point( 96, 189 ), new ur.Point( 97, 186 ), new ur.Point( 100, 179 ), new ur.Point( 102, 173 ), new ur.Point( 105, 165 ), new ur.Point( 107, 160 ), new ur.Point( 109, 158 ), new ur.Point( 112, 151 ), new ur.Point( 115, 144 ), new ur.Point( 117, 139 ), new ur.Point( 119, 136 ), new ur.Point( 119, 134 ), new ur.Point( 120, 132 ), new ur.Point( 121, 129 ), new ur.Point( 122, 127 ), new ur.Point( 124, 125 ), new ur.Point( 126, 124 ), new ur.Point( 129, 125 ), new ur.Point( 131, 127 ), new ur.Point( 132, 130 ), new ur.Point( 136, 139 ), new ur.Point( 141, 154 ), new ur.Point( 145, 166 ), new ur.Point( 151, 182 ), new ur.Point( 156, 193 ), new ur.Point( 157, 196 ), new ur.Point( 161, 209 ), new ur.Point( 162, 211 ), new ur.Point( 167, 223 ), new ur.Point( 169, 229 ), new ur.Point( 170, 231 ), new ur.Point( 173, 237 ), new ur.Point( 176, 242 ), new ur.Point( 177, 244 ), new ur.Point( 179, 250 ), new ur.Point( 181, 255 ), new ur.Point( 182, 257 ) ) );
36 | this.gestureUtil.addGesture( "zig-zag",
37 | new Array( new ur.Point( 307, 216 ), new ur.Point( 333, 186 ), new ur.Point( 356, 215 ), new ur.Point( 375, 186 ), new ur.Point( 399, 216 ), new ur.Point( 418, 186 ) ) );
38 | this.gestureUtil.addGesture( "arrow",
39 | new Array( new ur.Point( 68, 222 ), new ur.Point( 70, 220 ), new ur.Point( 73, 218 ), new ur.Point( 75, 217 ), new ur.Point( 77, 215 ), new ur.Point( 80, 213 ), new ur.Point( 82, 212 ), new ur.Point( 84, 210 ), new ur.Point( 87, 209 ), new ur.Point( 89, 208 ), new ur.Point( 92, 206 ), new ur.Point( 95, 204 ), new ur.Point( 101, 201 ), new ur.Point( 106, 198 ), new ur.Point( 112, 194 ), new ur.Point( 118, 191 ), new ur.Point( 124, 187 ), new ur.Point( 127, 186 ), new ur.Point( 132, 183 ), new ur.Point( 138, 181 ), new ur.Point( 141, 180 ), new ur.Point( 146, 178 ), new ur.Point( 154, 173 ), new ur.Point( 159, 171 ), new ur.Point( 161, 170 ), new ur.Point( 166, 167 ), new ur.Point( 168, 167 ), new ur.Point( 171, 166 ), new ur.Point( 174, 164 ), new ur.Point( 177, 162 ), new ur.Point( 180, 160 ), new ur.Point( 182, 158 ), new ur.Point( 183, 156 ), new ur.Point( 181, 154 ), new ur.Point( 178, 153 ), new ur.Point( 171, 153 ), new ur.Point( 164, 153 ), new ur.Point( 160, 153 ), new ur.Point( 150, 154 ), new ur.Point( 147, 155 ), new ur.Point( 141, 157 ), new ur.Point( 137, 158 ), new ur.Point( 135, 158 ), new ur.Point( 137, 158 ), new ur.Point( 140, 157 ), new ur.Point( 143, 156 ), new ur.Point( 151, 154 ), new ur.Point( 160, 152 ), new ur.Point( 170, 149 ), new ur.Point( 179, 147 ), new ur.Point( 185, 145 ), new ur.Point( 192, 144 ), new ur.Point( 196, 144 ), new ur.Point( 198, 144 ), new ur.Point( 200, 144 ), new ur.Point( 201, 147 ), new ur.Point( 199, 149 ), new ur.Point( 194, 157 ), new ur.Point( 191, 160 ), new ur.Point( 186, 167 ), new ur.Point( 180, 176 ), new ur.Point( 177, 179 ), new ur.Point( 171, 187 ), new ur.Point( 169, 189 ), new ur.Point( 165, 194 ), new ur.Point( 164, 196 ) ) );
40 | this.gestureUtil.addGesture( "left square bracket",
41 | new Array( new ur.Point( 140, 124 ), new ur.Point( 138, 123 ), new ur.Point( 135, 122 ), new ur.Point( 133, 123 ), new ur.Point( 130, 123 ), new ur.Point( 128, 124 ), new ur.Point( 125, 125 ), new ur.Point( 122, 124 ), new ur.Point( 120, 124 ), new ur.Point( 118, 124 ), new ur.Point( 116, 125 ), new ur.Point( 113, 125 ), new ur.Point( 111, 125 ), new ur.Point( 108, 124 ), new ur.Point( 106, 125 ), new ur.Point( 104, 125 ), new ur.Point( 102, 124 ), new ur.Point( 100, 123 ), new ur.Point( 98, 123 ), new ur.Point( 95, 124 ), new ur.Point( 93, 123 ), new ur.Point( 90, 124 ), new ur.Point( 88, 124 ), new ur.Point( 85, 125 ), new ur.Point( 83, 126 ), new ur.Point( 81, 127 ), new ur.Point( 81, 129 ), new ur.Point( 82, 131 ), new ur.Point( 82, 134 ), new ur.Point( 83, 138 ), new ur.Point( 84, 141 ), new ur.Point( 84, 144 ), new ur.Point( 85, 148 ), new ur.Point( 85, 151 ), new ur.Point( 86, 156 ), new ur.Point( 86, 160 ), new ur.Point( 86, 164 ), new ur.Point( 86, 168 ), new ur.Point( 87, 171 ), new ur.Point( 87, 175 ), new ur.Point( 87, 179 ), new ur.Point( 87, 182 ), new ur.Point( 87, 186 ), new ur.Point( 88, 188 ), new ur.Point( 88, 195 ), new ur.Point( 88, 198 ), new ur.Point( 88, 201 ), new ur.Point( 88, 207 ), new ur.Point( 89, 211 ), new ur.Point( 89, 213 ), new ur.Point( 89, 217 ), new ur.Point( 89, 222 ), new ur.Point( 88, 225 ), new ur.Point( 88, 229 ), new ur.Point( 88, 231 ), new ur.Point( 88, 233 ), new ur.Point( 88, 235 ), new ur.Point( 89, 237 ), new ur.Point( 89, 240 ), new ur.Point( 89, 242 ), new ur.Point( 91, 241 ), new ur.Point( 94, 241 ), new ur.Point( 96, 240 ), new ur.Point( 98, 239 ), new ur.Point( 105, 240 ), new ur.Point( 109, 240 ), new ur.Point( 113, 239 ), new ur.Point( 116, 240 ), new ur.Point( 121, 239 ), new ur.Point( 130, 240 ), new ur.Point( 136, 237 ), new ur.Point( 139, 237 ), new ur.Point( 144, 238 ), new ur.Point( 151, 237 ), new ur.Point( 157, 236 ), new ur.Point( 159, 237 ) ) );
42 | this.gestureUtil.addGesture( "right square bracket",
43 | new Array( new ur.Point( 112, 138 ), new ur.Point( 112, 136 ), new ur.Point( 115, 136 ), new ur.Point( 118, 137 ), new ur.Point( 120, 136 ), new ur.Point( 123, 136 ), new ur.Point( 125, 136 ), new ur.Point( 128, 136 ), new ur.Point( 131, 136 ), new ur.Point( 134, 135 ), new ur.Point( 137, 135 ), new ur.Point( 140, 134 ), new ur.Point( 143, 133 ), new ur.Point( 145, 132 ), new ur.Point( 147, 132 ), new ur.Point( 149, 132 ), new ur.Point( 152, 132 ), new ur.Point( 153, 134 ), new ur.Point( 154, 137 ), new ur.Point( 155, 141 ), new ur.Point( 156, 144 ), new ur.Point( 157, 152 ), new ur.Point( 158, 161 ), new ur.Point( 160, 170 ), new ur.Point( 162, 182 ), new ur.Point( 164, 192 ), new ur.Point( 166, 200 ), new ur.Point( 167, 209 ), new ur.Point( 168, 214 ), new ur.Point( 168, 216 ), new ur.Point( 169, 221 ), new ur.Point( 169, 223 ), new ur.Point( 169, 228 ), new ur.Point( 169, 231 ), new ur.Point( 166, 233 ), new ur.Point( 164, 234 ), new ur.Point( 161, 235 ), new ur.Point( 155, 236 ), new ur.Point( 147, 235 ), new ur.Point( 140, 233 ), new ur.Point( 131, 233 ), new ur.Point( 124, 233 ), new ur.Point( 117, 235 ), new ur.Point( 114, 238 ), new ur.Point( 112, 238 ) ) );
44 | this.gestureUtil.addGesture( "v",
45 | new Array( new ur.Point( 89, 164 ), new ur.Point( 90, 162 ), new ur.Point( 92, 162 ), new ur.Point( 94, 164 ), new ur.Point( 95, 166 ), new ur.Point( 96, 169 ), new ur.Point( 97, 171 ), new ur.Point( 99, 175 ), new ur.Point( 101, 178 ), new ur.Point( 103, 182 ), new ur.Point( 106, 189 ), new ur.Point( 108, 194 ), new ur.Point( 111, 199 ), new ur.Point( 114, 204 ), new ur.Point( 117, 209 ), new ur.Point( 119, 214 ), new ur.Point( 122, 218 ), new ur.Point( 124, 222 ), new ur.Point( 126, 225 ), new ur.Point( 128, 228 ), new ur.Point( 130, 229 ), new ur.Point( 133, 233 ), new ur.Point( 134, 236 ), new ur.Point( 136, 239 ), new ur.Point( 138, 240 ), new ur.Point( 139, 242 ), new ur.Point( 140, 244 ), new ur.Point( 142, 242 ), new ur.Point( 142, 240 ), new ur.Point( 142, 237 ), new ur.Point( 143, 235 ), new ur.Point( 143, 233 ), new ur.Point( 145, 229 ), new ur.Point( 146, 226 ), new ur.Point( 148, 217 ), new ur.Point( 149, 208 ), new ur.Point( 149, 205 ), new ur.Point( 151, 196 ), new ur.Point( 151, 193 ), new ur.Point( 153, 182 ), new ur.Point( 155, 172 ), new ur.Point( 157, 165 ), new ur.Point( 159, 160 ), new ur.Point( 162, 155 ), new ur.Point( 164, 150 ), new ur.Point( 165, 148 ), new ur.Point( 166, 146 ) ) );
46 | this.gestureUtil.addGesture( "delete",
47 | new Array( new ur.Point( 123, 129 ), new ur.Point( 123, 131 ), new ur.Point( 124, 133 ), new ur.Point( 125, 136 ), new ur.Point( 127, 140 ), new ur.Point( 129, 142 ), new ur.Point( 133, 148 ), new ur.Point( 137, 154 ), new ur.Point( 143, 158 ), new ur.Point( 145, 161 ), new ur.Point( 148, 164 ), new ur.Point( 153, 170 ), new ur.Point( 158, 176 ), new ur.Point( 160, 178 ), new ur.Point( 164, 183 ), new ur.Point( 168, 188 ), new ur.Point( 171, 191 ), new ur.Point( 175, 196 ), new ur.Point( 178, 200 ), new ur.Point( 180, 202 ), new ur.Point( 181, 205 ), new ur.Point( 184, 208 ), new ur.Point( 186, 210 ), new ur.Point( 187, 213 ), new ur.Point( 188, 215 ), new ur.Point( 186, 212 ), new ur.Point( 183, 211 ), new ur.Point( 177, 208 ), new ur.Point( 169, 206 ), new ur.Point( 162, 205 ), new ur.Point( 154, 207 ), new ur.Point( 145, 209 ), new ur.Point( 137, 210 ), new ur.Point( 129, 214 ), new ur.Point( 122, 217 ), new ur.Point( 118, 218 ), new ur.Point( 111, 221 ), new ur.Point( 109, 222 ), new ur.Point( 110, 219 ), new ur.Point( 112, 217 ), new ur.Point( 118, 209 ), new ur.Point( 120, 207 ), new ur.Point( 128, 196 ), new ur.Point( 135, 187 ), new ur.Point( 138, 183 ), new ur.Point( 148, 167 ), new ur.Point( 157, 153 ), new ur.Point( 163, 145 ), new ur.Point( 165, 142 ), new ur.Point( 172, 133 ), new ur.Point( 177, 127 ), new ur.Point( 179, 127 ), new ur.Point( 180, 125 ) ) );
48 | this.gestureUtil.addGesture( "left curly brace",
49 | new Array( new ur.Point( 150, 116 ), new ur.Point( 147, 117 ), new ur.Point( 145, 116 ), new ur.Point( 142, 116 ), new ur.Point( 139, 117 ), new ur.Point( 136, 117 ), new ur.Point( 133, 118 ), new ur.Point( 129, 121 ), new ur.Point( 126, 122 ), new ur.Point( 123, 123 ), new ur.Point( 120, 125 ), new ur.Point( 118, 127 ), new ur.Point( 115, 128 ), new ur.Point( 113, 129 ), new ur.Point( 112, 131 ), new ur.Point( 113, 134 ), new ur.Point( 115, 134 ), new ur.Point( 117, 135 ), new ur.Point( 120, 135 ), new ur.Point( 123, 137 ), new ur.Point( 126, 138 ), new ur.Point( 129, 140 ), new ur.Point( 135, 143 ), new ur.Point( 137, 144 ), new ur.Point( 139, 147 ), new ur.Point( 141, 149 ), new ur.Point( 140, 152 ), new ur.Point( 139, 155 ), new ur.Point( 134, 159 ), new ur.Point( 131, 161 ), new ur.Point( 124, 166 ), new ur.Point( 121, 166 ), new ur.Point( 117, 166 ), new ur.Point( 114, 167 ), new ur.Point( 112, 166 ), new ur.Point( 114, 164 ), new ur.Point( 116, 163 ), new ur.Point( 118, 163 ), new ur.Point( 120, 162 ), new ur.Point( 122, 163 ), new ur.Point( 125, 164 ), new ur.Point( 127, 165 ), new ur.Point( 129, 166 ), new ur.Point( 130, 168 ), new ur.Point( 129, 171 ), new ur.Point( 127, 175 ), new ur.Point( 125, 179 ), new ur.Point( 123, 184 ), new ur.Point( 121, 190 ), new ur.Point( 120, 194 ), new ur.Point( 119, 199 ), new ur.Point( 120, 202 ), new ur.Point( 123, 207 ), new ur.Point( 127, 211 ), new ur.Point( 133, 215 ), new ur.Point( 142, 219 ), new ur.Point( 148, 220 ), new ur.Point( 151, 221 ) ) );
50 | this.gestureUtil.addGesture( "right curly brace",
51 | new Array( new ur.Point( 117, 132 ), new ur.Point( 115, 132 ), new ur.Point( 115, 129 ), new ur.Point( 117, 129 ), new ur.Point( 119, 128 ), new ur.Point( 122, 127 ), new ur.Point( 125, 127 ), new ur.Point( 127, 127 ), new ur.Point( 130, 127 ), new ur.Point( 133, 129 ), new ur.Point( 136, 129 ), new ur.Point( 138, 130 ), new ur.Point( 140, 131 ), new ur.Point( 143, 134 ), new ur.Point( 144, 136 ), new ur.Point( 145, 139 ), new ur.Point( 145, 142 ), new ur.Point( 145, 145 ), new ur.Point( 145, 147 ), new ur.Point( 145, 149 ), new ur.Point( 144, 152 ), new ur.Point( 142, 157 ), new ur.Point( 141, 160 ), new ur.Point( 139, 163 ), new ur.Point( 137, 166 ), new ur.Point( 135, 167 ), new ur.Point( 133, 169 ), new ur.Point( 131, 172 ), new ur.Point( 128, 173 ), new ur.Point( 126, 176 ), new ur.Point( 125, 178 ), new ur.Point( 125, 180 ), new ur.Point( 125, 182 ), new ur.Point( 126, 184 ), new ur.Point( 128, 187 ), new ur.Point( 130, 187 ), new ur.Point( 132, 188 ), new ur.Point( 135, 189 ), new ur.Point( 140, 189 ), new ur.Point( 145, 189 ), new ur.Point( 150, 187 ), new ur.Point( 155, 186 ), new ur.Point( 157, 185 ), new ur.Point( 159, 184 ), new ur.Point( 156, 185 ), new ur.Point( 154, 185 ), new ur.Point( 149, 185 ), new ur.Point( 145, 187 ), new ur.Point( 141, 188 ), new ur.Point( 136, 191 ), new ur.Point( 134, 191 ), new ur.Point( 131, 192 ), new ur.Point( 129, 193 ), new ur.Point( 129, 195 ), new ur.Point( 129, 197 ), new ur.Point( 131, 200 ), new ur.Point( 133, 202 ), new ur.Point( 136, 206 ), new ur.Point( 139, 211 ), new ur.Point( 142, 215 ), new ur.Point( 145, 220 ), new ur.Point( 147, 225 ), new ur.Point( 148, 231 ), new ur.Point( 147, 239 ), new ur.Point( 144, 244 ), new ur.Point( 139, 248 ), new ur.Point( 134, 250 ), new ur.Point( 126, 253 ), new ur.Point( 119, 253 ), new ur.Point( 115, 253 ) ) );
52 | this.gestureUtil.addGesture( "star",
53 | new Array( new ur.Point( 75, 250 ), new ur.Point( 75, 247 ), new ur.Point( 77, 244 ), new ur.Point( 78, 242 ), new ur.Point( 79, 239 ), new ur.Point( 80, 237 ), new ur.Point( 82, 234 ), new ur.Point( 82, 232 ), new ur.Point( 84, 229 ), new ur.Point( 85, 225 ), new ur.Point( 87, 222 ), new ur.Point( 88, 219 ), new ur.Point( 89, 216 ), new ur.Point( 91, 212 ), new ur.Point( 92, 208 ), new ur.Point( 94, 204 ), new ur.Point( 95, 201 ), new ur.Point( 96, 196 ), new ur.Point( 97, 194 ), new ur.Point( 98, 191 ), new ur.Point( 100, 185 ), new ur.Point( 102, 178 ), new ur.Point( 104, 173 ), new ur.Point( 104, 171 ), new ur.Point( 105, 164 ), new ur.Point( 106, 158 ), new ur.Point( 107, 156 ), new ur.Point( 107, 152 ), new ur.Point( 108, 145 ), new ur.Point( 109, 141 ), new ur.Point( 110, 139 ), new ur.Point( 112, 133 ), new ur.Point( 113, 131 ), new ur.Point( 116, 127 ), new ur.Point( 117, 125 ), new ur.Point( 119, 122 ), new ur.Point( 121, 121 ), new ur.Point( 123, 120 ), new ur.Point( 125, 122 ), new ur.Point( 125, 125 ), new ur.Point( 127, 130 ), new ur.Point( 128, 133 ), new ur.Point( 131, 143 ), new ur.Point( 136, 153 ), new ur.Point( 140, 163 ), new ur.Point( 144, 172 ), new ur.Point( 145, 175 ), new ur.Point( 151, 189 ), new ur.Point( 156, 201 ), new ur.Point( 161, 213 ), new ur.Point( 166, 225 ), new ur.Point( 169, 233 ), new ur.Point( 171, 236 ), new ur.Point( 174, 243 ), new ur.Point( 177, 247 ), new ur.Point( 178, 249 ), new ur.Point( 179, 251 ), new ur.Point( 180, 253 ), new ur.Point( 180, 255 ), new ur.Point( 179, 257 ), new ur.Point( 177, 257 ), new ur.Point( 174, 255 ), new ur.Point( 169, 250 ), new ur.Point( 164, 247 ), new ur.Point( 160, 245 ), new ur.Point( 149, 238 ), new ur.Point( 138, 230 ), new ur.Point( 127, 221 ), new ur.Point( 124, 220 ), new ur.Point( 112, 212 ), new ur.Point( 110, 210 ), new ur.Point( 96, 201 ), new ur.Point( 84, 195 ), new ur.Point( 74, 190 ), new ur.Point( 64, 182 ), new ur.Point( 55, 175 ), new ur.Point( 51, 172 ), new ur.Point( 49, 170 ), new ur.Point( 51, 169 ), new ur.Point( 56, 169 ), new ur.Point( 66, 169 ), new ur.Point( 78, 168 ), new ur.Point( 92, 166 ), new ur.Point( 107, 164 ), new ur.Point( 123, 161 ), new ur.Point( 140, 162 ), new ur.Point( 156, 162 ), new ur.Point( 171, 160 ), new ur.Point( 173, 160 ), new ur.Point( 186, 160 ), new ur.Point( 195, 160 ), new ur.Point( 198, 161 ), new ur.Point( 203, 163 ), new ur.Point( 208, 163 ), new ur.Point( 206, 164 ), new ur.Point( 200, 167 ), new ur.Point( 187, 172 ), new ur.Point( 174, 179 ), new ur.Point( 172, 181 ), new ur.Point( 153, 192 ), new ur.Point( 137, 201 ), new ur.Point( 123, 211 ), new ur.Point( 112, 220 ), new ur.Point( 99, 229 ), new ur.Point( 90, 237 ), new ur.Point( 80, 244 ), new ur.Point( 73, 250 ), new ur.Point( 69, 254 ), new ur.Point( 69, 252 ) ) );
54 | this.gestureUtil.addGesture( "pigtail",
55 | new Array( new ur.Point( 81, 219 ), new ur.Point( 84, 218 ), new ur.Point( 86, 220 ), new ur.Point( 88, 220 ), new ur.Point( 90, 220 ), new ur.Point( 92, 219 ), new ur.Point( 95, 220 ), new ur.Point( 97, 219 ), new ur.Point( 99, 220 ), new ur.Point( 102, 218 ), new ur.Point( 105, 217 ), new ur.Point( 107, 216 ), new ur.Point( 110, 216 ), new ur.Point( 113, 214 ), new ur.Point( 116, 212 ), new ur.Point( 118, 210 ), new ur.Point( 121, 208 ), new ur.Point( 124, 205 ), new ur.Point( 126, 202 ), new ur.Point( 129, 199 ), new ur.Point( 132, 196 ), new ur.Point( 136, 191 ), new ur.Point( 139, 187 ), new ur.Point( 142, 182 ), new ur.Point( 144, 179 ), new ur.Point( 146, 174 ), new ur.Point( 148, 170 ), new ur.Point( 149, 168 ), new ur.Point( 151, 162 ), new ur.Point( 152, 160 ), new ur.Point( 152, 157 ), new ur.Point( 152, 155 ), new ur.Point( 152, 151 ), new ur.Point( 152, 149 ), new ur.Point( 152, 146 ), new ur.Point( 149, 142 ), new ur.Point( 148, 139 ), new ur.Point( 145, 137 ), new ur.Point( 141, 135 ), new ur.Point( 139, 135 ), new ur.Point( 134, 136 ), new ur.Point( 130, 140 ), new ur.Point( 128, 142 ), new ur.Point( 126, 145 ), new ur.Point( 122, 150 ), new ur.Point( 119, 158 ), new ur.Point( 117, 163 ), new ur.Point( 115, 170 ), new ur.Point( 114, 175 ), new ur.Point( 117, 184 ), new ur.Point( 120, 190 ), new ur.Point( 125, 199 ), new ur.Point( 129, 203 ), new ur.Point( 133, 208 ), new ur.Point( 138, 213 ), new ur.Point( 145, 215 ), new ur.Point( 155, 218 ), new ur.Point( 164, 219 ), new ur.Point( 166, 219 ), new ur.Point( 177, 219 ), new ur.Point( 182, 218 ), new ur.Point( 192, 216 ), new ur.Point( 196, 213 ), new ur.Point( 199, 212 ), new ur.Point( 201, 211 ) ) );
56 | }
57 |
58 | addEvent( target ):void {
59 | target.addEventListener( egret.TouchEvent.TOUCH_BEGIN, this.mouseDown, this );
60 | target.addEventListener( egret.TouchEvent.TOUCH_END, this.mouseUp, this );
61 | target.addEventListener( egret.TouchEvent.TOUCH_MOVE, this.mouseMove, this );
62 | }
63 |
64 | //响应函数
65 | private mouseDown( evt:egret.TouchEvent ) {
66 | this._layer.graphics.clear();
67 | var p:ur.Point = new ur.Point( evt.stageX, evt.stageY );
68 | this._currentPoint = p;
69 | this._mousePoints = [];
70 | this._mousePoints.push( p );
71 | }
72 |
73 | private mouseMove( evt:egret.TouchEvent ) {
74 | var p:ur.Point = new ur.Point( evt.stageX, evt.stageY );
75 | this._mousePoints.push( p );
76 | this._layer.graphics.lineStyle( 5, 0xffffff );
77 | this._layer.graphics.moveTo( this._currentPoint.x, this._currentPoint.y );
78 | this._layer.graphics.lineTo( p.x, p.y );
79 | this._layer.graphics.endFill();
80 | this._currentPoint = p;
81 | }
82 |
83 | private mouseUp( evt:egret.TouchEvent ) {
84 | this._mousePoints.push( new ur.Point( evt.stageX, evt.stageY ) );
85 | let start = new Date();
86 | egret.log('===================');
87 | let result = this.gestureUtil.recognize( this._mousePoints, false );
88 | egret.log( 'time ==>', new Date().getTime() - start.getTime() );
89 | egret.log( 'name:', result.name, 'score:', result.score );
90 | }
91 |
92 | }
--------------------------------------------------------------------------------