circle_origin.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /*
  2. * @Author: YuMS
  3. * @Date: 2014-08-14 01:49:45
  4. * @Last Modified by: YuMS
  5. * @Last Modified time: 2014-08-17 07:20:26
  6. */
  7. var VERSION = '1.0.4';
  8. // window size
  9. var viewWidth = view.viewSize.width;
  10. var viewHeight = view.viewSize.height;
  11. var windowWidth = viewWidth;
  12. var windowHeight = viewHeight;
  13. var windowMin = Math.min(windowWidth, windowHeight);
  14. var windowMax = Math.max(windowWidth, windowHeight);
  15. // component sizes
  16. var perfectTextPosY = windowHeight / 5.5;
  17. var perfectTextFontSize = windowHeight / 15;
  18. var helpTextFontSize = windowHeight / 30;
  19. var rankTextFontSize = windowHeight / 30;
  20. var versionTextFontSize = windowHeight / 70;
  21. var menuWidth = windowMin / 1.1;
  22. var menuHeight = windowHeight / 2.5;
  23. var menuStrokeWidth = windowHeight / 100;
  24. var slideStrokeWidth = windowHeight / 200;
  25. var replayWidth = windowHeight / 25;
  26. var replayPosY = windowHeight / 2;
  27. var menuButtonWidth = windowHeight / 10;
  28. var menuButtonHeight = windowHeight / 15;
  29. var helpWidth = windowMin / 1.2;
  30. var helpHeight = windowHeight / 2;
  31. var arrowWidth = windowMin / 8;
  32. var arrowHeight = windowMin / 6;
  33. var arrowTextFontSize = windowHeight / 30;
  34. var tutorialWidth = windowMin / 2;
  35. var tutorialHeight = windowMin / 10;
  36. var tutorialStrokeWidth = windowMin / 150;
  37. var tutorialTextFontSize = windowMin / 30;
  38. var maxCircleRadius = windowMin * 0.45;
  39. var pinRadius = windowMin / 180;
  40. // div 2 sizes
  41. var windowWidth2 = windowWidth / 2;
  42. var windowHeight2 = windowHeight / 2;
  43. var viewWidth2 = viewWidth / 2;
  44. var viewHeight2 = viewHeight / 2;
  45. var pinRadius2 = pinRadius / 2;
  46. var menuWidth2 = menuWidth / 2;
  47. var menuHeight2 = menuHeight / 2;
  48. var menuStrokeWidth2 = menuStrokeWidth / 2;
  49. var menuButtonWidth2 = menuButtonWidth / 2;
  50. var menuButtonHeight2 = menuButtonHeight / 2;
  51. var helpWidth2 = helpWidth / 2;
  52. var helpHeight2 = helpHeight / 2;
  53. var arrowWidth2 = arrowWidth / 2;
  54. var arrowHeight2 = arrowHeight / 2;
  55. var tutorialWidth2 = tutorialWidth / 2;
  56. var tutorialHeight2 = tutorialHeight / 2;
  57. // size instances
  58. var windowSize = new Size(windowWidth - 1, windowHeight - 1);
  59. var menuSize = new Size(menuWidth, menuHeight);
  60. var menuButtonSize = new Size(menuButtonWidth, menuButtonHeight);
  61. var helpSize = new Size(helpWidth, helpHeight);
  62. var tutorialSize = new Size(tutorialWidth, tutorialHeight);
  63. // points
  64. var centerPoint = new Point(viewWidth2, viewHeight2);
  65. // bias
  66. var menuButtonBiasX = windowHeight / 6;
  67. var menuButtonBiasY = windowHeight / 4.8;
  68. var maxRandomBias = windowHeight / 20;
  69. var minRandomBias = windowHeight / 200;
  70. var helpBiasY = windowHeight / 3;
  71. var rankBiasY = 0;
  72. var arrowBiasX = windowMin / 20;
  73. var versionBiasX = windowMin / 5;
  74. var tutorialBiasY = windowHeight / 2.5;
  75. var rotateFactor = 200;
  76. // settings
  77. var shared = getCookie('shared').length;
  78. var isiphone = getCookie('isiphone').length;
  79. var circle_played = parseInt(getCookie('circle_played'));
  80. if (!circle_played) {
  81. circle_played = 0;
  82. }
  83. // uuid
  84. if (!getCookie('uuid')) {
  85. setCookie('uuid', uuid());
  86. }
  87. // init status
  88. var nameSubmitted = false;
  89. var percentage = '0%';
  90. var status = 0;
  91. var loadedAd = false;
  92. var circleRadius = (Math.random() + 2) / 3 * maxCircleRadius;
  93. var hintLineRotated = 0;
  94. var perfection = 1;
  95. var positionList = Array();
  96. var drawed = null;
  97. var simplified = null;
  98. var saved = false;
  99. var intersections = [];
  100. // log info
  101. // components instances
  102. try {
  103. var back_rect = new Path.Rectangle(new Point(1, 1), windowSize);
  104. back_rect.fillColor = 'white';
  105. } catch(err) {
  106. /* $.ajax({
  107. type: 'POST',
  108. url: '/circle',
  109. data: {unsupport: 1, UA: navigator.appVersion, cookies: document.cookie}
  110. });*/
  111. alert('抱歉,本游戏暂不支持您的浏览器。');
  112. }
  113. // circle related
  114. var center = new Shape.Circle(centerPoint, pinRadius);
  115. center.fillColor = 'grey';
  116. var hintCircle = new Path.Circle(centerPoint, circleRadius);
  117. hintCircle.strokeColor = 'blue';
  118. var hintRadiusLine = new Path.Line(centerPoint, new Point(viewWidth2 - circleRadius, viewHeight2));
  119. hintRadiusLine.strokeColor = 'black';
  120. hintRadiusLine.rotate(120, centerPoint);
  121. var hintLongLine = new Path.Line(centerPoint, new Point(viewWidth2 - windowMax, viewHeight2));
  122. hintLongLine.rotate(120, centerPoint);
  123. var perfectText = new PointText({
  124. point: [viewWidth2, perfectTextPosY],
  125. justification: 'center',
  126. fillColor: 'black',
  127. fontSize: perfectTextFontSize
  128. });
  129. var versionText = new PointText({
  130. point: [viewWidth2, viewHeight - 0.5 * versionTextFontSize - slideStrokeWidth],
  131. justification: 'center',
  132. fillColor: 'black',
  133. fontSize: versionTextFontSize,
  134. content: '最好的游戏就在68微游戏!'
  135. });
  136. // help part
  137. var helpBox = new Shape.Rectangle({
  138. point: [viewWidth2 - helpWidth2, helpBiasY - helpHeight2],
  139. size: helpSize,
  140. strokeColor: 'black',
  141. fillColor: 'white',
  142. strokeJoin: 'round',
  143. strokeWidth: menuStrokeWidth
  144. });
  145. var helpText = new PointText({
  146. point: [viewWidth2, helpBiasY - 3.5 * helpTextFontSize],
  147. justification: 'center',
  148. fillColor: 'black',
  149. fontSize: helpTextFontSize
  150. });
  151. helpText.content = '画个圆\n\n重大更新:现在可以分享自己\n画的圆给好友了\n\n喏,圆心给你了,半径给你了。\n\n点此开始';
  152. var helpGroup = new Group(helpBox, helpText);
  153. helpBox.onMouseUp = function(event) {
  154. event.preventDefault();
  155. helpGroup.visible = false;
  156. versionText.visible = false;
  157. status = 1;
  158. };
  159. helpText.onMouseUp = function(event) {
  160. event.preventDefault();
  161. helpGroup.visible = false;
  162. versionText.visible = false;
  163. status = 1;
  164. };
  165. // menu group
  166. var menuBox = new Shape.Rectangle({
  167. point: [viewWidth2 - menuWidth2, viewHeight2 - menuHeight2],
  168. size: menuSize,
  169. strokeColor: 'black',
  170. fillColor: 'white',
  171. strokeJoin: 'round',
  172. strokeWidth: menuStrokeWidth
  173. });
  174. var replayButton = new Path.Circle(new Point(viewWidth2 - menuButtonBiasX, viewHeight2 + menuButtonBiasY), menuButtonWidth2);
  175. replayButton.fillColor = 'white';
  176. var replaySVG = new Path.Circle(new Point(viewWidth2 - menuButtonBiasX, viewHeight2 + menuButtonBiasY), menuButtonWidth2);
  177. replaySVG = replaySVG.split(replaySVG.length * 0.55);
  178. replaySVG.strokeColor = 'red';
  179. replaySVG.strokeWidth = menuStrokeWidth;
  180. replaySVG.strokeCap = 'round';
  181. replaySVG.firstSegment.point -= [menuStrokeWidth, menuStrokeWidth2];
  182. replaySVG.lastSegment.remove();
  183. replaySVG.lastSegment.point += [menuStrokeWidth2, menuStrokeWidth2];
  184. var shareButton = new Path.Rectangle(new Point(viewWidth2 + menuButtonBiasX - menuButtonWidth2, viewHeight2 + menuButtonWidth2 - menuButtonHeight + menuButtonBiasY), menuButtonSize);
  185. shareButton.fillColor = 'white';
  186. var shareSVG = new Path.Rectangle(new Point(viewWidth2 + menuButtonBiasX - menuButtonWidth2, viewHeight2 + menuButtonWidth2 - menuButtonHeight + menuButtonBiasY), menuButtonSize);
  187. shareSVG.strokeColor = 'blue';
  188. shareSVG.strokeWidth = menuStrokeWidth;
  189. var shareSVG1 = new Path.Line(new Point(viewWidth2 + menuButtonBiasX, viewHeight2 + menuButtonBiasY), new Point(viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY));
  190. var shareSVG2 = new Path.Line(new Point(viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY), new Point(viewWidth2 + menuButtonBiasX - menuButtonHeight2, viewHeight2 - menuButtonHeight2 + menuButtonBiasY));
  191. var shareSVG3 = new Path.Line(new Point(viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY), new Point(viewWidth2 + menuButtonBiasX + menuButtonHeight2, viewHeight2 - menuButtonHeight2 + menuButtonBiasY));
  192. shareSVG1.strokeColor = 'blue';
  193. shareSVG1.strokeWidth = menuStrokeWidth;
  194. shareSVG2.strokeColor = 'blue';
  195. shareSVG2.strokeWidth = menuStrokeWidth;
  196. shareSVG2.strokeCap = 'round';
  197. shareSVG3.strokeColor = 'blue';
  198. shareSVG3.strokeWidth = menuStrokeWidth;
  199. shareSVG3.strokeCap = 'round';
  200. var rankText = new PointText({
  201. point: [viewWidth2, viewHeight2 + rankBiasY - 2 * rankTextFontSize],
  202. justification: 'center',
  203. fillColor: 'black',
  204. fontSize: rankTextFontSize
  205. });
  206. rankText.content = '';
  207. var menuGroup = new Group(menuBox, replayButton, replaySVG, shareButton, shareSVG, shareSVG1, shareSVG2, shareSVG3, rankText);
  208. menuGroup.visible = false;
  209. // menu related events
  210. replayButton.onMouseUp = function(event) {
  211. event.preventDefault();
  212. init();
  213. };
  214. shareButton.onMouseDown = function(event) {
  215. event.preventDefault();
  216. HideContent('desktop-ad');
  217. // dp_share();
  218. play68_submitScore((perfection * 100).toFixed(2));
  219. if (!saved) {
  220. circleId = uuid();
  221. shareSVG2.rotate(20, [viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY]);
  222. shareSVG3.rotate(-20, [viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY]);
  223. /* $.ajax({
  224. type: 'POST',
  225. url: '/circle/save',
  226. data: {
  227. score: perfection,
  228. simplified: simplified.exportJSON(),
  229. window_min: windowMin,
  230. window_width: windowWidth,
  231. window_height: windowHeight,
  232. circle_id: circleId,
  233. circle_radius: circleRadius,
  234. timestamp: (new Date).getTime(),
  235. user_id: getCookie('uuid')
  236. }
  237. }).done(function() {
  238. window.location.replace('http://games.yumaoshu.com/circle/show?circleId=' + circleId);
  239. });*/
  240. saved = true;
  241. }
  242. };
  243. // tutorial group
  244. var tutorialBox = new Shape.Rectangle({
  245. point: [viewWidth2 - tutorialWidth2, viewHeight2 - tutorialHeight2 + tutorialBiasY],
  246. size: tutorialSize,
  247. strokeColor: 'black',
  248. fillColor: 'white',
  249. strokeJoin: 'round',
  250. strokeWidth: tutorialStrokeWidth
  251. });
  252. var tutorialText = new PointText({
  253. point: [viewWidth2, viewHeight2 + tutorialBiasY + tutorialTextFontSize * 0.5],
  254. justification: 'center',
  255. fillColor: 'black',
  256. fontSize: tutorialTextFontSize
  257. });
  258. tutorialText.content = '更多游戏';
  259. var tutorialGroup = new Group(tutorialBox, tutorialText);
  260. tutorialGroup.visible = false;
  261. // tutorial related events
  262. tutorialBox.onMouseDown = function(event) {
  263. // dp_share();
  264. Play68.goHome();
  265. };
  266. tutorialText.onMouseDown = function(event) {
  267. Play68.goHome();
  268. };
  269. // hint part
  270. var arrowSVG = new Path(
  271. new Segment(
  272. new Point(viewWidth - arrowWidth - arrowBiasX, arrowHeight), null,
  273. new Point(0, -arrowHeight2)
  274. ),
  275. new Segment(
  276. new Point(viewWidth - arrowBiasX, 0), null, null
  277. )
  278. );
  279. arrowSVG.strokeColor = 'blue';
  280. arrowSVG.strokeWidth = menuStrokeWidth;
  281. var arrowText = new PointText({
  282. point: [viewWidth - arrowWidth - arrowBiasX, arrowHeight + arrowTextFontSize],
  283. justification: 'center',
  284. fillColor: 'black',
  285. fontSize: arrowTextFontSize
  286. });
  287. arrowText.content = '分享到朋友圈';
  288. var arrowGroup = new Group(arrowSVG, arrowText);
  289. arrowGroup.visible = false;
  290. function init() {
  291. perfection = 1;
  292. circleRadius = (Math.random() + 2) / 3 * maxCircleRadius;
  293. hintLineRotated = 0;
  294. percentage = '0%';
  295. status = 1;
  296. menuGroup.visible = false;
  297. tutorialGroup.visible = false;
  298. arrowGroup.visible = false;
  299. versionText.visible = false;
  300. HideContent('desktop-ad');
  301. hintLineRotated = 0;
  302. drawed.remove();
  303. drawed = null;
  304. intersections.forEach(function(x) {
  305. x.remove();
  306. })
  307. intersections = [];
  308. hintCircle.remove();
  309. hintCircle = new Path.Circle(centerPoint, circleRadius);
  310. hintCircle.strokeColor = 'blue';
  311. hintRadiusLine.remove();
  312. hintRadiusLine = new Path.Line(centerPoint, new Point(viewWidth2 - circleRadius, viewHeight2));
  313. hintRadiusLine.strokeColor = 'black';
  314. hintRadiusLine.rotate(120, centerPoint);
  315. hintLongLine.remove();
  316. hintLongLine = new Path.Line(centerPoint, new Point(viewWidth2 - windowMax, viewHeight2));
  317. hintLongLine.rotate(120, centerPoint);
  318. simplified.remove();
  319. simplified = null;
  320. perfectText.content = '';
  321. document.title = '画个圆';
  322. }
  323. function uuid(len, radix) {
  324. var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''), uuid = [], i;
  325. radix = radix || chars.length;
  326. if (len) {
  327. // Compact form
  328. for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
  329. } else {
  330. // rfc4122, version 4 form
  331. var r;
  332. // rfc4122 requires these characters
  333. uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
  334. uuid[14] = '4';
  335. // Fill in random data. At i==19 set the high bits of clock sequence as
  336. // per rfc4122, sec. 4.1.5
  337. for (i = 0; i < 36; i++) {
  338. if (!uuid[i]) {
  339. r = 0 | Math.random()*16;
  340. uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
  341. }
  342. }
  343. }
  344. return uuid.join('');
  345. }
  346. function encourage(perfection) {
  347. if (perfection < 0.1) {
  348. return '画的圆,在哪儿呢?。。';
  349. } else if (perfection < 0.5) {
  350. return '我这次画的不是圆。。';
  351. } else if (perfection < 0.7) {
  352. return '看这个圆有种怪怪的感觉。';
  353. } else if (perfection < 0.8) {
  354. return '我这是苗条圆!';
  355. } else if (perfection < 0.9) {
  356. return '我的圆有种自然美。';
  357. } else if (perfection < 0.93) {
  358. return '比达芬奇的鸡蛋要圆了!';
  359. } else if (perfection < 0.94) {
  360. return '就差一点点了!';
  361. } else if (perfection < 0.95) {
  362. return '以后可以不用圆规了!';
  363. } else if (perfection < 0.96) {
  364. return '美术老师我给您磕个头。';
  365. } else if (perfection < 0.97) {
  366. return '我是圆规投胎来的!';
  367. } else if (perfection < 0.98) {
  368. return '手上无圆规,心中有圆规!';
  369. } else if (perfection < 0.99) {
  370. return '我是神手马良!';
  371. } else {
  372. return '我就是完美,完美就是我!';
  373. }
  374. }
  375. function fillRankText() {
  376. rankText.content = '“' + encourage(perfection) + '”\n\n';
  377. rankText.content += '你刚刚画出了一个' + (perfection * 100).toFixed(2) + '分圆!\n快点击下面的蓝色分享\n按钮让小伙伴围观这个圆吧';
  378. updateShare((perfection * 100).toFixed(2));
  379. Play68.setRankingScoreDesc((perfection * 100).toFixed(2));
  380. window.isConfirm=true;
  381. }
  382. function onFrame(event) {
  383. if (event.delta > 0.2) {
  384. event.delta = 0.2;
  385. }
  386. if (status === 0) {
  387. if (!helpText.visible) {
  388. helpText.bringToFront();
  389. helpText.visible = true;
  390. }
  391. if (loading) {
  392. loading = false;
  393. HideContent('inputpage');
  394. }
  395. } else if (status === 1) {
  396. if (hintCircle.visible) {
  397. opacity = hintCircle.opacity - 2 * event.delta;
  398. if (opacity < 0) {
  399. opacity = 0;
  400. hintCircle.visible = false;
  401. }
  402. hintCircle.opacity = opacity;
  403. }
  404. } else if (status === 2) {
  405. if (!hintCircle.visible) {
  406. hintCircle.visible = true;
  407. }
  408. if (hintCircle.opacity < 1) {
  409. opacity = hintCircle.opacity + 2 * event.delta;
  410. if (opacity > 1) {
  411. opacity = 1;
  412. }
  413. hintCircle.opacity = opacity;
  414. } else {
  415. if (hintLineRotated < 359.9) {
  416. rotation = event.delta * rotateFactor;
  417. hintLineRotated += rotation;
  418. if (hintLineRotated > 360) {
  419. rotation = 360 - hintLineRotated + rotation;
  420. hintLineRotated = 360;
  421. }
  422. hintRadiusLine.rotate(rotation, new Point(viewWidth2, viewHeight2));
  423. hintLongLine.rotate(rotation, new Point(viewWidth2, viewHeight2));
  424. var intersectionsDraw = hintLongLine.getIntersections(drawed);
  425. var intersectionsCircle = hintLongLine.getIntersections(hintCircle);
  426. var inter1 = centerPoint;
  427. if (intersectionsDraw.length) {
  428. inter1 = intersectionsDraw[0].point;
  429. }
  430. var inter2 = inter1;
  431. if (intersectionsCircle.length) {
  432. inter2 = intersectionsCircle[0].point;
  433. }
  434. if (!simplified) {
  435. simplified = new Path();
  436. simplified.visible = false;
  437. }
  438. simplified.add(inter1);
  439. var intersectionLine = new Path.Line(inter1, inter2);
  440. intersections.push(intersectionLine);
  441. intersectionLine.strokeWidth = 2;
  442. intersectionLine.strokeColor = 'pink';
  443. var distance = inter1.getDistance(inter2);
  444. perfection -= distance / circleRadius * rotation / 360;
  445. if (perfection < 0) {
  446. perfection = 0;
  447. }
  448. perfectText.content = (perfection * 100).toFixed(2) + '%';
  449. } else {
  450. if (!simplified.visible) {
  451. simplified.closed = true;
  452. simplified.smooth();
  453. simplified.strokeColor = 'black';
  454. simplified.strokeWidth = 2;
  455. simplified.opacity = 0;
  456. simplified.visible = true;
  457. } else if (simplified.opacity < 0.8) {
  458. opacity = simplified.opacity + event.delta;
  459. if (opacity > 1) {
  460. opacity = 1;
  461. }
  462. simplified.opacity = opacity;
  463. drawed.opacity = 1 - opacity;
  464. } else {
  465. // console.log(simplified.exportJSON());
  466. // console.log(simplified.exportJSON().length);
  467. fillRankText();
  468. /*$.ajax({
  469. type: 'POST',
  470. url: '/circle',
  471. data: {UA: navigator.appVersion, score: perfection, cookies: document.cookie}
  472. });*/
  473. circle_played = parseInt(getCookie('circle_played'));
  474. if (!circle_played) {
  475. circle_played = 0;
  476. }
  477. setCookie('circle_played', circle_played + 1);
  478. status = 4;
  479. }
  480. }
  481. }
  482. } else if (status === 4) {
  483. if (!loadedAd) {
  484. if (typeof(startLoadingGoogle) !== 'undefined') {
  485. startLoadingGoogle();
  486. }
  487. loadedAd = true;
  488. }
  489. if (!menuGroup.visible) {
  490. if (circle_played >= 3) {
  491. ShowContent('desktop-ad');
  492. }
  493. menuGroup.bringToFront();
  494. tutorialGroup.bringToFront();
  495. versionText.bringToFront();
  496. menuGroup.opacity = 0;
  497. menuGroup.visible = true;
  498. versionText.opacity = 0;
  499. versionText.visible = true;
  500. tutorialGroup.opacity = 0;
  501. tutorialGroup.visible = true;
  502. }
  503. if (menuGroup.opacity < 1) {
  504. opacity = menuGroup.opacity += 5 * event.delta;
  505. if (opacity > 1) {
  506. opacity = 1;
  507. }
  508. menuGroup.opacity = opacity;
  509. versionText.opacity = opacity;
  510. if (circle_played < 20) {
  511. tutorialGroup.opacity = opacity;
  512. }
  513. }
  514. }
  515. }
  516. function onMouseDown(event) {
  517. if (status === 1) {
  518. if (!drawed) {
  519. drawed = new Path({
  520. segments: [event.point],
  521. strokeColor: 'black',
  522. });
  523. }
  524. } else if (status === 3) {
  525. status = 4;
  526. }
  527. }
  528. function onMouseDrag(event) {
  529. if (status === 1) {
  530. drawed.add(event.point);
  531. }
  532. }
  533. function onMouseUp(event) {
  534. if (status === 1) {
  535. if (drawed) {
  536. status = 2;
  537. }
  538. }
  539. }