not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2051 lines
81 KiB

  1. // Copyright (c) 2014-16 Walter Bender
  2. //
  3. // This program is free software; you can redistribute it and/or
  4. // modify it under the terms of the The GNU Affero General Public
  5. // License as published by the Free Software Foundation; either
  6. // version 3 of the License, or (at your option) any later version.
  7. //
  8. // You should have received a copy of the GNU Affero General Public
  9. // License along with this library; if not, write to the Free Software
  10. // Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
  11. // Definition of basic blocks common to all branches
  12. // Some names changed between the Python verison and the
  13. // JS version so look up name in the conversion dictionary.
  14. var NAMEDICT = {
  15. 'fullscreen': 'vspace',
  16. 'fillscreen2': 'fillscreen',
  17. 'comment': 'print',
  18. 'sandwichclampcollapsed': 'clamp',
  19. 'ifelse': 'ifthenelse',
  20. 'xcor': 'x',
  21. 'ycor': 'y',
  22. 'seth': 'setheading',
  23. 'remainder2': 'mod',
  24. 'plus2': 'plus',
  25. 'product2': 'multiply',
  26. 'division2': 'divide',
  27. 'minus2': 'minus',
  28. 'stack': 'do',
  29. 'hat': 'action',
  30. 'stopstack': 'break',
  31. 'clean': 'clear',
  32. 'setxy2': 'setxy',
  33. 'greater2': 'greater',
  34. 'less2': 'less',
  35. 'equal2': 'equal',
  36. 'random2': 'random',
  37. 'setvalue': 'setshade',
  38. 'setchroma': 'setgrey',
  39. 'setgray': 'setgrey',
  40. 'gray': 'grey',
  41. 'chroma': 'grey',
  42. 'value': 'shade',
  43. 'hue': 'color',
  44. 'startfill': 'beginfill',
  45. 'stopfill': 'endfill',
  46. 'string': 'text',
  47. 'shell': 'turtleshell'
  48. };
  49. // Define blocks here. Note: The blocks are placed on the palettes
  50. // from bottom to top, i.e., the block at the top of a palette will be
  51. // the last block added to a palette.
  52. function initBasicProtoBlocks(palettes, blocks) {
  53. blocks.palettes = palettes;
  54. // TURTLE PALETTE
  55. var headingBlock = new ProtoBlock('heading');
  56. headingBlock.palette = palettes.dict['turtle'];
  57. blocks.protoBlockDict['heading'] = headingBlock;
  58. headingBlock.staticLabels.push(_('heading'));
  59. headingBlock.adjustWidthToLabel();
  60. headingBlock.parameterBlock();
  61. var xBlock = new ProtoBlock('x');
  62. xBlock.palette = palettes.dict['turtle'];
  63. blocks.protoBlockDict['x'] = xBlock;
  64. xBlock.staticLabels.push(_('x'));
  65. xBlock.adjustWidthToLabel();
  66. xBlock.parameterBlock();
  67. var yBlock = new ProtoBlock('y');
  68. yBlock.palette = palettes.dict['turtle'];
  69. blocks.protoBlockDict['y'] = yBlock;
  70. yBlock.staticLabels.push(_('y'));
  71. yBlock.adjustWidthToLabel();
  72. yBlock.parameterBlock();
  73. var clearBlock = new ProtoBlock('clear');
  74. clearBlock.palette = palettes.dict['turtle'];
  75. blocks.protoBlockDict['clear'] = clearBlock;
  76. clearBlock.staticLabels.push(_('clear'));
  77. clearBlock.adjustWidthToLabel();
  78. clearBlock.zeroArgBlock();
  79. var controlPoint2Block = new ProtoBlock('controlpoint2');
  80. controlPoint2Block.palette = palettes.dict['turtle'];
  81. blocks.protoBlockDict['controlpoint2'] = controlPoint2Block;
  82. controlPoint2Block.staticLabels.push(_('control point 2'), _('x'), _('y'));
  83. controlPoint2Block.adjustWidthToLabel();
  84. controlPoint2Block.twoArgBlock();
  85. controlPoint2Block.defaults.push(200);
  86. controlPoint2Block.defaults.push(100);
  87. controlPoint2Block.dockTypes[1] = 'numberin';
  88. controlPoint2Block.dockTypes[2] = 'numberin';
  89. var controlPoint1Block = new ProtoBlock('controlpoint1');
  90. controlPoint1Block.palette = palettes.dict['turtle'];
  91. blocks.protoBlockDict['controlpoint1'] = controlPoint1Block;
  92. controlPoint1Block.staticLabels.push(_('control point 1'), _('x'), _('y'));
  93. controlPoint1Block.adjustWidthToLabel();
  94. controlPoint1Block.twoArgBlock();
  95. controlPoint1Block.defaults.push(0);
  96. controlPoint1Block.defaults.push(100);
  97. controlPoint1Block.dockTypes[1] = 'numberin';
  98. controlPoint1Block.dockTypes[2] = 'numberin';
  99. var bezierBlock = new ProtoBlock('bezier');
  100. bezierBlock.palette = palettes.dict['turtle'];
  101. blocks.protoBlockDict['bezier'] = bezierBlock;
  102. bezierBlock.staticLabels.push(_('bezier'), _('x'), _('y'));
  103. bezierBlock.adjustWidthToLabel();
  104. bezierBlock.twoArgBlock();
  105. bezierBlock.defaults.push(200);
  106. bezierBlock.defaults.push(0);
  107. bezierBlock.dockTypes[1] = 'numberin';
  108. bezierBlock.dockTypes[2] = 'numberin';
  109. var arcBlock = new ProtoBlock('arc');
  110. arcBlock.palette = palettes.dict['turtle'];
  111. blocks.protoBlockDict['arc'] = arcBlock;
  112. arcBlock.staticLabels.push(_('arc'), _('angle'), _('radius'));
  113. arcBlock.adjustWidthToLabel();
  114. arcBlock.twoArgBlock();
  115. arcBlock.defaults.push(90);
  116. arcBlock.defaults.push(100);
  117. arcBlock.dockTypes[1] = 'numberin';
  118. var setheadingBlock = new ProtoBlock('setheading');
  119. setheadingBlock.palette = palettes.dict['turtle'];
  120. blocks.protoBlockDict['setheading'] = setheadingBlock;
  121. setheadingBlock.staticLabels.push(_('set heading'));
  122. setheadingBlock.adjustWidthToLabel();
  123. setheadingBlock.oneArgBlock();
  124. setheadingBlock.defaults.push(0);
  125. var setxyBlock = new ProtoBlock('setxy');
  126. setxyBlock.palette = palettes.dict['turtle'];
  127. blocks.protoBlockDict['setxy'] = setxyBlock;
  128. setxyBlock.staticLabels.push(_('set xy'), _('x'), _('y'));
  129. setxyBlock.adjustWidthToLabel();
  130. setxyBlock.twoArgBlock();
  131. setxyBlock.defaults.push(0);
  132. setxyBlock.defaults.push(0);
  133. setxyBlock.dockTypes[1] = 'numberin';
  134. var rightBlock = new ProtoBlock('right');
  135. rightBlock.palette = palettes.dict['turtle'];
  136. blocks.protoBlockDict['right'] = rightBlock;
  137. rightBlock.staticLabels.push(_('right'));
  138. rightBlock.adjustWidthToLabel();
  139. rightBlock.oneArgBlock();
  140. rightBlock.defaults.push(90);
  141. var leftBlock = new ProtoBlock('left');
  142. leftBlock.palette = palettes.dict['turtle'];
  143. blocks.protoBlockDict['left'] = leftBlock;
  144. leftBlock.staticLabels.push(_('left'));
  145. leftBlock.adjustWidthToLabel();
  146. leftBlock.oneArgBlock();
  147. leftBlock.defaults.push(90);
  148. var backBlock = new ProtoBlock('back');
  149. backBlock.palette = palettes.dict['turtle'];
  150. blocks.protoBlockDict['back'] = backBlock;
  151. backBlock.staticLabels.push(_('back'));
  152. backBlock.adjustWidthToLabel();
  153. backBlock.oneArgBlock();
  154. backBlock.defaults.push(100);
  155. var forwardBlock = new ProtoBlock('forward');
  156. forwardBlock.palette = palettes.dict['turtle'];
  157. blocks.protoBlockDict['forward'] = forwardBlock;
  158. forwardBlock.staticLabels.push(_('forward'));
  159. forwardBlock.adjustWidthToLabel();
  160. forwardBlock.oneArgBlock();
  161. forwardBlock.defaults.push(100);
  162. // PEN PALETTE
  163. var beginFillBlock = new ProtoBlock('beginfill');
  164. beginFillBlock.palette = palettes.dict['pen'];
  165. blocks.protoBlockDict['beginfill'] = beginFillBlock;
  166. beginFillBlock.hidden = true;
  167. beginFillBlock.staticLabels.push(_('begin fill'));
  168. beginFillBlock.adjustWidthToLabel();
  169. beginFillBlock.zeroArgBlock();
  170. var endFillBlock = new ProtoBlock('endfill');
  171. endFillBlock.palette = palettes.dict['pen'];
  172. blocks.protoBlockDict['endfill'] = endFillBlock;
  173. endFillBlock.hidden = true;
  174. endFillBlock.staticLabels.push(_('end fill'));
  175. endFillBlock.adjustWidthToLabel();
  176. endFillBlock.zeroArgBlock();
  177. var fillscreenBlock = new ProtoBlock('fillscreen');
  178. fillscreenBlock.palette = palettes.dict['pen'];
  179. blocks.protoBlockDict['fillscreen'] = fillscreenBlock;
  180. fillscreenBlock.hidden = true;
  181. fillscreenBlock.staticLabels.push(_('background'));
  182. fillscreenBlock.adjustWidthToLabel();
  183. fillscreenBlock.threeArgBlock();
  184. var colorBlock = new ProtoBlock('color');
  185. colorBlock.palette = palettes.dict['pen'];
  186. blocks.protoBlockDict['color'] = colorBlock;
  187. colorBlock.staticLabels.push(_('color'));
  188. colorBlock.adjustWidthToLabel();
  189. colorBlock.parameterBlock();
  190. var shadeBlock = new ProtoBlock('shade');
  191. shadeBlock.palette = palettes.dict['pen'];
  192. blocks.protoBlockDict['shade'] = shadeBlock;
  193. shadeBlock.staticLabels.push(_('shade'));
  194. shadeBlock.adjustWidthToLabel();
  195. shadeBlock.parameterBlock();
  196. var chromaBlock = new ProtoBlock('grey');
  197. chromaBlock.palette = palettes.dict['pen'];
  198. blocks.protoBlockDict['grey'] = chromaBlock;
  199. chromaBlock.staticLabels.push(_('grey'));
  200. chromaBlock.adjustWidthToLabel();
  201. chromaBlock.parameterBlock();
  202. var pensizeBlock = new ProtoBlock('pensize');
  203. pensizeBlock.palette = palettes.dict['pen'];
  204. blocks.protoBlockDict['pensize'] = pensizeBlock;
  205. pensizeBlock.staticLabels.push(_('pen size'));
  206. pensizeBlock.adjustWidthToLabel();
  207. pensizeBlock.parameterBlock();
  208. var setfontBlock = new ProtoBlock('setfont');
  209. setfontBlock.palette = palettes.dict['pen'];
  210. blocks.protoBlockDict['setfont'] = setfontBlock;
  211. setfontBlock.staticLabels.push(_('set font'));
  212. setfontBlock.adjustWidthToLabel();
  213. setfontBlock.oneArgBlock();
  214. setfontBlock.defaults.push(DEFAULTFONT);
  215. setfontBlock.dockTypes[1] = 'textin';
  216. var backgroundBlock = new ProtoBlock('background');
  217. backgroundBlock.palette = palettes.dict['pen'];
  218. blocks.protoBlockDict['background'] = backgroundBlock;
  219. backgroundBlock.staticLabels.push(_('background'));
  220. backgroundBlock.adjustWidthToLabel();
  221. backgroundBlock.zeroArgBlock();
  222. var hollowBlock = new ProtoBlock('hollowline');
  223. hollowBlock.palette = palettes.dict['pen'];
  224. blocks.protoBlockDict['hollowline'] = hollowBlock;
  225. hollowBlock.staticLabels.push(_('hollow line'));
  226. hollowBlock.adjustWidthToLabel();
  227. hollowBlock.flowClampZeroArgBlock();
  228. var fillBlock = new ProtoBlock('fill');
  229. fillBlock.palette = palettes.dict['pen'];
  230. blocks.protoBlockDict['fill'] = fillBlock;
  231. fillBlock.staticLabels.push(_('fill'));
  232. fillBlock.adjustWidthToLabel();
  233. fillBlock.flowClampZeroArgBlock();
  234. var penupBlock = new ProtoBlock('penup');
  235. penupBlock.palette = palettes.dict['pen'];
  236. blocks.protoBlockDict['penup'] = penupBlock;
  237. penupBlock.staticLabels.push(_('pen up'));
  238. penupBlock.adjustWidthToLabel();
  239. penupBlock.zeroArgBlock();
  240. var pendownBlock = new ProtoBlock('pendown');
  241. pendownBlock.palette = palettes.dict['pen'];
  242. blocks.protoBlockDict['pendown'] = pendownBlock;
  243. pendownBlock.staticLabels.push(_('pen down'));
  244. pendownBlock.adjustWidthToLabel();
  245. pendownBlock.zeroArgBlock();
  246. var setpensizeBlock = new ProtoBlock('setpensize');
  247. setpensizeBlock.palette = palettes.dict['pen'];
  248. blocks.protoBlockDict['setpensize'] = setpensizeBlock;
  249. setpensizeBlock.staticLabels.push(_('set pen size'));
  250. setpensizeBlock.adjustWidthToLabel();
  251. setpensizeBlock.oneArgBlock();
  252. setpensizeBlock.defaults.push(5);
  253. var settranslucencyBlock = new ProtoBlock('settranslucency');
  254. settranslucencyBlock.palette = palettes.dict['pen'];
  255. blocks.protoBlockDict['settranslucency'] = settranslucencyBlock;
  256. settranslucencyBlock.staticLabels.push(_('set translucency'));
  257. settranslucencyBlock.adjustWidthToLabel();
  258. settranslucencyBlock.oneArgBlock();
  259. settranslucencyBlock.defaults.push(50);
  260. var sethueBlock = new ProtoBlock('sethue');
  261. sethueBlock.palette = palettes.dict['pen'];
  262. blocks.protoBlockDict['sethue'] = sethueBlock;
  263. sethueBlock.staticLabels.push(_('set hue'));
  264. sethueBlock.adjustWidthToLabel();
  265. sethueBlock.oneArgBlock();
  266. sethueBlock.defaults.push(0);
  267. var setshadeBlock = new ProtoBlock('setshade');
  268. setshadeBlock.palette = palettes.dict['pen'];
  269. blocks.protoBlockDict['setshade'] = setshadeBlock;
  270. setshadeBlock.staticLabels.push(_('set shade'));
  271. setshadeBlock.adjustWidthToLabel();
  272. setshadeBlock.oneArgBlock();
  273. setshadeBlock.defaults.push(50);
  274. var setchromaBlock = new ProtoBlock('setgrey');
  275. setchromaBlock.palette = palettes.dict['pen'];
  276. blocks.protoBlockDict['setgrey'] = setchromaBlock;
  277. setchromaBlock.staticLabels.push(_('set grey'));
  278. setchromaBlock.adjustWidthToLabel();
  279. setchromaBlock.oneArgBlock();
  280. setchromaBlock.defaults.push(100);
  281. var setcolorBlock = new ProtoBlock('setcolor');
  282. setcolorBlock.palette = palettes.dict['pen'];
  283. blocks.protoBlockDict['setcolor'] = setcolorBlock;
  284. setcolorBlock.staticLabels.push(_('set color'));
  285. setcolorBlock.adjustWidthToLabel();
  286. setcolorBlock.oneArgBlock();
  287. setcolorBlock.defaults.push(0);
  288. // NUMBERS PALETTE
  289. var intBlock = new ProtoBlock('int');
  290. intBlock.palette = palettes.dict['number'];
  291. blocks.protoBlockDict['int'] = intBlock;
  292. intBlock.staticLabels.push(_('int'));
  293. intBlock.adjustWidthToLabel();
  294. intBlock.oneArgMathBlock();
  295. intBlock.defaults.push(100)
  296. var greaterBlock = new ProtoBlock('greater');
  297. greaterBlock.palette = palettes.dict['boolean'];
  298. blocks.protoBlockDict['greater'] = greaterBlock;
  299. greaterBlock.fontsize = 14;
  300. greaterBlock.staticLabels.push('>');
  301. greaterBlock.extraWidth = 20;
  302. greaterBlock.booleanTwoArgBlock();
  303. var lessBlock = new ProtoBlock('less');
  304. lessBlock.palette = palettes.dict['boolean'];
  305. blocks.protoBlockDict['less'] = lessBlock;
  306. lessBlock.fontsize = 14;
  307. lessBlock.staticLabels.push('<');
  308. lessBlock.extraWidth = 20;
  309. lessBlock.booleanTwoArgBlock();
  310. var equalBlock = new ProtoBlock('equal');
  311. equalBlock.palette = palettes.dict['boolean'];
  312. blocks.protoBlockDict['equal'] = equalBlock;
  313. equalBlock.fontsize = 14;
  314. equalBlock.staticLabels.push('=');
  315. equalBlock.extraWidth = 20;
  316. equalBlock.booleanTwoArgBlock();
  317. equalBlock.dockTypes[0] = 'booleanout';
  318. equalBlock.dockTypes[1] = 'anyin';
  319. equalBlock.dockTypes[2] = 'anyin';
  320. var andBlock = new ProtoBlock('and');
  321. andBlock.palette = palettes.dict['boolean'];
  322. blocks.protoBlockDict['and'] = andBlock;
  323. andBlock.extraWidth = 10;
  324. andBlock.staticLabels.push(_('and'));
  325. andBlock.booleanTwoBooleanArgBlock();
  326. var orBlock = new ProtoBlock('or');
  327. orBlock.palette = palettes.dict['boolean'];
  328. blocks.protoBlockDict['or'] = orBlock;
  329. orBlock.extraWidth = 10;
  330. orBlock.staticLabels.push(_('or'));
  331. orBlock.booleanTwoBooleanArgBlock();
  332. var notBlock = new ProtoBlock('not');
  333. notBlock.palette = palettes.dict['boolean'];
  334. blocks.protoBlockDict['not'] = notBlock;
  335. notBlock.extraWidth = 30;
  336. notBlock.staticLabels.push(_('not'));
  337. notBlock.booleanOneBooleanArgBlock();
  338. var modBlock = new ProtoBlock('mod');
  339. modBlock.palette = palettes.dict['number'];
  340. blocks.protoBlockDict['mod'] = modBlock;
  341. modBlock.staticLabels.push(_('mod'));
  342. modBlock.adjustWidthToLabel();
  343. modBlock.twoArgMathBlock();
  344. modBlock.defaults.push(100, 10)
  345. var sqrtBlock = new ProtoBlock('sqrt');
  346. sqrtBlock.palette = palettes.dict['number'];
  347. blocks.protoBlockDict['sqrt'] = sqrtBlock;
  348. sqrtBlock.staticLabels.push(_('sqrt'));
  349. sqrtBlock.adjustWidthToLabel();
  350. sqrtBlock.oneArgMathBlock();
  351. sqrtBlock.defaults.push(100)
  352. var divideBlock = new ProtoBlock('divide');
  353. divideBlock.palette = palettes.dict['number'];
  354. blocks.protoBlockDict['divide'] = divideBlock;
  355. divideBlock.fontsize = 14;
  356. divideBlock.staticLabels.push('/');
  357. divideBlock.twoArgMathBlock();
  358. divideBlock.defaults.push(100, 10)
  359. var powerBlock = new ProtoBlock('power');
  360. powerBlock.palette = palettes.dict['number'];
  361. blocks.protoBlockDict['power'] = powerBlock;
  362. powerBlock.fontsize = 14;
  363. powerBlock.staticLabels.push('^');
  364. powerBlock.twoArgMathBlock();
  365. powerBlock.defaults.push(2,4)
  366. var multiplyBlock = new ProtoBlock('multiply');
  367. multiplyBlock.palette = palettes.dict['number'];
  368. blocks.protoBlockDict['multiply'] = multiplyBlock;
  369. multiplyBlock.fontsize = 14;
  370. multiplyBlock.staticLabels.push('×');
  371. multiplyBlock.twoArgMathBlock();
  372. multiplyBlock.defaults.push(10, 10)
  373. var negBlock = new ProtoBlock('neg');
  374. negBlock.palette = palettes.dict['number'];
  375. blocks.protoBlockDict['neg'] = negBlock;
  376. negBlock.fontsize = 14;
  377. negBlock.staticLabels.push('–');
  378. negBlock.oneArgMathBlock();
  379. var minusBlock = new ProtoBlock('minus');
  380. minusBlock.palette = palettes.dict['number'];
  381. blocks.protoBlockDict['minus'] = minusBlock;
  382. minusBlock.fontsize = 14;
  383. minusBlock.staticLabels.push('–');
  384. minusBlock.twoArgMathBlock();
  385. minusBlock.defaults.push(100, 50)
  386. var plusBlock = new ProtoBlock('plus');
  387. plusBlock.palette = palettes.dict['number'];
  388. blocks.protoBlockDict['plus'] = plusBlock;
  389. plusBlock.fontsize = 14;
  390. plusBlock.staticLabels.push('+');
  391. plusBlock.twoArgMathBlock();
  392. plusBlock.dockTypes[0] = 'anyout';
  393. plusBlock.dockTypes[1] = 'anyin';
  394. plusBlock.dockTypes[2] = 'anyin';
  395. plusBlock.defaults.push(100, 100)
  396. var oneOfBlock = new ProtoBlock('oneOf');
  397. oneOfBlock.palette = palettes.dict['number'];
  398. blocks.protoBlockDict['oneOf'] = oneOfBlock;
  399. oneOfBlock.staticLabels.push(_('one of'), _('this'), _('that'));
  400. oneOfBlock.adjustWidthToLabel();
  401. oneOfBlock.twoArgMathBlock();
  402. oneOfBlock.dockTypes[0] = 'anyout';
  403. oneOfBlock.dockTypes[1] = 'anyin';
  404. oneOfBlock.dockTypes[2] = 'anyin';
  405. oneOfBlock.defaults.push(-90, 90);
  406. var randomBlock = new ProtoBlock('random');
  407. randomBlock.palette = palettes.dict['number'];
  408. blocks.protoBlockDict['random'] = randomBlock;
  409. randomBlock.staticLabels.push(_('random'), _('min'), _('max'));
  410. randomBlock.adjustWidthToLabel();
  411. randomBlock.twoArgMathBlock();
  412. randomBlock.defaults.push(0, 100);
  413. var numberBlock = new ProtoBlock('number');
  414. numberBlock.palette = palettes.dict['number'];
  415. blocks.protoBlockDict['number'] = numberBlock;
  416. numberBlock.valueBlock();
  417. // BLOCKS PALETTE
  418. var incrementOneBlock = new ProtoBlock('incrementOne');
  419. incrementOneBlock.palette = palettes.dict['boxes'];
  420. blocks.protoBlockDict['incrementOne'] = incrementOneBlock;
  421. incrementOneBlock.staticLabels.push(_('add 1 to'));
  422. incrementOneBlock.adjustWidthToLabel();
  423. incrementOneBlock.oneArgBlock();
  424. var incrementBlock = new ProtoBlock('increment');
  425. incrementBlock.palette = palettes.dict['boxes'];
  426. blocks.protoBlockDict['increment'] = incrementBlock;
  427. incrementBlock.staticLabels.push(_('add'), _('to'), _('value'));
  428. incrementBlock.adjustWidthToLabel();
  429. incrementBlock.twoArgBlock();
  430. incrementBlock.dockTypes[1] = 'anyin';
  431. incrementBlock.dockTypes[2] = 'anyin';
  432. var boxBlock = new ProtoBlock('box');
  433. boxBlock.palette = palettes.dict['boxes'];
  434. blocks.protoBlockDict['box'] = boxBlock;
  435. boxBlock.staticLabels.push(_('box'));
  436. boxBlock.extraWidth = 10;
  437. boxBlock.adjustWidthToLabel();
  438. boxBlock.oneArgMathBlock();
  439. boxBlock.defaults.push(_('box'));
  440. boxBlock.dockTypes[0] = 'anyout';
  441. // Show the value in the box as if it were a parameter.
  442. boxBlock.parameter = true;
  443. boxBlock.dockTypes[1] = 'anyin';
  444. var storeinBlock = new ProtoBlock('storein');
  445. storeinBlock.palette = palettes.dict['boxes'];
  446. blocks.protoBlockDict['storein'] = storeinBlock;
  447. storeinBlock.staticLabels.push(_('store in'), _('name'), _('value'));
  448. storeinBlock.adjustWidthToLabel();
  449. storeinBlock.twoArgBlock();
  450. storeinBlock.defaults.push(_('box'));
  451. storeinBlock.defaults.push(100);
  452. storeinBlock.dockTypes[1] = 'anyin';
  453. storeinBlock.dockTypes[2] = 'anyin';
  454. var namedBoxBlock = new ProtoBlock('namedbox');
  455. namedBoxBlock.palette = palettes.dict['boxes'];
  456. blocks.protoBlockDict['namedbox'] = namedBoxBlock;
  457. namedBoxBlock.staticLabels.push(_('box'));
  458. namedBoxBlock.extraWidth = 10;
  459. namedBoxBlock.adjustWidthToLabel();
  460. namedBoxBlock.parameterBlock();
  461. namedBoxBlock.dockTypes[0] = 'anyout';
  462. // ACTION PALETTE
  463. var doBlock = new ProtoBlock('do');
  464. doBlock.palette = palettes.dict['action'];
  465. blocks.protoBlockDict['do'] = doBlock;
  466. doBlock.staticLabels.push(_('do'));
  467. doBlock.adjustWidthToLabel();
  468. doBlock.oneArgBlock();
  469. doBlock.defaults.push(_('action'));
  470. doBlock.dockTypes[1] = 'anyin';
  471. var returnBlock = new ProtoBlock('return');
  472. returnBlock.palette = palettes.dict['action'];
  473. blocks.protoBlockDict['return'] = returnBlock;
  474. returnBlock.staticLabels.push(_('return'));
  475. returnBlock.extraWidth = 10;
  476. returnBlock.adjustWidthToLabel();
  477. returnBlock.oneArgBlock();
  478. returnBlock.defaults.push(100);
  479. returnBlock.dockTypes[1] = 'anyin';
  480. var returnToUrlBlock = new ProtoBlock('returnToUrl');
  481. returnToUrlBlock.palette = palettes.dict['action'];
  482. blocks.protoBlockDict['returnToUrl'] = returnToUrlBlock;
  483. returnToUrlBlock.staticLabels.push(_('return to URL'));
  484. returnToUrlBlock.extraWidth = 10;
  485. returnToUrlBlock.adjustWidthToLabel();
  486. returnToUrlBlock.oneArgBlock();
  487. returnToUrlBlock.defaults.push(_('100'));
  488. returnToUrlBlock.dockTypes[1] = 'anyin';
  489. var calcBlock = new ProtoBlock('calc');
  490. calcBlock.palette = palettes.dict['action'];
  491. blocks.protoBlockDict['calc'] = calcBlock;
  492. calcBlock.staticLabels.push(_('calculate'));
  493. calcBlock.adjustWidthToLabel();
  494. calcBlock.oneArgMathBlock();
  495. calcBlock.defaults.push(_('action'));
  496. calcBlock.dockTypes[0] = 'anyout';
  497. calcBlock.dockTypes[1] = 'anyin';
  498. var namedCalcBlock = new ProtoBlock('namedcalc');
  499. namedCalcBlock.palette = palettes.dict['action'];
  500. blocks.protoBlockDict['namedcalc'] = namedCalcBlock;
  501. namedCalcBlock.staticLabels.push(_('action'));
  502. namedCalcBlock.extraWidth = 10;
  503. namedCalcBlock.adjustWidthToLabel();
  504. namedCalcBlock.parameterBlock();
  505. var namedDoArgBlock = new ProtoBlock('nameddoArg');
  506. namedDoArgBlock.palette = palettes.dict['action'];
  507. blocks.protoBlockDict['nameddoArg'] = namedDoArgBlock;
  508. namedDoArgBlock.staticLabels.push(_('do'));
  509. namedDoArgBlock.adjustWidthToLabel();
  510. namedDoArgBlock.argClampBlock();
  511. namedDoArgBlock.dockTypes[1] = 'anyin';
  512. var namedCalcArgBlock = new ProtoBlock('namedcalcArg');
  513. namedCalcArgBlock.palette = palettes.dict['action'];
  514. blocks.protoBlockDict['namedcalcArg'] = namedCalcArgBlock;
  515. namedCalcArgBlock.staticLabels.push(_('calculate'));
  516. namedCalcArgBlock.adjustWidthToLabel();
  517. namedCalcArgBlock.argClampMathBlock();
  518. namedCalcArgBlock.dockTypes[0] = 'anyout';
  519. namedCalcArgBlock.dockTypes[1] = 'anyin';
  520. var doArgBlock = new ProtoBlock('doArg');
  521. doArgBlock.palette = palettes.dict['action'];
  522. blocks.protoBlockDict['doArg'] = doArgBlock;
  523. doArgBlock.staticLabels.push(_('do'));
  524. doArgBlock.adjustWidthToLabel();
  525. doArgBlock.argClampOneArgBlock();
  526. doArgBlock.defaults.push(_('action'));
  527. doArgBlock.dockTypes[1] = 'anyin';
  528. doArgBlock.dockTypes[2] = 'anyin';
  529. var calcArgBlock = new ProtoBlock('calcArg');
  530. calcArgBlock.palette = palettes.dict['action'];
  531. blocks.protoBlockDict['calcArg'] = calcArgBlock;
  532. calcArgBlock.staticLabels.push(_('calculate'));
  533. calcArgBlock.adjustWidthToLabel();
  534. calcArgBlock.argClampOneArgMathBlock();
  535. calcArgBlock.defaults.push(_('action'));
  536. calcArgBlock.dockTypes[0] = 'anyout';
  537. calcArgBlock.dockTypes[1] = 'anyin';
  538. calcArgBlock.dockTypes[2] = 'anyin';
  539. var argBlock = new ProtoBlock('arg');
  540. argBlock.palette = palettes.dict['action'];
  541. blocks.protoBlockDict['arg'] = argBlock;
  542. argBlock.staticLabels.push('arg');
  543. argBlock.adjustWidthToLabel();
  544. argBlock.oneArgMathBlock();
  545. argBlock.defaults.push(1);
  546. argBlock.dockTypes[0] = 'anyout';
  547. argBlock.dockTypes[1] = 'numberin';
  548. var namedArgBlock = new ProtoBlock('namedarg');
  549. namedArgBlock.palette = palettes.dict['action'];
  550. blocks.protoBlockDict['namedarg'] = namedArgBlock;
  551. namedArgBlock.staticLabels.push('arg ' + 1);
  552. namedArgBlock.adjustWidthToLabel();
  553. namedArgBlock.parameterBlock();
  554. var listenBlock = new ProtoBlock('listen');
  555. listenBlock.palette = palettes.dict['action'];
  556. blocks.protoBlockDict['listen'] = listenBlock;
  557. listenBlock.staticLabels.push(_('on'), _('event'), _('do'));
  558. listenBlock.adjustWidthToLabel();
  559. listenBlock.twoArgBlock();
  560. listenBlock.defaults.push(_('event'));
  561. listenBlock.defaults.push(_('action'));
  562. listenBlock.dockTypes[1] = 'textin';
  563. listenBlock.dockTypes[2] = 'textin';
  564. var dispatchBlock = new ProtoBlock('dispatch');
  565. dispatchBlock.palette = palettes.dict['action'];
  566. blocks.protoBlockDict['dispatch'] = dispatchBlock;
  567. dispatchBlock.staticLabels.push(_('broadcast'));
  568. dispatchBlock.adjustWidthToLabel();
  569. dispatchBlock.oneArgBlock();
  570. dispatchBlock.defaults.push(_('event'));
  571. dispatchBlock.dockTypes[1] = 'textin';
  572. var startBlock = new ProtoBlock('start');
  573. startBlock.palette = palettes.dict['action'];
  574. blocks.protoBlockDict['start'] = startBlock;
  575. startBlock.staticLabels.push(_('start'));
  576. startBlock.extraWidth = 10;
  577. startBlock.adjustWidthToLabel();
  578. startBlock.stackClampZeroArgBlock();
  579. var actionBlock = new ProtoBlock('action');
  580. actionBlock.palette = palettes.dict['action'];
  581. blocks.protoBlockDict['action'] = actionBlock;
  582. actionBlock.staticLabels.push(_('action'));
  583. actionBlock.extraWidth = 25;
  584. actionBlock.adjustWidthToLabel();
  585. actionBlock.stackClampOneArgBlock();
  586. actionBlock.defaults.push(_('action'));
  587. var namedDoBlock = new ProtoBlock('nameddo');
  588. namedDoBlock.palette = palettes.dict['action'];
  589. blocks.protoBlockDict['nameddo'] = namedDoBlock;
  590. namedDoBlock.hidden = true;
  591. namedDoBlock.staticLabels.push(_('action'));
  592. namedDoBlock.extraWidth = 10;
  593. namedDoBlock.adjustWidthToLabel();
  594. namedDoBlock.zeroArgBlock();
  595. // HEAP PALETTE
  596. var loadHeapFromApp = new ProtoBlock('loadHeapFromApp');
  597. loadHeapFromApp.palette = palettes.dict['heap'];
  598. blocks.protoBlockDict['loadHeapFromApp'] = loadHeapFromApp;
  599. loadHeapFromApp.staticLabels.push(_('load heap from App'));
  600. loadHeapFromApp.adjustWidthToLabel();
  601. loadHeapFromApp.twoArgBlock();
  602. loadHeapFromApp.dockTypes[1] = 'textin';
  603. loadHeapFromApp.dockTypes[2] = 'textin';
  604. loadHeapFromApp.defaults.push('appName')
  605. loadHeapFromApp.defaults.push('localhost');
  606. var saveHeapToApp = new ProtoBlock('saveHeapToApp');
  607. saveHeapToApp.palette = palettes.dict['heap'];
  608. blocks.protoBlockDict['saveHeapToApp'] = saveHeapToApp;
  609. saveHeapToApp.staticLabels.push(_('save heap to App'));
  610. saveHeapToApp.adjustWidthToLabel();
  611. saveHeapToApp.twoArgBlock();
  612. saveHeapToApp.dockTypes[1] = 'textin';
  613. saveHeapToApp.dockTypes[2] = 'textin';
  614. saveHeapToApp.defaults.push('appName')
  615. saveHeapToApp.defaults.push('localhost');
  616. var setHeapEntry = new ProtoBlock('setHeapEntry');
  617. setHeapEntry.palette = palettes.dict['heap'];
  618. blocks.protoBlockDict['setHeapEntry'] = setHeapEntry;
  619. setHeapEntry.staticLabels.push(_('set heap'), _('index'), _('value'));
  620. setHeapEntry.adjustWidthToLabel();
  621. setHeapEntry.twoArgBlock();
  622. setHeapEntry.dockTypes[1] = 'numberin';
  623. setHeapEntry.dockTypes[2] = 'anyin';
  624. setHeapEntry.defaults.push(1);
  625. setHeapEntry.defaults.push(100);
  626. var showHeap = new ProtoBlock('showHeap');
  627. showHeap.palette = palettes.dict['heap'];
  628. blocks.protoBlockDict['showHeap'] = showHeap;
  629. showHeap.staticLabels.push(_('show heap'));
  630. showHeap.adjustWidthToLabel();
  631. showHeap.zeroArgBlock();
  632. var heapLength = new ProtoBlock('heapLength');
  633. heapLength.palette = palettes.dict['heap'];
  634. blocks.protoBlockDict['heapLength'] = heapLength;
  635. heapLength.staticLabels.push(_('heap length'));
  636. heapLength.adjustWidthToLabel();
  637. heapLength.parameterBlock();
  638. heapLength.dockTypes[0] = 'numberout';
  639. var heapEmpty = new ProtoBlock('heapEmpty');
  640. heapEmpty.palette = palettes.dict['heap'];
  641. blocks.protoBlockDict['heapEmpty'] = heapEmpty;
  642. heapEmpty.staticLabels.push(_('heap empty?'));
  643. heapEmpty.adjustWidthToLabel();
  644. heapEmpty.booleanZeroArgBlock();
  645. var emptyHeap = new ProtoBlock('emptyHeap');
  646. emptyHeap.palette = palettes.dict['heap'];
  647. blocks.protoBlockDict['emptyHeap'] = emptyHeap;
  648. emptyHeap.staticLabels.push(_('empty heap'));
  649. emptyHeap.adjustWidthToLabel();
  650. emptyHeap.zeroArgBlock();
  651. var saveHeap = new ProtoBlock('saveHeap');
  652. saveHeap.palette = palettes.dict['heap'];
  653. blocks.protoBlockDict['saveHeap'] = saveHeap;
  654. saveHeap.staticLabels.push(_('save heap'));
  655. saveHeap.adjustWidthToLabel();
  656. saveHeap.oneArgBlock();
  657. saveHeap.defaults.push('heap.json');
  658. saveHeap.dockTypes[1] = 'textin';
  659. var loadHeap = new ProtoBlock('loadHeap');
  660. loadHeap.palette = palettes.dict['heap'];
  661. blocks.protoBlockDict['loadHeap'] = loadHeap;
  662. loadHeap.staticLabels.push(_('load heap'));
  663. loadHeap.adjustWidthToLabel();
  664. loadHeap.oneArgBlock();
  665. loadHeap.dockTypes[1] = 'filein';
  666. loadHeap.defaults = [[null, null]];
  667. var indexHeap = new ProtoBlock('indexHeap');
  668. indexHeap.palette = palettes.dict['heap'];
  669. blocks.protoBlockDict['indexHeap'] = indexHeap;
  670. indexHeap.staticLabels.push(_('index heap'));
  671. indexHeap.adjustWidthToLabel();
  672. indexHeap.oneArgMathBlock();
  673. indexHeap.dockTypes[1] = 'numberin';
  674. indexHeap.defaults.push(1);
  675. var pushBlk = new ProtoBlock('push');
  676. pushBlk.palette = palettes.dict['heap'];
  677. blocks.protoBlockDict['push'] = pushBlk;
  678. pushBlk.staticLabels.push(_('push'));
  679. pushBlk.adjustWidthToLabel();
  680. pushBlk.oneArgBlock();
  681. pushBlk.dockTypes[1] = 'anyin';
  682. var popBlk = new ProtoBlock('pop');
  683. popBlk.palette = palettes.dict['heap'];
  684. blocks.protoBlockDict['pop'] = popBlk;
  685. popBlk.staticLabels.push(_('pop'));
  686. popBlk.adjustWidthToLabel();
  687. popBlk.parameterBlock();
  688. // MEDIA PALETTE
  689. var speakBlock = new ProtoBlock('speak');
  690. speakBlock.palette = palettes.dict['media'];
  691. blocks.protoBlockDict['speak'] = speakBlock;
  692. speakBlock.staticLabels.push(_('speak'));
  693. speakBlock.adjustWidthToLabel();
  694. speakBlock.oneArgBlock();
  695. speakBlock.defaults.push('hello');
  696. speakBlock.dockTypes[1] = 'textin';
  697. var cameraBlock = new ProtoBlock('camera');
  698. cameraBlock.palette = palettes.dict['media'];
  699. cameraBlock.image = 'images/camera.svg'
  700. blocks.protoBlockDict['camera'] = cameraBlock;
  701. cameraBlock.mediaBlock();
  702. var videoBlock = new ProtoBlock('video');
  703. videoBlock.palette = palettes.dict['media'];
  704. videoBlock.image = 'images/video.svg'
  705. blocks.protoBlockDict['video'] = videoBlock;
  706. videoBlock.mediaBlock();
  707. var loadFile = new ProtoBlock('loadFile');
  708. loadFile.palette = palettes.dict['media'];
  709. blocks.protoBlockDict['loadFile'] = loadFile;
  710. loadFile.staticLabels.push('');
  711. loadFile.parameterBlock();
  712. loadFile.dockTypes[0] = 'fileout';
  713. var stopVideoCamBlock = new ProtoBlock('stopvideocam');
  714. stopVideoCamBlock.palette = palettes.dict['media'];
  715. blocks.protoBlockDict['stopvideocam'] = stopVideoCamBlock;
  716. stopVideoCamBlock.staticLabels.push(_('stop media'));
  717. stopVideoCamBlock.adjustWidthToLabel();
  718. stopVideoCamBlock.zeroArgBlock();
  719. var toneBlock = new ProtoBlock('tone2');
  720. toneBlock.palette = palettes.dict['media'];
  721. blocks.protoBlockDict['tone2'] = toneBlock;
  722. toneBlock.staticLabels.push(_('tone'), _('frequency'), _('duration (ms)'));
  723. toneBlock.adjustWidthToLabel();
  724. toneBlock.defaults.push(440, 200);
  725. toneBlock.twoArgBlock();
  726. toneBlock.dockTypes[1] = 'numberin';
  727. toneBlock.dockTypes[2] = 'numberin';
  728. var toFrequencyBlock = new ProtoBlock('tofrequency');
  729. toFrequencyBlock.palette = palettes.dict['media'];
  730. blocks.protoBlockDict['tofrequency'] = toFrequencyBlock;
  731. toFrequencyBlock.staticLabels.push(_('note to frequency'), _('name'), _('octave'));
  732. toFrequencyBlock.adjustWidthToLabel();
  733. toFrequencyBlock.defaults.push('A');
  734. toFrequencyBlock.defaults.push('4');
  735. toFrequencyBlock.twoArgMathBlock();
  736. toFrequencyBlock.dockTypes[1] = 'anyin';
  737. toFrequencyBlock.dockTypes[2] = 'numberin';
  738. var shellBlock = new ProtoBlock('turtleshell');
  739. shellBlock.palette = palettes.dict['media'];
  740. blocks.protoBlockDict['turtleshell'] = shellBlock;
  741. shellBlock.staticLabels.push(_('shell'), _('size'), _('image'));
  742. shellBlock.adjustWidthToLabel();
  743. shellBlock.twoArgBlock();
  744. shellBlock.defaults.push(55);
  745. shellBlock.defaults.push(null);
  746. shellBlock.dockTypes[1] = 'numberin';
  747. shellBlock.dockTypes[2] = 'mediain';
  748. var showBlock = new ProtoBlock('show');
  749. showBlock.palette = palettes.dict['media'];
  750. blocks.protoBlockDict['show'] = showBlock;
  751. showBlock.staticLabels.push(_('show'), _('size'), _('obj'));
  752. showBlock.adjustWidthToLabel();
  753. showBlock.twoArgBlock();
  754. showBlock.defaults.push(24);
  755. showBlock.defaults.push(_('text'));
  756. showBlock.dockTypes[1] = 'numberin';
  757. showBlock.dockTypes[2] = 'anyin';
  758. var mediaBlock = new ProtoBlock('media');
  759. mediaBlock.palette = palettes.dict['media'];
  760. mediaBlock.image = 'images/load-media.svg'
  761. blocks.protoBlockDict['media'] = mediaBlock;
  762. mediaBlock.mediaBlock();
  763. mediaBlock.dockTypes[0] = 'mediaout';
  764. var textBlock = new ProtoBlock('text');
  765. textBlock.palette = palettes.dict['media'];
  766. blocks.protoBlockDict['text'] = textBlock;
  767. textBlock.valueBlock();
  768. textBlock.dockTypes[0] = 'textout';
  769. // FLOW PALETTE
  770. var hiddenNoFlowBlock = new ProtoBlock('hiddennoflow');
  771. hiddenNoFlowBlock.palette = palettes.dict['flow'];
  772. blocks.protoBlockDict['hiddennoflow'] = hiddenNoFlowBlock;
  773. hiddenNoFlowBlock.hiddenNoFlow = true;
  774. hiddenNoFlowBlock.hiddenBlockNoFlow();
  775. hiddenNoFlowBlock.hidden = true;
  776. var hiddenBlock = new ProtoBlock('hidden');
  777. hiddenBlock.palette = palettes.dict['flow'];
  778. blocks.protoBlockDict['hidden'] = hiddenBlock;
  779. hiddenBlock.hidden = true;
  780. hiddenBlock.hiddenBlockFlow();
  781. var clampBlock = new ProtoBlock('clamp');
  782. clampBlock.palette = palettes.dict['flow'];
  783. blocks.protoBlockDict['clamp'] = clampBlock;
  784. clampBlock.hidden = true;
  785. clampBlock.flowClampBlock();
  786. var breakBlock = new ProtoBlock('break');
  787. breakBlock.palette = palettes.dict['flow'];
  788. blocks.protoBlockDict['break'] = breakBlock;
  789. breakBlock.staticLabels.push(_('stop'));
  790. breakBlock.adjustWidthToLabel();
  791. breakBlock.basicBlockNoFlow();
  792. var waitForBlock = new ProtoBlock('waitFor');
  793. waitForBlock.palette = palettes.dict['flow'];
  794. blocks.protoBlockDict['waitFor'] = waitForBlock;
  795. waitForBlock.staticLabels.push(_('wait for'));
  796. waitForBlock.adjustWidthToLabel();
  797. waitForBlock.oneBooleanArgBlock();
  798. var untilBlock = new ProtoBlock('until');
  799. untilBlock.palette = palettes.dict['flow'];
  800. blocks.protoBlockDict['until'] = untilBlock;
  801. untilBlock.staticLabels.push(_('until'), _('do'));
  802. untilBlock.adjustWidthToLabel();
  803. untilBlock.flowClampBooleanArgBlock();
  804. var whileBlock = new ProtoBlock('while');
  805. whileBlock.palette = palettes.dict['flow'];
  806. blocks.protoBlockDict['while'] = whileBlock;
  807. whileBlock.staticLabels.push(_('while'), _('do'));
  808. whileBlock.adjustWidthToLabel();
  809. whileBlock.flowClampBooleanArgBlock();
  810. var ifthenelseBlock = new ProtoBlock('ifthenelse');
  811. ifthenelseBlock.palette = palettes.dict['flow'];
  812. blocks.protoBlockDict['ifthenelse'] = ifthenelseBlock;
  813. ifthenelseBlock.staticLabels.push(_('if'), _('then'), _('else'));
  814. ifthenelseBlock.adjustWidthToLabel();
  815. ifthenelseBlock.doubleFlowClampBooleanArgBlock();
  816. var ifBlock = new ProtoBlock('if');
  817. ifBlock.palette = palettes.dict['flow'];
  818. blocks.protoBlockDict['if'] = ifBlock;
  819. ifBlock.staticLabels.push(_('if'), _('then'));
  820. ifBlock.adjustWidthToLabel();
  821. ifBlock.flowClampBooleanArgBlock();
  822. var foreverBlock = new ProtoBlock('forever');
  823. foreverBlock.palette = palettes.dict['flow'];
  824. blocks.protoBlockDict['forever'] = foreverBlock;
  825. foreverBlock.staticLabels.push(_('forever'));
  826. foreverBlock.adjustWidthToLabel();
  827. foreverBlock.flowClampZeroArgBlock();
  828. var repeatBlock = new ProtoBlock('repeat');
  829. repeatBlock.palette = palettes.dict['flow'];
  830. blocks.protoBlockDict['repeat'] = repeatBlock;
  831. repeatBlock.staticLabels.push(_('repeat'));
  832. repeatBlock.adjustWidthToLabel();
  833. repeatBlock.flowClampOneArgBlock();
  834. repeatBlock.defaults.push(4);
  835. // EXTRAS PALETTE
  836. // NOP blocks (used as placeholders when loaded blocks not found)
  837. var nopValueBlock = new ProtoBlock('nopValueBlock');
  838. blocks.protoBlockDict['nopValueBlock'] = nopValueBlock;
  839. nopValueBlock.hidden = true;
  840. nopValueBlock.palette = palettes.dict['extras'];
  841. nopValueBlock.staticLabels.push(_('unknown'));
  842. nopValueBlock.adjustWidthToLabel();
  843. nopValueBlock.valueBlock();
  844. nopValueBlock.dockTypes[0] = 'anyout';
  845. /*
  846. var nopOneArgMathBlock = new ProtoBlock('nopOneArgMathBlock');
  847. blocks.protoBlockDict['nopOneArgMathBlock'] = nopOneArgMathBlock;
  848. nopOneArgMathBlock.hidden = true;
  849. nopOneArgMathBlock.palette = palettes.dict['extras'];
  850. nopOneArgMathBlock.oneArgMathBlock();
  851. nopOneArgMathBlock.staticLabels.push(_('unknown'));
  852. nopOneArgMathBlock.dockTypes[0] = 'anyout';
  853. nopOneArgMathBlock.dockTypes[1] = 'anyin';
  854. var nopTwoArgMathBlock = new ProtoBlock('nopTwoArgMathBlock');
  855. blocks.protoBlockDict['nopTwoArgMathBlock'] = nopTwoArgMathBlock;
  856. nopTwoArgMathBlock.twoArgMathBlock();
  857. nopTwoArgMathBlock.hidden = true;
  858. nopTwoArgMathBlock.palette = palettes.dict['extras'];
  859. nopTwoArgMathBlock.staticLabels.push(_('unknown'));
  860. nopTwoArgMathBlock.dockTypes[0] = 'anyout';
  861. nopTwoArgMathBlock.dockTypes[1] = 'anyin';
  862. nopTwoArgMathBlock.dockTypes[2] = 'anyin';
  863. */
  864. var nopZeroArgBlock = new ProtoBlock('nopZeroArgBlock');
  865. blocks.protoBlockDict['nopZeroArgBlock'] = nopZeroArgBlock;
  866. nopZeroArgBlock.hidden = true;
  867. nopZeroArgBlock.palette = palettes.dict['extras'];
  868. nopZeroArgBlock.staticLabels.push(_('unknown'));
  869. nopZeroArgBlock.adjustWidthToLabel();
  870. nopZeroArgBlock.zeroArgBlock();
  871. var nopOneArgBlock = new ProtoBlock('nopOneArgBlock');
  872. blocks.protoBlockDict['nopOneArgBlock'] = nopOneArgBlock;
  873. nopOneArgBlock.hidden = true;
  874. nopOneArgBlock.palette = palettes.dict['extras'];
  875. nopOneArgBlock.staticLabels.push(_('unknown'));
  876. nopOneArgBlock.adjustWidthToLabel();
  877. nopOneArgBlock.oneArgBlock();
  878. nopOneArgBlock.dockTypes[1] = 'anyin';
  879. var nopTwoArgBlock = new ProtoBlock('nopTwoArgBlock');
  880. blocks.protoBlockDict['nopTwoArgBlock'] = nopTwoArgBlock;
  881. nopTwoArgBlock.hidden = true;
  882. nopTwoArgBlock.palette = palettes.dict['extras'];
  883. nopTwoArgBlock.staticLabels.push(_('unknown'));
  884. nopTwoArgBlock.adjustWidthToLabel();
  885. nopTwoArgBlock.twoArgBlock();
  886. nopTwoArgBlock.dockTypes[1] = 'anyin';
  887. nopTwoArgBlock.dockTypes[2] = 'anyin';
  888. var nopThreeArgBlock = new ProtoBlock('nopThreeArgBlock');
  889. blocks.protoBlockDict['nopThreeArgBlock'] = nopThreeArgBlock;
  890. nopThreeArgBlock.hidden = true;
  891. nopThreeArgBlock.palette = palettes.dict['extras'];
  892. nopThreeArgBlock.staticLabels.push(_('unknown'));
  893. nopThreeArgBlock.adjustWidthToLabel();
  894. nopThreeArgBlock.threeArgBlock();
  895. nopThreeArgBlock.dockTypes[1] = 'anyin';
  896. nopThreeArgBlock.dockTypes[2] = 'anyin';
  897. nopThreeArgBlock.dockTypes[3] = 'anyin';
  898. var audioBlock = new ProtoBlock('playback');
  899. audioBlock.palette = palettes.dict['extras'];
  900. blocks.protoBlockDict['playback'] = audioBlock;
  901. audioBlock.defaults.push(null);
  902. audioBlock.staticLabels.push(_('play back'));
  903. audioBlock.adjustWidthToLabel();
  904. audioBlock.oneArgBlock();
  905. audioBlock.dockTypes[1] = 'mediain';
  906. var audioStopBlock = new ProtoBlock('stopplayback');
  907. audioStopBlock.palette = palettes.dict['extras'];
  908. blocks.protoBlockDict['stopplayback'] = audioStopBlock;
  909. audioStopBlock.staticLabels.push(_('stop play'));
  910. audioStopBlock.adjustWidthToLabel();
  911. audioStopBlock.zeroArgBlock();
  912. var svgBlock = new ProtoBlock('savesvg');
  913. svgBlock.palette = palettes.dict['extras'];
  914. blocks.protoBlockDict['savesvg'] = svgBlock;
  915. svgBlock.staticLabels.push(_('save svg'));
  916. svgBlock.adjustWidthToLabel();
  917. svgBlock.oneArgBlock();
  918. svgBlock.defaults.push(_('title') + '.svg');
  919. svgBlock.dockTypes[1] = 'textin';
  920. var publishBlock = new ProtoBlock('publish');
  921. publishBlock.palette = palettes.dict['extras'];
  922. blocks.protoBlockDict['publish'] = publishBlock;
  923. publishBlock.staticLabels.push(_('publish to Facebook'));
  924. publishBlock.adjustWidthToLabel();
  925. publishBlock.oneArgBlock();
  926. publishBlock.defaults.push(_('title'));
  927. publishBlock.dockTypes[1] = 'textin';
  928. publishBlock.hidden = true;
  929. var getyTurtleBlock = new ProtoBlock('yturtle');
  930. getyTurtleBlock.palette = palettes.dict['extras'];
  931. blocks.protoBlockDict['yturtle'] = getyTurtleBlock;
  932. getyTurtleBlock.staticLabels.push(_('turtle y'));
  933. getyTurtleBlock.adjustWidthToLabel();
  934. getyTurtleBlock.oneArgMathBlock();
  935. getyTurtleBlock.dockTypes[1] = 'anyin';
  936. getyTurtleBlock.defaults.push('0');
  937. var getxTurtleBlock = new ProtoBlock('xturtle');
  938. getxTurtleBlock.palette = palettes.dict['extras'];
  939. blocks.protoBlockDict['xturtle'] = getxTurtleBlock;
  940. getxTurtleBlock.staticLabels.push(_('turtle x'));
  941. getxTurtleBlock.adjustWidthToLabel();
  942. getxTurtleBlock.oneArgMathBlock();
  943. getxTurtleBlock.dockTypes[1] = 'anyin';
  944. getxTurtleBlock.defaults.push('0');
  945. var startTurtleBlock = new ProtoBlock('startTurtle');
  946. startTurtleBlock.palette = palettes.dict['extras'];
  947. blocks.protoBlockDict['startTurtle'] = startTurtleBlock;
  948. startTurtleBlock.staticLabels.push(_('start turtle'));
  949. startTurtleBlock.adjustWidthToLabel();
  950. startTurtleBlock.oneArgBlock();
  951. startTurtleBlock.dockTypes[1] = 'anyin';
  952. startTurtleBlock.defaults.push('0');
  953. var stopTurtleBlock = new ProtoBlock('stopTurtle');
  954. stopTurtleBlock.palette = palettes.dict['extras'];
  955. blocks.protoBlockDict['stopTurtle'] = stopTurtleBlock;
  956. stopTurtleBlock.staticLabels.push(_('stop turtle'));
  957. stopTurtleBlock.adjustWidthToLabel();
  958. stopTurtleBlock.oneArgBlock();
  959. stopTurtleBlock.dockTypes[1] = 'anyin';
  960. stopTurtleBlock.defaults.push('0');
  961. var noBackgroundBlock = new ProtoBlock('nobackground');
  962. blocks.protoBlockDict['nobackground'] = noBackgroundBlock;
  963. noBackgroundBlock.palette = palettes.dict['extras'];
  964. noBackgroundBlock.staticLabels.push(_('no background'));
  965. noBackgroundBlock.adjustWidthToLabel();
  966. noBackgroundBlock.zeroArgBlock();
  967. var showBlocks = new ProtoBlock('showblocks');
  968. showBlocks.palette = palettes.dict['extras'];
  969. blocks.protoBlockDict['showblocks'] = showBlocks;
  970. showBlocks.staticLabels.push(_('show blocks'));
  971. showBlocks.adjustWidthToLabel();
  972. showBlocks.zeroArgBlock();
  973. var hideBlocks = new ProtoBlock('hideblocks');
  974. hideBlocks.palette = palettes.dict['extras'];
  975. blocks.protoBlockDict['hideblocks'] = hideBlocks;
  976. hideBlocks.staticLabels.push(_('hide blocks'));
  977. hideBlocks.adjustWidthToLabel();
  978. hideBlocks.zeroArgBlock();
  979. var openProjectBlock = new ProtoBlock('openProject');
  980. openProjectBlock.palette = palettes.dict['extras'];
  981. blocks.protoBlockDict['openProject'] = openProjectBlock;
  982. openProjectBlock.staticLabels.push(_('open project'));
  983. openProjectBlock.adjustWidthToLabel();
  984. openProjectBlock.oneArgBlock();
  985. openProjectBlock.defaults.push('url');
  986. openProjectBlock.dockTypes[1] = 'textin';
  987. var vspaceBlock = new ProtoBlock('vspace');
  988. vspaceBlock.palette = palettes.dict['extras'];
  989. blocks.protoBlockDict['vspace'] = vspaceBlock;
  990. vspaceBlock.staticLabels.push('↓');
  991. vspaceBlock.extraWidth = -10;
  992. vspaceBlock.zeroArgBlock();
  993. var hspaceBlock = new ProtoBlock('hspace');
  994. hspaceBlock.palette = palettes.dict['extras'];
  995. blocks.protoBlockDict['hspace'] = hspaceBlock;
  996. hspaceBlock.oneArgMathBlock();
  997. hspaceBlock.staticLabels.push('←');
  998. hspaceBlock.dockTypes[0] = 'anyout';
  999. hspaceBlock.dockTypes[1] = 'anyin';
  1000. var waitBlock = new ProtoBlock('wait');
  1001. waitBlock.palette = palettes.dict['extras'];
  1002. blocks.protoBlockDict['wait'] = waitBlock;
  1003. waitBlock.staticLabels.push(_('wait'));
  1004. waitBlock.adjustWidthToLabel();
  1005. waitBlock.oneArgBlock();
  1006. waitBlock.defaults.push(1);
  1007. var printBlock = new ProtoBlock('print');
  1008. printBlock.palette = palettes.dict['extras'];
  1009. blocks.protoBlockDict['print'] = printBlock;
  1010. printBlock.staticLabels.push(_('print'));
  1011. printBlock.adjustWidthToLabel();
  1012. printBlock.oneArgBlock();
  1013. printBlock.dockTypes[1] = 'anyin';
  1014. var turtleNameBlock = new ProtoBlock('turtlename');
  1015. turtleNameBlock.palette = palettes.dict['extras'];
  1016. blocks.protoBlockDict['turtlename'] = turtleNameBlock;
  1017. turtleNameBlock.staticLabels.push(_('turtle name'));
  1018. turtleNameBlock.adjustWidthToLabel();
  1019. turtleNameBlock.parameterBlock();
  1020. turtleNameBlock.dockTypes[0] = 'textout';
  1021. var setTurtleName = new ProtoBlock('setturtlename');
  1022. setTurtleName.palette = palettes.dict['extras'];
  1023. blocks.protoBlockDict['setturtlename'] = setTurtleName;
  1024. setTurtleName.staticLabels.push(_('turtle name'));
  1025. setTurtleName.staticLabels.push(_('source'));
  1026. setTurtleName.staticLabels.push(_('target'));
  1027. setTurtleName.adjustWidthToLabel();
  1028. setTurtleName.twoArgBlock();
  1029. setTurtleName.dockTypes[1] = 'anyin';
  1030. setTurtleName.dockTypes[2] = 'anyin';
  1031. setTurtleName.defaults.push('0');
  1032. setTurtleName.defaults.push('Yertle');
  1033. var statusBlock = new ProtoBlock('status');
  1034. statusBlock.palette = palettes.dict['extras'];
  1035. blocks.protoBlockDict['status'] = statusBlock;
  1036. statusBlock.staticLabels.push(_('status'));
  1037. statusBlock.adjustWidthToLabel();
  1038. statusBlock.stackClampZeroArgBlock();
  1039. // SENSORS PALETTE
  1040. var loudnessBlock = new ProtoBlock('loudness');
  1041. loudnessBlock.palette = palettes.dict['sensors'];
  1042. blocks.protoBlockDict['loudness'] = loudnessBlock;
  1043. loudnessBlock.staticLabels.push(_('loudness'));
  1044. loudnessBlock.adjustWidthToLabel();
  1045. loudnessBlock.parameterBlock();
  1046. // Turtle-specific click event
  1047. var myClickBlock = new ProtoBlock('myclick');
  1048. myClickBlock.palette = palettes.dict['sensors'];
  1049. blocks.protoBlockDict['myclick'] = myClickBlock;
  1050. myClickBlock.staticLabels.push(_('click'));
  1051. myClickBlock.adjustWidthToLabel();
  1052. myClickBlock.parameterBlock();
  1053. myClickBlock.dockTypes[0] = 'textout';
  1054. var getBlue = new ProtoBlock('getblue');
  1055. getBlue.palette = palettes.dict['sensors'];
  1056. blocks.protoBlockDict['getblue'] = getBlue;
  1057. getBlue.staticLabels.push(_('blue'));
  1058. getBlue.adjustWidthToLabel();
  1059. getBlue.parameterBlock();
  1060. var getGreen = new ProtoBlock('getgreen');
  1061. getGreen.palette = palettes.dict['sensors'];
  1062. blocks.protoBlockDict['getgreen'] = getGreen;
  1063. getGreen.staticLabels.push(_('green'));
  1064. getGreen.adjustWidthToLabel();
  1065. getGreen.parameterBlock();
  1066. var getRed = new ProtoBlock('getred');
  1067. getRed.palette = palettes.dict['sensors'];
  1068. blocks.protoBlockDict['getred'] = getRed;
  1069. getRed.staticLabels.push(_('red'));
  1070. getRed.adjustWidthToLabel();
  1071. getRed.parameterBlock();
  1072. var getColorPixel = new ProtoBlock('getcolorpixel');
  1073. getColorPixel.palette = palettes.dict['sensors'];
  1074. blocks.protoBlockDict['getcolorpixel'] = getColorPixel;
  1075. getColorPixel.staticLabels.push(_('pixel color'));
  1076. getColorPixel.adjustWidthToLabel();
  1077. getColorPixel.parameterBlock();
  1078. var timeBlock = new ProtoBlock('time');
  1079. timeBlock.palette = palettes.dict['sensors'];
  1080. blocks.protoBlockDict['time'] = timeBlock;
  1081. timeBlock.staticLabels.push(_('time'));
  1082. timeBlock.adjustWidthToLabel();
  1083. timeBlock.parameterBlock();
  1084. var mousexBlock = new ProtoBlock('mousex');
  1085. mousexBlock.palette = palettes.dict['sensors'];
  1086. blocks.protoBlockDict['mousex'] = mousexBlock;
  1087. mousexBlock.staticLabels.push(_('mouse x'));
  1088. mousexBlock.extraWidth = 15;
  1089. mousexBlock.adjustWidthToLabel();
  1090. mousexBlock.parameterBlock();
  1091. var mouseyBlock = new ProtoBlock('mousey');
  1092. mouseyBlock.palette = palettes.dict['sensors'];
  1093. blocks.protoBlockDict['mousey'] = mouseyBlock;
  1094. mouseyBlock.staticLabels.push(_('mouse y'));
  1095. mouseyBlock.extraWidth = 15;
  1096. mouseyBlock.adjustWidthToLabel();
  1097. mouseyBlock.parameterBlock();
  1098. var mousebuttonBlock = new ProtoBlock('mousebutton');
  1099. mousebuttonBlock.palette = palettes.dict['sensors'];
  1100. blocks.protoBlockDict['mousebutton'] = mousebuttonBlock;
  1101. mousebuttonBlock.staticLabels.push(_('mouse button'));
  1102. mousebuttonBlock.adjustWidthToLabel();
  1103. mousebuttonBlock.booleanZeroArgBlock();
  1104. var toASCIIBlock = new ProtoBlock('toascii');
  1105. toASCIIBlock.palette = palettes.dict['sensors'];
  1106. blocks.protoBlockDict['toascii'] = toASCIIBlock;
  1107. toASCIIBlock.staticLabels.push(_('to ASCII'));
  1108. toASCIIBlock.defaults.push(65);
  1109. toASCIIBlock.oneArgMathBlock();
  1110. var keyboardBlock = new ProtoBlock('keyboard');
  1111. keyboardBlock.palette = palettes.dict['sensors'];
  1112. blocks.protoBlockDict['keyboard'] = keyboardBlock;
  1113. keyboardBlock.staticLabels.push(_('keyboard'));
  1114. keyboardBlock.adjustWidthToLabel();
  1115. keyboardBlock.parameterBlock();
  1116. // REMOVED UNTIL WE PLUG THE SECURITY HOLE
  1117. /*
  1118. var evalBlock = new ProtoBlock('eval');
  1119. evalBlock.palette = palettes.dict['number'];
  1120. blocks.protoBlockDict['eval'] = evalBlock;
  1121. evalBlock.staticLabels.push(_('eval'));
  1122. evalBlock.staticLabels.push('f(x)');
  1123. evalBlock.staticLabels.push('x');
  1124. evalBlock.adjustWidthToLabel();
  1125. evalBlock.twoArgMathBlock();
  1126. evalBlock.dockTypes[1] = 'textin';
  1127. evalBlock.defaults.push('x');
  1128. evalBlock.defaults.push(100);
  1129. */
  1130. // Music Blocks that we ignore
  1131. var transposition = new ProtoBlock('transpositionfactor');
  1132. transposition.palette = palettes.dict['extras'];
  1133. blocks.protoBlockDict['transpositionfactor'] = transposition;
  1134. transposition.staticLabels.push(_('transposition'));
  1135. transposition.adjustWidthToLabel();
  1136. transposition.parameterBlock();
  1137. transposition.hidden = true;
  1138. var consonantStepDownBlock = new ProtoBlock('consonantstepsizedown');
  1139. consonantStepDownBlock.palette = palettes.dict['extras'];
  1140. blocks.protoBlockDict['consonantstepsizedown'] = consonantStepDownBlock;
  1141. //.TRANS: step down one note in current mode
  1142. consonantStepDownBlock.staticLabels.push(_('consonant step down'));
  1143. consonantStepDownBlock.adjustWidthToLabel();
  1144. consonantStepDownBlock.parameterBlock();
  1145. consonantStepDownBlock.hidden = true;
  1146. var consonantStepUpBlock = new ProtoBlock('consonantstepsizeup');
  1147. consonantStepUpBlock.palette = palettes.dict['extras'];
  1148. blocks.protoBlockDict['consonantstepsizeup'] = consonantStepUpBlock;
  1149. //.TRANS: step up one note in current mode
  1150. consonantStepUpBlock.staticLabels.push(_('consonant step up'));
  1151. consonantStepUpBlock.adjustWidthToLabel();
  1152. consonantStepUpBlock.parameterBlock();
  1153. consonantStepUpBlock.hidden = true;
  1154. var turtlePitchBlock = new ProtoBlock('turtlepitch');
  1155. turtlePitchBlock.palette = palettes.dict['extras'];
  1156. blocks.protoBlockDict['turtlepitch'] = turtlePitchBlock;
  1157. //.TRANS: convert current note for this turtle to piano key (1-88)
  1158. turtlePitchBlock.staticLabels.push(_('mouse pitch number'));
  1159. turtlePitchBlock.oneArgMathBlock();
  1160. turtlePitchBlock.adjustWidthToLabel();
  1161. turtlePitchBlock.dockTypes[1] = 'anyin';
  1162. turtlePitchBlock.hidden = true;
  1163. var setPitchNumberOffsetBlock = new ProtoBlock('setpitchnumberoffset');
  1164. setPitchNumberOffsetBlock.palette = palettes.dict['extras'];
  1165. blocks.protoBlockDict['setpitchnumberoffset'] = setPitchNumberOffsetBlock;
  1166. setPitchNumberOffsetBlock.staticLabels.push(_('set pitch number offset'), _('name'), _('octave'));
  1167. setPitchNumberOffsetBlock.adjustWidthToLabel();
  1168. setPitchNumberOffsetBlock.twoArgBlock();
  1169. setPitchNumberOffsetBlock.defaults.push('4');
  1170. setPitchNumberOffsetBlock.dockTypes[1] = 'notein';
  1171. setPitchNumberOffsetBlock.dockTypes[2] = 'anyin';
  1172. setPitchNumberOffsetBlock.hidden = true;
  1173. var numberToPitchBlock = new ProtoBlock('number2pitch');
  1174. numberToPitchBlock.palette = palettes.dict['extras'];
  1175. blocks.protoBlockDict['number2pitch'] = numberToPitchBlock;
  1176. //.TRANS: convert piano key number (1-88) to pitch
  1177. numberToPitchBlock.staticLabels.push(_('number to pitch'));
  1178. numberToPitchBlock.oneArgMathBlock();
  1179. numberToPitchBlock.adjustWidthToLabel();
  1180. numberToPitchBlock.defaults.push(48);
  1181. numberToPitchBlock.hidden = true;
  1182. var numberToOctaveBlock = new ProtoBlock('number2octave');
  1183. numberToOctaveBlock.palette = palettes.dict['extras'];
  1184. blocks.protoBlockDict['number2octave'] = numberToOctaveBlock;
  1185. //.TRANS: convert piano key number (1-88) to octave
  1186. numberToOctaveBlock.staticLabels.push(_('number to octave'));
  1187. numberToOctaveBlock.oneArgMathBlock();
  1188. numberToOctaveBlock.adjustWidthToLabel();
  1189. numberToOctaveBlock.hidden = true;
  1190. numberToOctaveBlock.defaults.push(48);
  1191. // Value blocks
  1192. var modenameBlock = new ProtoBlock('modename');
  1193. modenameBlock.palette = palettes.dict['extras'];
  1194. blocks.protoBlockDict['modename'] = modenameBlock;
  1195. modenameBlock.valueBlock();
  1196. modenameBlock.dockTypes[0] = 'textout';
  1197. modenameBlock.hidden = true;
  1198. var notenameBlock = new ProtoBlock('notename');
  1199. notenameBlock.palette = palettes.dict['extras'];
  1200. blocks.protoBlockDict['notename'] = notenameBlock;
  1201. notenameBlock.valueBlock();
  1202. notenameBlock.dockTypes[0] = 'noteout';
  1203. notenameBlock.hidden = true;
  1204. var solfegeBlock = new ProtoBlock('solfege');
  1205. solfegeBlock.palette = palettes.dict['extras'];
  1206. blocks.protoBlockDict['solfege'] = solfegeBlock;
  1207. solfegeBlock.valueBlock();
  1208. solfegeBlock.dockTypes[0] = 'solfegeout';
  1209. solfegeBlock.hidden = true;
  1210. var eastindiansolfegeBlock = new ProtoBlock('eastindiansolfege');
  1211. eastindiansolfegeBlock.palette = palettes.dict['extras'];
  1212. blocks.protoBlockDict['eastindiansolfege'] = eastindiansolfegeBlock;
  1213. eastindiansolfegeBlock.valueBlock();
  1214. eastindiansolfegeBlock.dockTypes[0] = 'solfegeout';
  1215. eastindiansolfegeBlock.hidden = true;
  1216. // Transposition blocks
  1217. var invertBlock = new ProtoBlock('invert1');
  1218. invertBlock.palette = palettes.dict['extras'];
  1219. blocks.protoBlockDict['invert1'] = invertBlock;
  1220. invertBlock.staticLabels.push(_('invert'), _('name'), _('octave'), _('even') + '/' + _('odd'));
  1221. invertBlock.adjustWidthToLabel();
  1222. invertBlock.flowClampThreeArgBlock();
  1223. invertBlock.adjustWidthToLabel();
  1224. invertBlock.defaults.push('sol');
  1225. invertBlock.defaults.push(4);
  1226. invertBlock.defaults.push(_('even'));
  1227. invertBlock.dockTypes[1] = 'solfegein';
  1228. invertBlock.dockTypes[2] = 'anyin';
  1229. invertBlock.dockTypes[3] = 'anyin';
  1230. invertBlock.hidden = true;
  1231. var transpositionBlock = new ProtoBlock('settransposition');
  1232. transpositionBlock.palette = palettes.dict['extras'];
  1233. blocks.protoBlockDict['settransposition'] = transpositionBlock;
  1234. transpositionBlock.staticLabels.push(_('adjust transposition'));
  1235. transpositionBlock.adjustWidthToLabel();
  1236. transpositionBlock.defaults.push('1');
  1237. transpositionBlock.flowClampOneArgBlock();
  1238. transpositionBlock.hidden = true;
  1239. var octaveBlock = new ProtoBlock('octave');
  1240. octaveBlock.palette = palettes.dict['extras'];
  1241. blocks.protoBlockDict['octave'] = octaveBlock;
  1242. octaveBlock.staticLabels.push(_('octave'));
  1243. octaveBlock.adjustWidthToLabel();
  1244. octaveBlock.zeroArgBlock();
  1245. octaveBlock.hidden = true;
  1246. var flatBlock = new ProtoBlock('flat');
  1247. flatBlock.palette = palettes.dict['extras'];
  1248. blocks.protoBlockDict['flat'] = flatBlock;
  1249. flatBlock.staticLabels.push(_('flat'));
  1250. flatBlock.adjustWidthToLabel();
  1251. flatBlock.flowClampZeroArgBlock();
  1252. flatBlock.hidden = true;
  1253. var sharpBlock = new ProtoBlock('sharp');
  1254. sharpBlock.palette = palettes.dict['extras'];
  1255. blocks.protoBlockDict['sharp'] = sharpBlock;
  1256. sharpBlock.staticLabels.push(_('sharp'));
  1257. sharpBlock.adjustWidthToLabel();
  1258. sharpBlock.flowClampZeroArgBlock();
  1259. sharpBlock.hidden = true;
  1260. var hertzBlock = new ProtoBlock('hertz');
  1261. hertzBlock.palette = palettes.dict['extras'];
  1262. blocks.protoBlockDict['hertz'] = hertzBlock;
  1263. hertzBlock.staticLabels.push(_('hertz'));
  1264. hertzBlock.adjustWidthToLabel();
  1265. hertzBlock.oneArgBlock();
  1266. hertzBlock.defaults.push(392);
  1267. hertzBlock.hidden = true;
  1268. var pitchNumberBlock = new ProtoBlock('pitchnumber');
  1269. pitchNumberBlock.palette = palettes.dict['extras'];
  1270. blocks.protoBlockDict['pitchnumber'] = pitchNumberBlock;
  1271. pitchNumberBlock.staticLabels.push(_('pitch number'));
  1272. pitchNumberBlock.adjustWidthToLabel();
  1273. pitchNumberBlock.oneArgBlock();
  1274. pitchNumberBlock.defaults.push(7);
  1275. pitchNumberBlock.dockTypes[1] = 'numberin';
  1276. pitchNumberBlock.hidden = true;
  1277. var scaleDegree = new ProtoBlock('scaledegree');
  1278. scaleDegree.palette = palettes.dict['extras'];
  1279. blocks.protoBlockDict['scaledegree'] = scaleDegree;
  1280. scaleDegree.staticLabels.push(_('scale degree'), _('number'), _('octave'));
  1281. scaleDegree.adjustWidthToLabel();
  1282. scaleDegree.defaults.push(5); // G in C Major
  1283. scaleDegree.defaults.push(4);
  1284. scaleDegree.twoArgBlock();
  1285. scaleDegree.dockTypes[1] = 'numberin';
  1286. scaleDegree.dockTypes[2] = 'anyin';
  1287. scaleDegree.hidden = true;
  1288. var pitchStepBlock = new ProtoBlock('steppitch');
  1289. pitchStepBlock.palette = palettes.dict['extras'];
  1290. blocks.protoBlockDict['steppitch'] = pitchStepBlock;
  1291. //.TRANS: step some number of notes in current mode
  1292. pitchStepBlock.staticLabels.push(_('step pitch'));
  1293. pitchStepBlock.oneArgBlock();
  1294. pitchStepBlock.adjustWidthToLabel();
  1295. pitchStepBlock.dockTypes[1] = 'anyin';
  1296. pitchStepBlock.defaults.push(1);
  1297. pitchStepBlock.hidden = true;
  1298. var pitch = new ProtoBlock('pitch');
  1299. pitch.palette = palettes.dict['extras'];
  1300. blocks.protoBlockDict['pitch'] = pitch;
  1301. pitch.staticLabels.push(_('pitch'), _('name'), _('octave'));
  1302. pitch.adjustWidthToLabel();
  1303. pitch.defaults.push('sol');
  1304. pitch.defaults.push(4);
  1305. pitch.twoArgBlock();
  1306. pitch.dockTypes[1] = 'solfegein';
  1307. pitch.dockTypes[2] = 'anyin';
  1308. pitch.hidden = true;
  1309. var sixtyfourthNoteBlock = new ProtoBlock('sixtyfourthNote');
  1310. sixtyfourthNoteBlock.palette = palettes.dict['extras'];
  1311. blocks.protoBlockDict['sixtyfourthNote'] = sixtyfourthNoteBlock;
  1312. sixtyfourthNoteBlock.staticLabels.push(_('1/64 note') + ' 𝅘𝅥𝅱');
  1313. sixtyfourthNoteBlock.adjustWidthToLabel();
  1314. sixtyfourthNoteBlock.zeroArgBlock();
  1315. sixtyfourthNoteBlock.hidden = true;
  1316. var thirtysecondNoteBlock = new ProtoBlock('thirtysecondNote');
  1317. thirtysecondNoteBlock.palette = palettes.dict['extras'];
  1318. blocks.protoBlockDict['thirtysecondNote'] = thirtysecondNoteBlock;
  1319. thirtysecondNoteBlock.staticLabels.push(_('1/32 note') + ' 𝅘𝅥𝅰');
  1320. thirtysecondNoteBlock.adjustWidthToLabel();
  1321. thirtysecondNoteBlock.zeroArgBlock();
  1322. thirtysecondNoteBlock.hidden = true;
  1323. var sixteenthNoteBlock = new ProtoBlock('sixteenthNote');
  1324. sixteenthNoteBlock.palette = palettes.dict['extras'];
  1325. blocks.protoBlockDict['sixteenthNote'] = sixteenthNoteBlock;
  1326. sixteenthNoteBlock.staticLabels.push(_('1/16 note') + ' 𝅘𝅥𝅯');
  1327. sixteenthNoteBlock.adjustWidthToLabel();
  1328. sixteenthNoteBlock.zeroArgBlock();
  1329. sixteenthNoteBlock.hidden = true;
  1330. var eighthNoteBlock = new ProtoBlock('eighthNote');
  1331. eighthNoteBlock.palette = palettes.dict['extras'];
  1332. blocks.protoBlockDict['eighthNote'] = eighthNoteBlock;
  1333. eighthNoteBlock.staticLabels.push(_('eighth note') + ' ♪');
  1334. eighthNoteBlock.adjustWidthToLabel();
  1335. eighthNoteBlock.zeroArgBlock();
  1336. eighthNoteBlock.hidden = true;
  1337. var quarterNoteBlock = new ProtoBlock('quarterNote');
  1338. quarterNoteBlock.palette = palettes.dict['extras'];
  1339. blocks.protoBlockDict['quarterNote'] = quarterNoteBlock;
  1340. quarterNoteBlock.staticLabels.push(_('quarter note') + ' ♩');
  1341. quarterNoteBlock.adjustWidthToLabel();
  1342. quarterNoteBlock.zeroArgBlock();
  1343. quarterNoteBlock.hidden = true;
  1344. var halfNoteBlock = new ProtoBlock('halfNote');
  1345. halfNoteBlock.palette = palettes.dict['extras'];
  1346. blocks.protoBlockDict['halfNote'] = halfNoteBlock;
  1347. halfNoteBlock.staticLabels.push(_('half note') + ' 𝅗𝅥');
  1348. halfNoteBlock.adjustWidthToLabel();
  1349. halfNoteBlock.zeroArgBlock();
  1350. halfNoteBlock.hidden = true;
  1351. var wholeNoteBlock = new ProtoBlock('wholeNote');
  1352. wholeNoteBlock.palette = palettes.dict['extras'];
  1353. blocks.protoBlockDict['wholeNote'] = wholeNoteBlock;
  1354. wholeNoteBlock.staticLabels.push(_('whole note') + ' 𝅝');
  1355. wholeNoteBlock.adjustWidthToLabel();
  1356. wholeNoteBlock.zeroArgBlock();
  1357. wholeNoteBlock.hidden = true;
  1358. var tuplet4Block = new ProtoBlock('tuplet4');
  1359. tuplet4Block.palette = palettes.dict['extras'];
  1360. blocks.protoBlockDict['tuplet4'] = tuplet4Block;
  1361. tuplet4Block.staticLabels.push(_('tuplet'), _('note value'));
  1362. tuplet4Block.extraWidth = 20;
  1363. tuplet4Block.adjustWidthToLabel();
  1364. tuplet4Block.flowClampOneArgBlock();
  1365. tuplet4Block.defaults.push(1 / 4);
  1366. tuplet4Block.hidden = true;
  1367. var simpleTupletBlock = new ProtoBlock('stuplet');
  1368. simpleTupletBlock.palette = palettes.dict['extras'];
  1369. blocks.protoBlockDict['stuplet'] = simpleTupletBlock;
  1370. simpleTupletBlock.staticLabels.push(_('simple tuplet'), _('number of notes'), _('note value'));
  1371. simpleTupletBlock.adjustWidthToLabel();
  1372. simpleTupletBlock.twoArgBlock();
  1373. simpleTupletBlock.defaults.push(3);
  1374. simpleTupletBlock.defaults.push(1 / 2);
  1375. simpleTupletBlock.hidden = true;
  1376. var rhythm2 = new ProtoBlock('rhythm2');
  1377. rhythm2.palette = palettes.dict['extras'];
  1378. blocks.protoBlockDict['rhythm2'] = rhythm2;
  1379. rhythm2.staticLabels.push(_('rhythm'), _('number of notes'), _('note value'));
  1380. rhythm2.extraWidth = 10;
  1381. rhythm2.adjustWidthToLabel();
  1382. rhythm2.defaults.push(3);
  1383. rhythm2.defaults.push(4);
  1384. rhythm2.twoArgBlock();
  1385. rhythm2.dockTypes[1] = 'anyin';
  1386. rhythm2.dockTypes[2] = 'anyin';
  1387. rhythm2.hidden = true;
  1388. var modewidgetBlock = new ProtoBlock('modewidget');
  1389. modewidgetBlock.palette = palettes.dict['extras'];
  1390. blocks.protoBlockDict['modewidget'] = modewidgetBlock;
  1391. modewidgetBlock.staticLabels.push(_('custom mode'));
  1392. modewidgetBlock.adjustWidthToLabel();
  1393. modewidgetBlock.stackClampZeroArgBlock();
  1394. modewidgetBlock.hidden = true;
  1395. var tempoBlock = new ProtoBlock('tempo');
  1396. tempoBlock.palette = palettes.dict['extras'];
  1397. blocks.protoBlockDict['tempo'] = tempoBlock;
  1398. tempoBlock.staticLabels.push(_('tempo'));
  1399. tempoBlock.adjustWidthToLabel();
  1400. tempoBlock.stackClampZeroArgBlock();
  1401. tempoBlock.hidden = true;
  1402. var pitchDrumMatrixBlock = new ProtoBlock('pitchdrummatrix');
  1403. pitchDrumMatrixBlock.palette = palettes.dict['extras'];
  1404. blocks.protoBlockDict['pitchdrummatrix'] = pitchDrumMatrixBlock;
  1405. pitchDrumMatrixBlock.staticLabels.push(_('pitch-drum matrix'));
  1406. pitchDrumMatrixBlock.adjustWidthToLabel();
  1407. pitchDrumMatrixBlock.stackClampZeroArgBlock();
  1408. pitchDrumMatrixBlock.hidden = true;
  1409. var pitchsliderBlock = new ProtoBlock('pitchslider');
  1410. pitchsliderBlock.palette = palettes.dict['extras'];
  1411. blocks.protoBlockDict['pitchslider'] = pitchsliderBlock;
  1412. //.TRANS: widget to generate pitches using a slider
  1413. pitchsliderBlock.staticLabels.push(_('pitchslider'));
  1414. pitchsliderBlock.adjustWidthToLabel();
  1415. pitchsliderBlock.stackClampZeroArgBlock();
  1416. pitchsliderBlock.hidden = true;
  1417. var pitchstaircaseBlock = new ProtoBlock('pitchstaircase');
  1418. pitchstaircaseBlock.palette = palettes.dict['extras'];
  1419. blocks.protoBlockDict['pitchstaircase'] = pitchstaircaseBlock;
  1420. pitchstaircaseBlock.staticLabels.push(_('pitch staircase'));
  1421. pitchstaircaseBlock.adjustWidthToLabel();
  1422. pitchstaircaseBlock.stackClampZeroArgBlock();
  1423. pitchstaircaseBlock.hidden = true;
  1424. var rhythmrulerBlock = new ProtoBlock('rhythmruler');
  1425. rhythmrulerBlock.palette = palettes.dict['extras'];
  1426. blocks.protoBlockDict['rhythmruler'] = rhythmrulerBlock;
  1427. //.TRANS: widget for subdividing a measure into distinct rhythmic elements
  1428. rhythmrulerBlock.staticLabels.push(_('rhythm ruler'));
  1429. rhythmrulerBlock.adjustWidthToLabel();
  1430. rhythmrulerBlock.stackClampOneArgBlock();
  1431. rhythmrulerBlock.defaults.push(1);
  1432. rhythmrulerBlock.hidden = true;
  1433. var matrixBlock = new ProtoBlock('matrix');
  1434. matrixBlock.palette = palettes.dict['extras'];
  1435. blocks.protoBlockDict['matrix'] = matrixBlock;
  1436. matrixBlock.staticLabels.push(_('pitch-time matrix'));
  1437. matrixBlock.adjustWidthToLabel();
  1438. matrixBlock.stackClampZeroArgBlock();
  1439. matrixBlock.hidden = true;
  1440. var noteCounter = new ProtoBlock('notecounter');
  1441. noteCounter.palette = palettes.dict['extras'];
  1442. blocks.protoBlockDict['notecounter'] = noteCounter;
  1443. noteCounter.staticLabels.push(_('note counter'));
  1444. noteCounter.argFlowClampBlock();
  1445. noteCounter.adjustWidthToLabel();
  1446. noteCounter.hidden = true;
  1447. var turtleNoteBlock2 = new ProtoBlock('turtlenote2');
  1448. turtleNoteBlock2.palette = palettes.dict['extras'];
  1449. blocks.protoBlockDict['turtlenote2'] = turtleNoteBlock2;
  1450. turtleNoteBlock2.staticLabels.push(_('mouse note value'));
  1451. turtleNoteBlock2.oneArgMathBlock();
  1452. turtleNoteBlock2.adjustWidthToLabel();
  1453. turtleNoteBlock2.dockTypes[1] = 'anyin';
  1454. turtleNoteBlock2.hidden = true;
  1455. var duplicateFactor = new ProtoBlock('duplicatefactor');
  1456. duplicateFactor.palette = palettes.dict['extras'];
  1457. blocks.protoBlockDict['duplicatefactor'] = duplicateFactor;
  1458. duplicateFactor.staticLabels.push(_('duplicate factor'));
  1459. duplicateFactor.adjustWidthToLabel();
  1460. duplicateFactor.parameterBlock();
  1461. duplicateFactor.hidden = true;
  1462. var skipFactor = new ProtoBlock('skipfactor');
  1463. skipFactor.palette = palettes.dict['extras'];
  1464. blocks.protoBlockDict['skipfactor'] = skipFactor;
  1465. skipFactor.staticLabels.push(_('skip factor'));
  1466. skipFactor.adjustWidthToLabel();
  1467. skipFactor.parameterBlock();
  1468. skipFactor.hidden = true;
  1469. var elapsedNotes = new ProtoBlock('elapsednotes');
  1470. elapsedNotes.palette = palettes.dict['extras'];
  1471. blocks.protoBlockDict['elapsednotes'] = elapsedNotes;
  1472. //.TRANS: number of whole notes that have been played
  1473. elapsedNotes.staticLabels.push(_('notes played'));
  1474. elapsedNotes.adjustWidthToLabel();
  1475. elapsedNotes.parameterBlock();
  1476. elapsedNotes.hidden = true;
  1477. var beatfactor = new ProtoBlock('beatfactor');
  1478. beatfactor.palette = palettes.dict['extras'];
  1479. blocks.protoBlockDict['beatfactor'] = beatfactor;
  1480. //.TRANS: number of beats per minute
  1481. beatfactor.staticLabels.push(_('beat factor'));
  1482. beatfactor.adjustWidthToLabel();
  1483. beatfactor.parameterBlock();
  1484. beatfactor.hidden = true;
  1485. var bpmBlock = new ProtoBlock('bpmfactor');
  1486. bpmBlock.palette = palettes.dict['extras'];
  1487. blocks.protoBlockDict['bpmfactor'] = bpmBlock;
  1488. bpmBlock.staticLabels.push(_('beats per minute'));
  1489. bpmBlock.adjustWidthToLabel();
  1490. bpmBlock.parameterBlock();
  1491. bpmBlock.hidden = true;
  1492. var driftBlock = new ProtoBlock('drift');
  1493. driftBlock.palette = palettes.dict['extras'];
  1494. blocks.protoBlockDict['drift'] = driftBlock;
  1495. driftBlock.staticLabels.push(_('free time'));
  1496. driftBlock.adjustWidthToLabel();
  1497. driftBlock.flowClampZeroArgBlock();
  1498. driftBlock.hidden = true;
  1499. var osctimeBlock = new ProtoBlock('osctime');
  1500. osctimeBlock.palette = palettes.dict['extras'];
  1501. blocks.protoBlockDict['osctime'] = osctimeBlock;
  1502. //.TRANS: oscillator time (in micro seconds)
  1503. osctimeBlock.staticLabels.push(_('osctime'));
  1504. osctimeBlock.adjustWidthToLabel();
  1505. osctimeBlock.flowClampOneArgBlock();
  1506. osctimeBlock.defaults.push(200);
  1507. osctimeBlock.hidden = true;
  1508. var newswingBlock = new ProtoBlock('newswing2');
  1509. newswingBlock.palette = palettes.dict['extras'];
  1510. blocks.protoBlockDict['newswing2'] = newswingBlock;
  1511. newswingBlock.staticLabels.push(_('swing'), _('swing value'), _('note value'));
  1512. newswingBlock.extraWidth = 20;
  1513. newswingBlock.adjustWidthToLabel();
  1514. newswingBlock.flowClampTwoArgBlock();
  1515. newswingBlock.defaults.push(1 / 24);
  1516. newswingBlock.defaults.push(1 / 8);
  1517. newswingBlock.hidden = true;
  1518. var setbpmBlock = new ProtoBlock('setbpm');
  1519. setbpmBlock.palette = palettes.dict['extras'];
  1520. blocks.protoBlockDict['setbpm'] = setbpmBlock;
  1521. setbpmBlock.staticLabels.push(_('beats per minute'));
  1522. setbpmBlock.adjustWidthToLabel();
  1523. setbpmBlock.flowClampOneArgBlock();
  1524. setbpmBlock.defaults.push(90);
  1525. setbpmBlock.hidden = true;
  1526. var backwardBlock = new ProtoBlock('backward');
  1527. backwardBlock.palette = palettes.dict['extras'];
  1528. blocks.protoBlockDict['backward'] = backwardBlock;
  1529. backwardBlock.staticLabels.push(_('backward'));
  1530. backwardBlock.adjustWidthToLabel();
  1531. backwardBlock.flowClampZeroArgBlock();
  1532. backwardBlock.hidden = true;
  1533. var skipNotesBlock = new ProtoBlock('skipnotes');
  1534. skipNotesBlock.palette = palettes.dict['extras'];
  1535. blocks.protoBlockDict['skipnotes'] = skipNotesBlock;
  1536. skipNotesBlock.staticLabels.push(_('skip notes'));
  1537. skipNotesBlock.adjustWidthToLabel();
  1538. skipNotesBlock.flowClampOneArgBlock();
  1539. skipNotesBlock.defaults.push(2);
  1540. skipNotesBlock.hidden = true;
  1541. var duplicateNotesBlock = new ProtoBlock('duplicatenotes');
  1542. duplicateNotesBlock.palette = palettes.dict['extras'];
  1543. blocks.protoBlockDict['duplicatenotes'] = duplicateNotesBlock;
  1544. duplicateNotesBlock.staticLabels.push(_('duplicate notes'));
  1545. duplicateNotesBlock.adjustWidthToLabel();
  1546. duplicateNotesBlock.flowClampOneArgBlock();
  1547. duplicateNotesBlock.defaults.push(2);
  1548. duplicateNotesBlock.hidden = true;
  1549. var beatFactorBlock = new ProtoBlock('multiplybeatfactor');
  1550. beatFactorBlock.palette = palettes.dict['extras'];
  1551. blocks.protoBlockDict['multiplybeatfactor'] = beatFactorBlock;
  1552. //.TRANS: speed up note duration by some factor, e.g. convert 1/4 to 1/8 notes by using a factor of 2
  1553. beatFactorBlock.staticLabels.push(_('multiply beat value'));
  1554. beatFactorBlock.adjustWidthToLabel();
  1555. beatFactorBlock.flowClampOneArgBlock();
  1556. beatFactorBlock.defaults.push(2);
  1557. beatFactorBlock.hidden = true;
  1558. var beatFactorBlock2 = new ProtoBlock('dividebeatfactor');
  1559. beatFactorBlock2.palette = palettes.dict['extras'];
  1560. blocks.protoBlockDict['dividebeatfactor'] = beatFactorBlock2;
  1561. //.TRANS: slow down note duration by some factor, e.g. convert 1/8 to 1/4 notes by using a factor of 2
  1562. beatFactorBlock2.staticLabels.push(_('divide beat value'));
  1563. beatFactorBlock2.adjustWidthToLabel();
  1564. beatFactorBlock2.flowClampOneArgBlock();
  1565. beatFactorBlock2.defaults.push(2);
  1566. beatFactorBlock2.hidden = true;
  1567. var tieBlock = new ProtoBlock('tie');
  1568. tieBlock.palette = palettes.dict['extras'];
  1569. blocks.protoBlockDict['tie'] = tieBlock;
  1570. //.TRANS: tie notes together into one longer note
  1571. tieBlock.staticLabels.push(_('tie'));
  1572. tieBlock.adjustWidthToLabel();
  1573. tieBlock.flowClampZeroArgBlock();
  1574. tieBlock.hidden = true;
  1575. var rhythmicdotBlock = new ProtoBlock('rhythmicdot');
  1576. rhythmicdotBlock.palette = palettes.dict['extras'];
  1577. blocks.protoBlockDict['rhythmicdot'] = rhythmicdotBlock;
  1578. rhythmicdotBlock.staticLabels.push(_('dot'));
  1579. rhythmicdotBlock.adjustWidthToLabel();
  1580. rhythmicdotBlock.flowClampZeroArgBlock();
  1581. rhythmicdotBlock.hidden = true;
  1582. var rest2Block = new ProtoBlock('rest2');
  1583. rest2Block.palette = palettes.dict['extras'];
  1584. blocks.protoBlockDict['rest2'] = rest2Block;
  1585. rest2Block.staticLabels.push(_('silence'));
  1586. rest2Block.adjustWidthToLabel();
  1587. rest2Block.zeroArgBlock();
  1588. rest2Block.hidden = true;
  1589. var newnoteBlock = new ProtoBlock('newnote');
  1590. newnoteBlock.palette = palettes.dict['extras'];
  1591. blocks.protoBlockDict['newnote'] = newnoteBlock;
  1592. newnoteBlock.staticLabels.push(_('note value'));
  1593. newnoteBlock.adjustWidthToLabel();
  1594. newnoteBlock.flowClampOneArgBlock();
  1595. newnoteBlock.defaults.push(1 / 4);
  1596. newnoteBlock.hidden = true;
  1597. var setkey2Block = new ProtoBlock('setkey2');
  1598. setkey2Block.palette = palettes.dict['extras'];
  1599. blocks.protoBlockDict['setkey2'] = setkey2Block;
  1600. setkey2Block.staticLabels.push(_('set key'), _('key'), _('mode'));
  1601. setkey2Block.adjustWidthToLabel();
  1602. setkey2Block.twoArgBlock();
  1603. setkey2Block.dockTypes[1] = 'anyin';
  1604. setkey2Block.dockTypes[2] = 'anyin';
  1605. setkey2Block.hidden = true;
  1606. var keyBlock = new ProtoBlock('key');
  1607. keyBlock.palette = palettes.dict['extras'];
  1608. blocks.protoBlockDict['key'] = keyBlock;
  1609. keyBlock.staticLabels.push(_('key'));
  1610. keyBlock.adjustWidthToLabel();
  1611. keyBlock.parameterBlock();
  1612. keyBlock.hidden = true;
  1613. var meter = new ProtoBlock('meter');
  1614. meter.palette = palettes.dict['extras'];
  1615. blocks.protoBlockDict['meter'] = meter;
  1616. meter.hidden = true;
  1617. meter.staticLabels.push(_('meter'), _('numerator'), _('denominator'));
  1618. meter.adjustWidthToLabel();
  1619. meter.defaults.push(3);
  1620. meter.defaults.push(4);
  1621. meter.twoArgMathBlock();
  1622. meter.dockTypes[1] = 'number';
  1623. meter.dockTypes[2] = 'number';
  1624. meter.hidden = true;
  1625. var setMasterBPMBlock = new ProtoBlock('setmasterbpm');
  1626. setMasterBPMBlock.palette = palettes.dict['extras'];
  1627. blocks.protoBlockDict['setmasterbpm'] = setMasterBPMBlock;
  1628. setMasterBPMBlock.staticLabels.push(_('master beats per minute'));
  1629. setMasterBPMBlock.adjustWidthToLabel();
  1630. setMasterBPMBlock.oneArgBlock();
  1631. setMasterBPMBlock.defaults.push(90);
  1632. setMasterBPMBlock.hidden = true;
  1633. var voicenameBlock = new ProtoBlock('voicename');
  1634. voicenameBlock.palette = palettes.dict['extras'];
  1635. blocks.protoBlockDict['voicename'] = voicenameBlock;
  1636. voicenameBlock.valueBlock();
  1637. voicenameBlock.dockTypes[0] = 'textout';
  1638. voicenameBlock.hidden = true;
  1639. var vibratoBlock = new ProtoBlock('vibrato');
  1640. vibratoBlock.palette = palettes.dict['extras'];
  1641. blocks.protoBlockDict['vibrato'] = vibratoBlock;
  1642. vibratoBlock.staticLabels.push(_('vibrato'), _('intensity'), _('rate'));
  1643. vibratoBlock.adjustWidthToLabel();
  1644. vibratoBlock.flowClampTwoArgBlock();
  1645. vibratoBlock.defaults.push(10);
  1646. vibratoBlock.defaults.push(1 / 16);
  1647. vibratoBlock.hidden = true;
  1648. var voiceBlock = new ProtoBlock('setvoice');
  1649. voiceBlock.palette = palettes.dict['extras'];
  1650. blocks.protoBlockDict['setvoice'] = voiceBlock;
  1651. voiceBlock.staticLabels.push(_('set synth'));
  1652. voiceBlock.adjustWidthToLabel();
  1653. voiceBlock.flowClampOneArgBlock();
  1654. voiceBlock.dockTypes[1] = 'textin';
  1655. voiceBlock.defaults.push(_('violin'));
  1656. voiceBlock.hidden = true;
  1657. var articulationBlock = new ProtoBlock('articulation');
  1658. articulationBlock.palette = palettes.dict['extras'];
  1659. blocks.protoBlockDict['articulation'] = articulationBlock;
  1660. articulationBlock.staticLabels.push(_('set relative volume'));
  1661. articulationBlock.adjustWidthToLabel();
  1662. articulationBlock.flowClampOneArgBlock();
  1663. articulationBlock.defaults.push(25);
  1664. articulationBlock.hidden = true;
  1665. var noteVolumeBlock2 = new ProtoBlock('setnotevolume2');
  1666. noteVolumeBlock2.palette = palettes.dict['extras'];
  1667. blocks.protoBlockDict['setnotevolume2'] = noteVolumeBlock2;
  1668. noteVolumeBlock2.staticLabels.push(_('set volume'));
  1669. noteVolumeBlock2.adjustWidthToLabel();
  1670. noteVolumeBlock2.flowClampOneArgBlock();
  1671. noteVolumeBlock2.defaults.push(50);
  1672. noteVolumeBlock2.hidden = true;
  1673. var crescendoBlock = new ProtoBlock('crescendo');
  1674. crescendoBlock.palette = palettes.dict['extras'];
  1675. blocks.protoBlockDict['crescendo'] = crescendoBlock;
  1676. crescendoBlock.staticLabels.push(_('crescendo')+" +/-");
  1677. crescendoBlock.adjustWidthToLabel();
  1678. crescendoBlock.flowClampOneArgBlock();
  1679. crescendoBlock.defaults.push(5);
  1680. crescendoBlock.hidden = true;
  1681. var newslurBlock = new ProtoBlock('newslur');
  1682. newslurBlock.palette = palettes.dict['extras'];
  1683. blocks.protoBlockDict['newslur'] = newslurBlock;
  1684. newslurBlock.staticLabels.push(_('slur'));
  1685. newslurBlock.adjustWidthToLabel();
  1686. newslurBlock.flowClampOneArgBlock();
  1687. newslurBlock.defaults.push(1 / 16);
  1688. newslurBlock.hidden = true;
  1689. var newstaccatoBlock = new ProtoBlock('newstaccato');
  1690. newstaccatoBlock.palette = palettes.dict['extras'];
  1691. blocks.protoBlockDict['newstaccato'] = newstaccatoBlock;
  1692. newstaccatoBlock.staticLabels.push(_('staccato'));
  1693. newstaccatoBlock.adjustWidthToLabel();
  1694. newstaccatoBlock.flowClampOneArgBlock();
  1695. newstaccatoBlock.defaults.push(1 / 32);
  1696. newstaccatoBlock.hidden = true;
  1697. var diminishedxBlock = new ProtoBlock('diminishedx');
  1698. diminishedxBlock.palette = palettes.dict['extras'];
  1699. blocks.protoBlockDict['diminishedx'] = diminishedxBlock;
  1700. diminishedxBlock.staticLabels.push(_('diminished'), _('interval'), _('octave') + '+/-');
  1701. diminishedxBlock.extraWidth = 20;
  1702. diminishedxBlock.adjustWidthToLabel();
  1703. diminishedxBlock.flowClampTwoArgBlock();
  1704. diminishedxBlock.dockTypes[2] = 'anyin';
  1705. diminishedxBlock.defaults.push(5);
  1706. diminishedxBlock.defaults.push(0);
  1707. diminishedxBlock.hidden = true;
  1708. var augmentedxBlock = new ProtoBlock('augmentedx');
  1709. augmentedxBlock.palette = palettes.dict['extras'];
  1710. blocks.protoBlockDict['augmentedx'] = augmentedxBlock;
  1711. augmentedxBlock.staticLabels.push(_('augmented'), _('interval'), _('octave') + '+/-');
  1712. augmentedxBlock.extraWidth = 20;
  1713. augmentedxBlock.adjustWidthToLabel();
  1714. augmentedxBlock.flowClampTwoArgBlock();
  1715. augmentedxBlock.dockTypes[2] = 'anyin';
  1716. augmentedxBlock.defaults.push(5);
  1717. augmentedxBlock.defaults.push(0);
  1718. augmentedxBlock.hidden = true;
  1719. var perfectxBlock = new ProtoBlock('perfectx');
  1720. perfectxBlock.palette = palettes.dict['extras'];
  1721. blocks.protoBlockDict['perfectx'] = perfectxBlock;
  1722. perfectxBlock.staticLabels.push(_('perfect'), _('interval'), _('octave') + '+/-');
  1723. perfectxBlock.extraWidth = 20;
  1724. perfectxBlock.adjustWidthToLabel();
  1725. perfectxBlock.flowClampTwoArgBlock();
  1726. perfectxBlock.dockTypes[2] = 'anyin';
  1727. perfectxBlock.defaults.push(5);
  1728. perfectxBlock.defaults.push(0);
  1729. perfectxBlock.hidden = true;
  1730. var minorxBlock = new ProtoBlock('minorx');
  1731. minorxBlock.palette = palettes.dict['extras'];
  1732. blocks.protoBlockDict['minorx'] = minorxBlock;
  1733. minorxBlock.staticLabels.push(_('minor'), _('interval'), _('octave') + '+/-');
  1734. minorxBlock.extraWidth = 20;
  1735. minorxBlock.adjustWidthToLabel();
  1736. minorxBlock.flowClampTwoArgBlock();
  1737. minorxBlock.dockTypes[2] = 'anyin';
  1738. minorxBlock.defaults.push(3);
  1739. minorxBlock.defaults.push(0);
  1740. minorxBlock.hidden = true;
  1741. var majorxBlock = new ProtoBlock('majorx');
  1742. majorxBlock.palette = palettes.dict['extras'];
  1743. blocks.protoBlockDict['majorx'] = majorxBlock;
  1744. majorxBlock.staticLabels.push(_('major'), _('interval'), _('octave') + '+/-');
  1745. majorxBlock.extraWidth = 20;
  1746. majorxBlock.adjustWidthToLabel();
  1747. majorxBlock.flowClampTwoArgBlock();
  1748. majorxBlock.dockTypes[2] = 'anyin';
  1749. majorxBlock.defaults.push(3);
  1750. majorxBlock.defaults.push(0);
  1751. majorxBlock.hidden = true;
  1752. var intervalBlock = new ProtoBlock('interval');
  1753. intervalBlock.palette = palettes.dict['extras'];
  1754. blocks.protoBlockDict['interval'] = intervalBlock;
  1755. //.TRANS: calculate a relative step between notes based on the current mode
  1756. intervalBlock.staticLabels.push(_('relative interval'));
  1757. intervalBlock.adjustWidthToLabel();
  1758. intervalBlock.flowClampOneArgBlock();
  1759. intervalBlock.defaults.push(5);
  1760. intervalBlock.hidden = true;
  1761. var drumnameBlock = new ProtoBlock('drumname');
  1762. drumnameBlock.palette = palettes.dict['extras'];
  1763. blocks.protoBlockDict['drumname'] = drumnameBlock;
  1764. drumnameBlock.valueBlock();
  1765. drumnameBlock.dockTypes[0] = 'textout';
  1766. drumnameBlock.hidden = true;
  1767. var setdrumBlock = new ProtoBlock('setdrum');
  1768. setdrumBlock.palette = palettes.dict['extras'];
  1769. blocks.protoBlockDict['setdrum'] = setdrumBlock;
  1770. //.TRANS: set the current drum sound for playback
  1771. setdrumBlock.staticLabels.push(_('set drum'));
  1772. setdrumBlock.adjustWidthToLabel();
  1773. setdrumBlock.flowClampOneArgBlock();
  1774. setdrumBlock.dockTypes[1] = 'anyin';
  1775. setdrumBlock.hidden = true;
  1776. var playdrumBlock = new ProtoBlock('playdrum');
  1777. playdrumBlock.palette = palettes.dict['extras'];
  1778. blocks.protoBlockDict['playdrum'] = playdrumBlock;
  1779. playdrumBlock.staticLabels.push(_('drum'));
  1780. playdrumBlock.adjustWidthToLabel();
  1781. playdrumBlock.oneArgBlock();
  1782. playdrumBlock.dockTypes[1] = 'anyin';
  1783. playdrumBlock.hidden = true;
  1784. var lilypondBlock = new ProtoBlock('savelilypond');
  1785. lilypondBlock.palette = palettes.dict['extras'];
  1786. blocks.protoBlockDict['savelilypond'] = lilypondBlock;
  1787. lilypondBlock.staticLabels.push(_('save as lilypond'));
  1788. lilypondBlock.adjustWidthToLabel();
  1789. lilypondBlock.oneArgBlock();
  1790. lilypondBlock.defaults.push(_('title') + '.ly');
  1791. lilypondBlock.dockTypes[1] = 'textin';
  1792. lilypondBlock.hidden = true;
  1793. var notevolumeFactor = new ProtoBlock('notevolumefactor');
  1794. notevolumeFactor.palette = palettes.dict['extras'];
  1795. blocks.protoBlockDict['notevolumefactor'] = notevolumeFactor;
  1796. //.TRANS: the volume at which notes are played
  1797. notevolumeFactor.staticLabels.push(_('note volume'));
  1798. notevolumeFactor.adjustWidthToLabel();
  1799. notevolumeFactor.parameterBlock();
  1800. // Push protoblocks onto their palettes.
  1801. for (var protoblock in blocks.protoBlockDict) {
  1802. if (blocks.protoBlockDict[protoblock].palette != null) {
  1803. blocks.protoBlockDict[protoblock].palette.add(blocks.protoBlockDict[protoblock]);
  1804. }
  1805. }
  1806. // Populate the lists of block types.
  1807. blocks.findBlockTypes();
  1808. }