Examples.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');
  2. smalltalk.addMethod(
  3. '_initialize',
  4. smalltalk.method({
  5. selector: 'initialize',
  6. category: 'initialization',
  7. fn: function (){
  8. var self=this;
  9. smalltalk.send(self, "_initialize", [], smalltalk.Widget);
  10. self['@count']=(0);
  11. return self;},
  12. source: unescape('initialize%0A%20%20%20%20super%20initialize.%0A%20%20%20%20count%20%3A%3D%200%0A'),
  13. messageSends: ["initialize"],
  14. referencedClasses: []
  15. }),
  16. smalltalk.Counter);
  17. smalltalk.addMethod(
  18. '_renderOn_',
  19. smalltalk.method({
  20. selector: 'renderOn:',
  21. category: 'rendering',
  22. fn: function (html){
  23. var self=this;
  24. self['@header']=(function($rec){smalltalk.send($rec, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(html, "_h1", []));
  25. (function($rec){smalltalk.send($rec, "_with_", [unescape("++")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_increase", []);})]);})(smalltalk.send(html, "_button", []));
  26. (function($rec){smalltalk.send($rec, "_with_", [unescape("--")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_decrease", []);})]);})(smalltalk.send(html, "_button", []));
  27. return self;},
  28. source: unescape('renderOn%3A%20html%0A%20%20%20%20header%20%3A%3D%20html%20h1%20%0A%09with%3A%20count%20asString%3B%0A%09yourself.%0A%20%20%20%20html%20button%0A%09with%3A%20%27++%27%3B%0A%09onClick%3A%20%5Bself%20increase%5D.%0A%20%20%20%20html%20button%0A%09with%3A%20%27--%27%3B%0A%09onClick%3A%20%5Bself%20decrease%5D%0A'),
  29. messageSends: ["with:", "asString", "yourself", "h1", "onClick:", "increase", "button", "decrease"],
  30. referencedClasses: []
  31. }),
  32. smalltalk.Counter);
  33. smalltalk.addMethod(
  34. '_increase',
  35. smalltalk.method({
  36. selector: 'increase',
  37. category: 'actions',
  38. fn: function (){
  39. var self=this;
  40. self['@count']=smalltalk.send(self['@count'], "__plus", [(1)]);
  41. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);})]);
  42. return self;},
  43. source: unescape('increase%0A%20%20%20%20count%20%3A%3D%20count%20+%201.%0A%20%20%20%20header%20contents%3A%20%5B%3Ahtml%20%7C%20html%20with%3A%20count%20asString%5D'),
  44. messageSends: [unescape("+"), "contents:", "with:", "asString"],
  45. referencedClasses: []
  46. }),
  47. smalltalk.Counter);
  48. smalltalk.addMethod(
  49. '_decrease',
  50. smalltalk.method({
  51. selector: 'decrease',
  52. category: 'actions',
  53. fn: function (){
  54. var self=this;
  55. self['@count']=smalltalk.send(self['@count'], "__minus", [(1)]);
  56. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);})]);
  57. return self;},
  58. source: unescape('decrease%0A%20%20%20%20count%20%3A%3D%20count%20-%201.%0A%20%20%20%20header%20contents%3A%20%5B%3Ahtml%20%7C%20html%20with%3A%20count%20asString%5D'),
  59. messageSends: [unescape("-"), "contents:", "with:", "asString"],
  60. referencedClasses: []
  61. }),
  62. smalltalk.Counter);
  63. smalltalk.addClass('Tetris', smalltalk.Widget, ['renderingContext', 'timer', 'speed', 'score', 'rows', 'movingPiece'], 'Examples');
  64. smalltalk.addMethod(
  65. '_renderOn_',
  66. smalltalk.method({
  67. selector: 'renderOn:',
  68. category: 'rendering',
  69. fn: function (html){
  70. var self=this;
  71. (function($rec){smalltalk.send($rec, "_class_", ["tetris"]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(smalltalk.send(html, "_h3", []), "_with_", ["Tetris"]);smalltalk.send(self, "_renderCanvasOn_", [html]);return smalltalk.send(self, "_renderButtonsOn_", [html]);})]);})(smalltalk.send(html, "_div", []));
  72. return self;},
  73. source: unescape('renderOn%3A%20html%0A%09html%20div%0A%09%09class%3A%20%27tetris%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20h3%20with%3A%20%27Tetris%27.%0A%09%09%09self%20renderCanvasOn%3A%20html.%0A%09%09%09self%20renderButtonsOn%3A%20html%5D'),
  74. messageSends: ["class:", "with:", "h3", "renderCanvasOn:", "renderButtonsOn:", "div"],
  75. referencedClasses: []
  76. }),
  77. smalltalk.Tetris);
  78. smalltalk.addMethod(
  79. '_renderCanvasOn_',
  80. smalltalk.method({
  81. selector: 'renderCanvasOn:',
  82. category: 'rendering',
  83. fn: function (html){
  84. var self=this;
  85. var canvas=nil;
  86. canvas=smalltalk.send(html, "_canvas", []);
  87. smalltalk.send(canvas, "_at_put_", ["width", smalltalk.send(smalltalk.send(self, "_width", []), "_asString", [])]);
  88. smalltalk.send(canvas, "_at_put_", ["height", smalltalk.send(smalltalk.send(self, "_height", []), "_asString", [])]);
  89. self['@renderingContext']=smalltalk.send(smalltalk.CanvasRenderingContext, "_tagBrush_", [canvas]);
  90. smalltalk.send(self, "_redraw", []);
  91. return self;},
  92. source: unescape('renderCanvasOn%3A%20html%0A%09%7C%20canvas%20%7C%0A%09canvas%20%3A%3D%20html%20canvas.%0A%09canvas%20at%3A%20%27width%27%20put%3A%20self%20width%20asString.%0A%09canvas%20at%3A%20%27height%27%20put%3A%20self%20height%20asString.%0A%09renderingContext%20%3A%3D%20CanvasRenderingContext%20tagBrush%3A%20canvas.%0A%09self%20redraw'),
  93. messageSends: ["canvas", "at:put:", "asString", "width", "height", "tagBrush:", "redraw"],
  94. referencedClasses: [smalltalk.CanvasRenderingContext]
  95. }),
  96. smalltalk.Tetris);
  97. smalltalk.addMethod(
  98. '_renderButtonsOn_',
  99. smalltalk.method({
  100. selector: 'renderButtonsOn:',
  101. category: 'rendering',
  102. fn: function (html){
  103. var self=this;
  104. (function($rec){smalltalk.send($rec, "_class_", ["tetris_buttons"]);return smalltalk.send($rec, "_with_", [(function(){(function($rec){smalltalk.send($rec, "_with_", ["New game"]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_startNewGame", []);})]);})(smalltalk.send(html, "_button", []));return (function($rec){smalltalk.send($rec, "_with_", [unescape("play/pause")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_update", []);})]);})(smalltalk.send(html, "_button", []));})]);})(smalltalk.send(html, "_div", []));
  105. return self;},
  106. source: unescape('renderButtonsOn%3A%20html%0A%09html%20div%20%0A%09%09class%3A%20%27tetris_buttons%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20button%0A%09%09%09%09with%3A%20%27New%20game%27%3B%0A%09%09%09%09onClick%3A%20%5Bself%20startNewGame%5D.%0A%09%09%09html%20button%0A%09%09%09%09with%3A%20%27play/pause%27%3B%0A%09%09%09%09onClick%3A%20%5Bself%20update%5D%5D'),
  107. messageSends: ["class:", "with:", "onClick:", "startNewGame", "button", "update", "div"],
  108. referencedClasses: []
  109. }),
  110. smalltalk.Tetris);
  111. smalltalk.addMethod(
  112. '_initialize',
  113. smalltalk.method({
  114. selector: 'initialize',
  115. category: 'initialization',
  116. fn: function (){
  117. var self=this;
  118. smalltalk.send(self, "_initialize", [], smalltalk.Widget);
  119. smalltalk.send(self, "_newGame", []);
  120. return self;},
  121. source: unescape('initialize%0A%09super%20initialize.%0A%09self%20newGame'),
  122. messageSends: ["initialize", "newGame"],
  123. referencedClasses: []
  124. }),
  125. smalltalk.Tetris);
  126. smalltalk.addMethod(
  127. '_startNewGame',
  128. smalltalk.method({
  129. selector: 'startNewGame',
  130. category: 'actions',
  131. fn: function (){
  132. var self=this;
  133. smalltalk.send(self, "_newGame", []);
  134. smalltalk.send(self['@timer'], "_ifNotNil_", [(function(){return smalltalk.send(self['@timer'], "_clearInterval", []);})]);
  135. self['@timer']=smalltalk.send((function(){return smalltalk.send(self, "_nextStep", []);}), "_valueWithInterval_", [self['@speed']]);
  136. return self;},
  137. source: unescape('startNewGame%0A%09self%20newGame.%0A%09timer%20ifNotNil%3A%20%5Btimer%20clearInterval%5D.%0A%09timer%20%3A%3D%20%5Bself%20nextStep%5D%20valueWithInterval%3A%20speed'),
  138. messageSends: ["newGame", "ifNotNil:", "clearInterval", "valueWithInterval:", "nextStep"],
  139. referencedClasses: []
  140. }),
  141. smalltalk.Tetris);
  142. smalltalk.addMethod(
  143. '_width',
  144. smalltalk.method({
  145. selector: 'width',
  146. category: 'accessing',
  147. fn: function (){
  148. var self=this;
  149. return smalltalk.send(smalltalk.send(self, "_class", []), "_width", []);
  150. return self;},
  151. source: unescape('width%0A%09%5Eself%20class%20width'),
  152. messageSends: ["width", "class"],
  153. referencedClasses: []
  154. }),
  155. smalltalk.Tetris);
  156. smalltalk.addMethod(
  157. '_height',
  158. smalltalk.method({
  159. selector: 'height',
  160. category: 'accessing',
  161. fn: function (){
  162. var self=this;
  163. return smalltalk.send(smalltalk.send(self, "_class", []), "_height", []);
  164. return self;},
  165. source: unescape('height%0A%09%5Eself%20class%20height'),
  166. messageSends: ["height", "class"],
  167. referencedClasses: []
  168. }),
  169. smalltalk.Tetris);
  170. smalltalk.addMethod(
  171. '_nextStep',
  172. smalltalk.method({
  173. selector: 'nextStep',
  174. category: 'actions',
  175. fn: function (){
  176. var self=this;
  177. smalltalk.send(self['@movingPiece'], "_ifNil_", [(function(){return smalltalk.send(self, "_newPiece", []);})]);
  178. smalltalk.send(smalltalk.send(self['@movingPiece'], "_canMoveIn_", [self]), "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@movingPiece'], "_position_", [smalltalk.send(smalltalk.send(self['@movingPiece'], "_position", []), "__plus", [smalltalk.send((0), "__at", [(1)])])]);}), (function(){return smalltalk.send(self, "_newPiece", []);})]);
  179. smalltalk.send(self, "_redraw", []);
  180. return self;},
  181. source: unescape('nextStep%0A%09movingPiece%20ifNil%3A%20%5Bself%20newPiece%5D.%0A%09%28movingPiece%20canMoveIn%3A%20self%29%0A%09%09ifTrue%3A%20%5BmovingPiece%20position%3A%20movingPiece%20position%20+%20%280@1%29%5D%0A%09%09ifFalse%3A%20%5Bself%20newPiece%5D.%0A%09self%20redraw%0A%09'),
  182. messageSends: ["ifNil:", "newPiece", "ifTrue:ifFalse:", "canMoveIn:", "position:", unescape("+"), "position", unescape("@"), "redraw"],
  183. referencedClasses: []
  184. }),
  185. smalltalk.Tetris);
  186. smalltalk.addMethod(
  187. '_redraw',
  188. smalltalk.method({
  189. selector: 'redraw',
  190. category: 'actions',
  191. fn: function (){
  192. var self=this;
  193. smalltalk.send(self['@renderingContext'], "_clearRectFrom_to_", [smalltalk.send((0), "__at", [smalltalk.send(self, "_width", [])]), smalltalk.send((0), "__at", [smalltalk.send(self, "_height", [])])]);
  194. (function($rec){smalltalk.send($rec, "_drawMap", []);return smalltalk.send($rec, "_drawPiece", []);})(self);
  195. return self;},
  196. source: unescape('redraw%0A%09renderingContext%20clearRectFrom%3A%200@%20self%20width%20to%3A%200@%20self%20height.%0A%09self%20%0A%09%09drawMap%3B%0A%09%09drawPiece'),
  197. messageSends: ["clearRectFrom:to:", unescape("@"), "width", "height", "drawMap", "drawPiece"],
  198. referencedClasses: []
  199. }),
  200. smalltalk.Tetris);
  201. smalltalk.addMethod(
  202. '_drawMap',
  203. smalltalk.method({
  204. selector: 'drawMap',
  205. category: 'actions',
  206. fn: function (){
  207. var self=this;
  208. (function($rec){smalltalk.send($rec, "_fillStyle_", [unescape("%23fafafa")]);return smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send((0), "__at", [(0)]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [smalltalk.send(self, "_height", [])])]);})(self['@renderingContext']);
  209. (function($rec){smalltalk.send($rec, "_lineWidth_", [(0.5)]);return smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);})(self['@renderingContext']);
  210. smalltalk.send((0), "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_x", []), (function(each){var x=nil;
  211. x=smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send(x, "__at", [(0)]), smalltalk.send(x, "__at", [smalltalk.send(self, "_height", [])])]);})]);
  212. smalltalk.send((0), "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_y", []), (function(each){var y=nil;
  213. y=smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send((0), "__at", [y]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [y])]);})]);
  214. return self;},
  215. source: unescape('drawMap%0A%09renderingContext%20%0A%09%09fillStyle%3A%20%27%23fafafa%27%3B%0A%09%09fillRectFrom%3A%200@0%20to%3A%20self%20width@self%20height.%0A%09renderingContext%20%0A%09%09lineWidth%3A%200.5%3B%0A%09%09strokeStyle%3A%20%27%23999%27.%0A%090%20to%3A%20self%20class%20squares%20x%20do%3A%20%5B%3Aeach%20%7C%20%7C%20x%20%7C%0A%09%09x%20%3A%3D%20each%20*%20self%20class%20squareSize.%0A%09%09self%20drawLineFrom%3A%20x@0%20to%3A%20x@self%20height%5D.%0A%090%20to%3A%20self%20class%20squares%20y%20do%3A%20%5B%3Aeach%20%7C%20%7C%20y%20%7C%0A%09%09y%20%3A%3D%20each%20*%20self%20class%20squareSize.%0A%09%09self%20drawLineFrom%3A%200@y%20to%3A%20self%20width@y%5D.'),
  216. messageSends: ["fillStyle:", "fillRectFrom:to:", unescape("@"), "width", "height", "lineWidth:", "strokeStyle:", "to:do:", "x", "squares", "class", unescape("*"), "squareSize", "drawLineFrom:to:", "y"],
  217. referencedClasses: []
  218. }),
  219. smalltalk.Tetris);
  220. smalltalk.addMethod(
  221. '_drawLineFrom_to_',
  222. smalltalk.method({
  223. selector: 'drawLineFrom:to:',
  224. category: 'actions',
  225. fn: function (aPoint, anotherPoint){
  226. var self=this;
  227. (function($rec){smalltalk.send($rec, "_beginPath", []);smalltalk.send($rec, "_moveTo_", [aPoint]);smalltalk.send($rec, "_lineTo_", [anotherPoint]);return smalltalk.send($rec, "_stroke", []);})(self['@renderingContext']);
  228. return self;},
  229. source: unescape('drawLineFrom%3A%20aPoint%20to%3A%20anotherPoint%0A%09renderingContext%20%0A%09%09beginPath%3B%0A%09%09moveTo%3A%20aPoint%3B%0A%09%09lineTo%3A%20anotherPoint%3B%0A%09%09stroke'),
  230. messageSends: ["beginPath", "moveTo:", "lineTo:", "stroke"],
  231. referencedClasses: []
  232. }),
  233. smalltalk.Tetris);
  234. smalltalk.addMethod(
  235. '_newGame',
  236. smalltalk.method({
  237. selector: 'newGame',
  238. category: 'actions',
  239. fn: function (){
  240. var self=this;
  241. self['@rows']=[];
  242. self['@movingPiece']=nil;
  243. self['@speed']=(200);
  244. self['@score']=(0);
  245. return self;},
  246. source: unescape('newGame%0A%09rows%20%3A%3D%20%23%28%29.%0A%09movingPiece%20%3A%3D%20nil.%0A%09speed%20%3A%3D%20200.%0A%09score%20%3A%3D%200'),
  247. messageSends: [],
  248. referencedClasses: []
  249. }),
  250. smalltalk.Tetris);
  251. smalltalk.addMethod(
  252. '_newPiece',
  253. smalltalk.method({
  254. selector: 'newPiece',
  255. category: 'actions',
  256. fn: function (){
  257. var self=this;
  258. self['@movingPiece']=smalltalk.send(smalltalk.TetrisPiece, "_atRandom", []);
  259. return self;},
  260. source: unescape('newPiece%0A%09movingPiece%20%3A%3D%20TetrisPiece%20atRandom'),
  261. messageSends: ["atRandom"],
  262. referencedClasses: [smalltalk.nil]
  263. }),
  264. smalltalk.Tetris);
  265. smalltalk.addMethod(
  266. '_squares',
  267. smalltalk.method({
  268. selector: 'squares',
  269. category: 'accessing',
  270. fn: function (){
  271. var self=this;
  272. return smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []);
  273. return self;},
  274. source: unescape('squares%0A%09%5Eself%20class%20squares'),
  275. messageSends: ["squares", "class"],
  276. referencedClasses: []
  277. }),
  278. smalltalk.Tetris);
  279. smalltalk.addMethod(
  280. '_gluePiece_',
  281. smalltalk.method({
  282. selector: 'gluePiece:',
  283. category: 'accessing',
  284. fn: function (aPiece){
  285. var self=this;
  286. smalltalk.send(aPiece, "_glueOn_", [self]);
  287. return self;},
  288. source: unescape('gluePiece%3A%20aPiece%0A%09aPiece%20glueOn%3A%20self%0A%09'),
  289. messageSends: ["glueOn:"],
  290. referencedClasses: []
  291. }),
  292. smalltalk.Tetris);
  293. smalltalk.addMethod(
  294. '_drawRows',
  295. smalltalk.method({
  296. selector: 'drawRows',
  297. category: 'actions',
  298. fn: function (){
  299. var self=this;
  300. smalltalk.send(smalltalk.send(self, "_rows", []), "_do_", [(function(each){return nil;})]);
  301. smalltalk.send(self['@movingPiece'], "_ifNotNil_", [(function(){return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);})]);
  302. return self;},
  303. source: unescape('drawRows%0A%09self%20rows%20do%3A%20%5B%3Aeach%20%7C%5D.%0A%09movingPiece%20ifNotNil%3A%20%5BmovingPiece%20drawOn%3A%20renderingContext%5D'),
  304. messageSends: ["do:", "rows", "ifNotNil:", "drawOn:"],
  305. referencedClasses: []
  306. }),
  307. smalltalk.Tetris);
  308. smalltalk.addMethod(
  309. '_drawPiece',
  310. smalltalk.method({
  311. selector: 'drawPiece',
  312. category: 'actions',
  313. fn: function (){
  314. var self=this;
  315. smalltalk.send(self['@movingPiece'], "_ifNotNil_", [(function(){return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);})]);
  316. return self;},
  317. source: unescape('drawPiece%0A%09movingPiece%20ifNotNil%3A%20%5B%0A%09%09movingPiece%20drawOn%3A%20renderingContext%5D'),
  318. messageSends: ["ifNotNil:", "drawOn:"],
  319. referencedClasses: []
  320. }),
  321. smalltalk.Tetris);
  322. smalltalk.addMethod(
  323. '_rows',
  324. smalltalk.method({
  325. selector: 'rows',
  326. category: 'accessing',
  327. fn: function (){
  328. var self=this;
  329. return self['@rows'];
  330. return self;},
  331. source: unescape('rows%0A%09%22An%20array%20of%20rows.%20Each%20row%20is%20a%20collection%20of%20points.%22%0A%09%5Erows'),
  332. messageSends: [],
  333. referencedClasses: []
  334. }),
  335. smalltalk.Tetris);
  336. smalltalk.addMethod(
  337. '_addRow_',
  338. smalltalk.method({
  339. selector: 'addRow:',
  340. category: 'accessing',
  341. fn: function (aCollection){
  342. var self=this;
  343. smalltalk.send(smalltalk.send(self, "_rows", []), "_add_", [aCollection]);
  344. return self;},
  345. source: unescape('addRow%3A%20aCollection%0A%09self%20rows%20add%3A%20aCollection'),
  346. messageSends: ["add:", "rows"],
  347. referencedClasses: []
  348. }),
  349. smalltalk.Tetris);
  350. smalltalk.addMethod(
  351. '_squareSize',
  352. smalltalk.method({
  353. selector: 'squareSize',
  354. category: 'accessing',
  355. fn: function (){
  356. var self=this;
  357. return (22);
  358. return self;},
  359. source: unescape('squareSize%0A%09%5E22'),
  360. messageSends: [],
  361. referencedClasses: []
  362. }),
  363. smalltalk.Tetris.klass);
  364. smalltalk.addMethod(
  365. '_width',
  366. smalltalk.method({
  367. selector: 'width',
  368. category: 'accessing',
  369. fn: function (){
  370. var self=this;
  371. return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_x", [])]);
  372. return self;},
  373. source: unescape('width%0A%09%5Eself%20squareSize%20*%20%28self%20squares%20x%29'),
  374. messageSends: [unescape("*"), "squareSize", "x", "squares"],
  375. referencedClasses: []
  376. }),
  377. smalltalk.Tetris.klass);
  378. smalltalk.addMethod(
  379. '_height',
  380. smalltalk.method({
  381. selector: 'height',
  382. category: 'accessing',
  383. fn: function (){
  384. var self=this;
  385. return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_y", [])]);
  386. return self;},
  387. source: unescape('height%0A%09%5Eself%20squareSize%20*%20%28self%20squares%20y%29'),
  388. messageSends: [unescape("*"), "squareSize", "y", "squares"],
  389. referencedClasses: []
  390. }),
  391. smalltalk.Tetris.klass);
  392. smalltalk.addMethod(
  393. '_squares',
  394. smalltalk.method({
  395. selector: 'squares',
  396. category: 'accessing',
  397. fn: function (){
  398. var self=this;
  399. return smalltalk.send((10), "__at", [(15)]);
  400. return self;},
  401. source: unescape('squares%0A%09%5E10@15'),
  402. messageSends: [unescape("@")],
  403. referencedClasses: []
  404. }),
  405. smalltalk.Tetris.klass);
  406. smalltalk.addClass('TetrisPiece', smalltalk.Widget, ['rotation', 'position'], 'Examples');
  407. smalltalk.addMethod(
  408. '_drawOn_',
  409. smalltalk.method({
  410. selector: 'drawOn:',
  411. category: 'drawing',
  412. fn: function (aRenderingContext){
  413. var self=this;
  414. smalltalk.send(aRenderingContext, "_fillStyle_", [smalltalk.send(self, "_color", [])]);
  415. smalltalk.send(smalltalk.send(self, "_bounds", []), "_do_", [(function(each){return (function($rec){smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send((1), "__at", [(1)]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);smalltalk.send($rec, "_lineWidth_", [(2)]);return smalltalk.send($rec, "_strokeRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send((1), "__at", [(1)]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);})(aRenderingContext);})]);
  416. return self;},
  417. source: unescape('drawOn%3A%20aRenderingContext%0A%09aRenderingContext%20fillStyle%3A%20self%20color.%0A%09self%20bounds%20do%3A%20%5B%3Aeach%20%7C%0A%09%09aRenderingContext%20%0A%09%09%09fillRectFrom%3A%20each%20+%20self%20position*%20Tetris%20squareSize%20to%3A%201@1%20*%20Tetris%20squareSize%3B%0A%09%09%09strokeStyle%3A%20%27%23999%27%3B%0A%09%09%09lineWidth%3A%202%3B%0A%09%09%09strokeRectFrom%3A%20each%20+%20self%20position*%20Tetris%20squareSize%20to%3A%201@1%20*%20Tetris%20squareSize%5D'),
  418. messageSends: ["fillStyle:", "color", "do:", "bounds", "fillRectFrom:to:", unescape("*"), unescape("+"), "position", "squareSize", unescape("@"), "strokeStyle:", "lineWidth:", "strokeRectFrom:to:"],
  419. referencedClasses: [smalltalk.Tetris]
  420. }),
  421. smalltalk.TetrisPiece);
  422. smalltalk.addMethod(
  423. '_rotation',
  424. smalltalk.method({
  425. selector: 'rotation',
  426. category: 'accessing',
  427. fn: function (){
  428. var self=this;
  429. return smalltalk.send(self['@rotation'], "_ifNil_", [(function(){return self['@rotation']=(1);})]);
  430. return self;},
  431. source: unescape('rotation%0A%09%5Erotation%20ifNil%3A%20%5Brotation%20%3A%3D%201%5D'),
  432. messageSends: ["ifNil:"],
  433. referencedClasses: []
  434. }),
  435. smalltalk.TetrisPiece);
  436. smalltalk.addMethod(
  437. '_rotation_',
  438. smalltalk.method({
  439. selector: 'rotation:',
  440. category: 'accessing',
  441. fn: function (aNumber){
  442. var self=this;
  443. self['@rotation']=aNumber;
  444. return self;},
  445. source: unescape('rotation%3A%20aNumber%0A%09rotation%20%3A%3D%20aNumber'),
  446. messageSends: [],
  447. referencedClasses: []
  448. }),
  449. smalltalk.TetrisPiece);
  450. smalltalk.addMethod(
  451. '_position',
  452. smalltalk.method({
  453. selector: 'position',
  454. category: 'accessing',
  455. fn: function (){
  456. var self=this;
  457. return smalltalk.send(self['@position'], "_ifNil_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_x", []), "__slash", [(2)]), "__minus", [(1)]), "__at", [(0)]);})]);
  458. return self;},
  459. source: unescape('position%0A%09%5Eposition%20ifNil%3A%20%5B%28Tetris%20squares%20x%20/%202%29%20-1%20@%200%5D'),
  460. messageSends: ["ifNil:", unescape("@"), unescape("-"), unescape("/"), "x", "squares"],
  461. referencedClasses: [smalltalk.Tetris]
  462. }),
  463. smalltalk.TetrisPiece);
  464. smalltalk.addMethod(
  465. '_position_',
  466. smalltalk.method({
  467. selector: 'position:',
  468. category: 'accessing',
  469. fn: function (aPoint){
  470. var self=this;
  471. return self['@position']=aPoint;
  472. return self;},
  473. source: unescape('position%3A%20aPoint%0A%09%5Eposition%20%3A%3D%20aPoint'),
  474. messageSends: [],
  475. referencedClasses: []
  476. }),
  477. smalltalk.TetrisPiece);
  478. smalltalk.addMethod(
  479. '_bounds',
  480. smalltalk.method({
  481. selector: 'bounds',
  482. category: 'accessing',
  483. fn: function (){
  484. var self=this;
  485. smalltalk.send(self, "_subclassResponsibility", []);
  486. return self;},
  487. source: unescape('bounds%0A%09self%20subclassResponsibility'),
  488. messageSends: ["subclassResponsibility"],
  489. referencedClasses: []
  490. }),
  491. smalltalk.TetrisPiece);
  492. smalltalk.addMethod(
  493. '_color',
  494. smalltalk.method({
  495. selector: 'color',
  496. category: 'accessing',
  497. fn: function (){
  498. var self=this;
  499. return unescape("%23afa");
  500. return self;},
  501. source: unescape('color%0A%09%5E%27%23afa%27'),
  502. messageSends: [],
  503. referencedClasses: []
  504. }),
  505. smalltalk.TetrisPiece);
  506. smalltalk.addMethod(
  507. '_canMove',
  508. smalltalk.method({
  509. selector: 'canMove',
  510. category: 'testing',
  511. fn: function (){
  512. var self=this;
  513. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
  514. return self;},
  515. source: unescape('canMove%0A%09%5Eself%20position%20y%20%3C%20%28Tetris%20squares%20y%20-%20self%20height%29'),
  516. messageSends: [unescape("%3C"), "y", "position", unescape("-"), "squares", "height"],
  517. referencedClasses: [smalltalk.Tetris]
  518. }),
  519. smalltalk.TetrisPiece);
  520. smalltalk.addMethod(
  521. '_height',
  522. smalltalk.method({
  523. selector: 'height',
  524. category: 'accessing',
  525. fn: function (){
  526. var self=this;
  527. return (2);
  528. return self;},
  529. source: unescape('height%0A%09%5E2'),
  530. messageSends: [],
  531. referencedClasses: []
  532. }),
  533. smalltalk.TetrisPiece);
  534. smalltalk.addMethod(
  535. '_canMoveIn_',
  536. smalltalk.method({
  537. selector: 'canMoveIn:',
  538. category: 'testing',
  539. fn: function (aTetris){
  540. var self=this;
  541. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(aTetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
  542. return self;},
  543. source: unescape('canMoveIn%3A%20aTetris%0A%09%5Eself%20position%20y%20%3C%20%28aTetris%20squares%20y%20-%20self%20height%29'),
  544. messageSends: [unescape("%3C"), "y", "position", unescape("-"), "squares", "height"],
  545. referencedClasses: []
  546. }),
  547. smalltalk.TetrisPiece);
  548. smalltalk.addMethod(
  549. '_atRandom',
  550. smalltalk.method({
  551. selector: 'atRandom',
  552. category: 'instance creation',
  553. fn: function (){
  554. var self=this;
  555. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_at_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_size", []), "_atRandom", [])]), "_new", []);
  556. return self;},
  557. source: unescape('atRandom%0A%09%5E%28self%20subclasses%20at%3A%20self%20subclasses%20size%20atRandom%29%20new'),
  558. messageSends: ["new", "at:", "subclasses", "atRandom", "size"],
  559. referencedClasses: []
  560. }),
  561. smalltalk.TetrisPiece.klass);
  562. smalltalk.addClass('TetrisPieceO', smalltalk.TetrisPiece, [], 'Examples');
  563. smalltalk.addMethod(
  564. '_bounds',
  565. smalltalk.method({
  566. selector: 'bounds',
  567. category: 'accessing',
  568. fn: function (){
  569. var self=this;
  570. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  571. return self;},
  572. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09yourself'),
  573. messageSends: ["add:", unescape("@"), "yourself", "new"],
  574. referencedClasses: [smalltalk.Array]
  575. }),
  576. smalltalk.TetrisPieceO);
  577. smalltalk.addClass('TetrisPieceL', smalltalk.TetrisPiece, [], 'Examples');
  578. smalltalk.addMethod(
  579. '_bounds',
  580. smalltalk.method({
  581. selector: 'bounds',
  582. category: 'accessing',
  583. fn: function (){
  584. var self=this;
  585. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(2)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  586. return self;},
  587. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%200@2%3B%0A%09%09add%3A%201@2%3B%0A%09%09yourself'),
  588. messageSends: ["add:", unescape("@"), "yourself", "new"],
  589. referencedClasses: [smalltalk.Array]
  590. }),
  591. smalltalk.TetrisPieceL);
  592. smalltalk.addMethod(
  593. '_color',
  594. smalltalk.method({
  595. selector: 'color',
  596. category: 'accessing',
  597. fn: function (){
  598. var self=this;
  599. return unescape("%23ffa");
  600. return self;},
  601. source: unescape('color%0A%09%5E%27%23ffa%27'),
  602. messageSends: [],
  603. referencedClasses: []
  604. }),
  605. smalltalk.TetrisPieceL);
  606. smalltalk.addMethod(
  607. '_height',
  608. smalltalk.method({
  609. selector: 'height',
  610. category: 'accessing',
  611. fn: function (){
  612. var self=this;
  613. return (3);
  614. return self;},
  615. source: unescape('height%0A%09%5E3'),
  616. messageSends: [],
  617. referencedClasses: []
  618. }),
  619. smalltalk.TetrisPieceL);
  620. smalltalk.addClass('TetrisPieceJ', smalltalk.TetrisPiece, [], 'Examples');
  621. smalltalk.addMethod(
  622. '_color',
  623. smalltalk.method({
  624. selector: 'color',
  625. category: 'accessing',
  626. fn: function (){
  627. var self=this;
  628. return unescape("%23aaf");
  629. return self;},
  630. source: unescape('color%0A%09%5E%27%23aaf%27'),
  631. messageSends: [],
  632. referencedClasses: []
  633. }),
  634. smalltalk.TetrisPieceJ);
  635. smalltalk.addMethod(
  636. '_bounds',
  637. smalltalk.method({
  638. selector: 'bounds',
  639. category: 'accessing',
  640. fn: function (){
  641. var self=this;
  642. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  643. return self;},
  644. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09add%3A%201@2%3B%0A%09%09add%3A%200@2%3B%0A%09%09yourself'),
  645. messageSends: ["add:", unescape("@"), "yourself", "new"],
  646. referencedClasses: [smalltalk.Array]
  647. }),
  648. smalltalk.TetrisPieceJ);
  649. smalltalk.addMethod(
  650. '_height',
  651. smalltalk.method({
  652. selector: 'height',
  653. category: 'accessing',
  654. fn: function (){
  655. var self=this;
  656. return (3);
  657. return self;},
  658. source: unescape('height%0A%09%5E3'),
  659. messageSends: [],
  660. referencedClasses: []
  661. }),
  662. smalltalk.TetrisPieceJ);
  663. smalltalk.addClass('TetrisPieceI', smalltalk.TetrisPiece, [], 'Examples');
  664. smalltalk.addMethod(
  665. '_color',
  666. smalltalk.method({
  667. selector: 'color',
  668. category: 'accessing',
  669. fn: function (){
  670. var self=this;
  671. return unescape("%23faa");
  672. return self;},
  673. source: unescape('color%0A%09%5E%27%23faa%27'),
  674. messageSends: [],
  675. referencedClasses: []
  676. }),
  677. smalltalk.TetrisPieceI);
  678. smalltalk.addMethod(
  679. '_bounds',
  680. smalltalk.method({
  681. selector: 'bounds',
  682. category: 'accessing',
  683. fn: function (){
  684. var self=this;
  685. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(3)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  686. return self;},
  687. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%200@2%3B%0A%09%09add%3A%200@3%3B%0A%09%09yourself'),
  688. messageSends: ["add:", unescape("@"), "yourself", "new"],
  689. referencedClasses: [smalltalk.Array]
  690. }),
  691. smalltalk.TetrisPieceI);
  692. smalltalk.addMethod(
  693. '_height',
  694. smalltalk.method({
  695. selector: 'height',
  696. category: 'accessing',
  697. fn: function (){
  698. var self=this;
  699. return (4);
  700. return self;},
  701. source: unescape('height%0A%09%5E4'),
  702. messageSends: [],
  703. referencedClasses: []
  704. }),
  705. smalltalk.TetrisPieceI);
  706. smalltalk.addClass('TetrisPieceT', smalltalk.TetrisPiece, [], 'Examples');
  707. smalltalk.addMethod(
  708. '_bounds',
  709. smalltalk.method({
  710. selector: 'bounds',
  711. category: 'accessing',
  712. fn: function (){
  713. var self=this;
  714. return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((2), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
  715. return self;},
  716. source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%202@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09yourself'),
  717. messageSends: ["add:", unescape("@"), "yourself", "new"],
  718. referencedClasses: [smalltalk.Array]
  719. }),
  720. smalltalk.TetrisPieceT);
  721. smalltalk.addMethod(
  722. '_color',
  723. smalltalk.method({
  724. selector: 'color',
  725. category: 'accessing',
  726. fn: function (){
  727. var self=this;
  728. return unescape("%23aaf");
  729. return self;},
  730. source: unescape('color%0A%09%5E%27%23aaf%27'),
  731. messageSends: [],
  732. referencedClasses: []
  733. }),
  734. smalltalk.TetrisPieceT);