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.

117 lines
4.5 KiB

  1. //* comment *//
  2. Copyright (C) 2015 Sam Parkinson
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. //* arg-globals *//
  14. var block = logo.blocks.blockList[blk];
  15. var conns = block.connections;
  16. //* block-globals *//
  17. var simpleOneArgBlock = function (name, label) {
  18. if (label === undefined) { var label = name; }
  19. var block = new ProtoBlock(name);
  20. block.palette = palettes.dict['maths'];
  21. blocks.protoBlockDict[name] = block;
  22. block.staticLabels.push(label);
  23. block.adjustWidthToLabel();
  24. block.oneArgMathBlock();
  25. block.defaults.push(1);
  26. };
  27. var staticBlock = function (name, label) {
  28. var block = new ProtoBlock(name);
  29. block.palette = palettes.dict['maths'];
  30. blocks.protoBlockDict[name] = block;
  31. block.staticLabels.push(label);
  32. block.adjustWidthToLabel();
  33. block.parameterBlock();
  34. };
  35. //* block:power *//
  36. var block = new ProtoBlock('power');
  37. block.palette = palettes.dict['maths'];
  38. blocks.protoBlockDict['power'] = block;
  39. block.staticLabels.push(_('power'), _('base'), _('exp'));
  40. block.twoArgMathBlock();
  41. block.defaults.push(10, 2);
  42. //* arg:power *//
  43. var base = logo.parseArg(logo, turtle, conns[1]);
  44. var exp = logo.parseArg(logo, turtle, conns[2]);
  45. block.value = Math.pow(base, exp);
  46. //* block:sin *// simpleOneArgBlock('sin');
  47. //* arg:sin *// block.value = Math.sin(logo.parseArg(logo, turtle, conns[1]));
  48. //* block:cos *// simpleOneArgBlock('cos');
  49. //* arg:cos *// block.value = Math.cos(logo.parseArg(logo, turtle, conns[1]));
  50. //* block:tan *// simpleOneArgBlock('tan');
  51. //* arg:sin *// block.value = Math.tan(logo.parseArg(logo, turtle, conns[1]));
  52. //* block:asin *// simpleOneArgBlock('asin');
  53. //* arg:asin *// block.value = Math.asin(logo.parseArg(logo, turtle, conns[1]));
  54. //* block:acos *// simpleOneArgBlock('acos');
  55. //* arg:acos *// block.value = Math.acos(logo.parseArg(logo, turtle, conns[1]));
  56. //* block:atan *// simpleOneArgBlock('atan');
  57. //* arg:atan *// block.value = Math.atan(logo.parseArg(logo, turtle, conns[1]));
  58. //* block:floor *// simpleOneArgBlock(_('floor'));
  59. //* arg:floor *// block.value = Math.floor(logo.parseArg(logo, turtle, conns[1]));
  60. //* block:ceiling *// simpleOneArgBlock(_('ceiling'));
  61. //* arg:ceiling *// block.value = Math.ceil(logo.parseArg(logo, turtle, conns[1]));
  62. //* block:degrees *// simpleOneArgBlock(_('degrees'), _('to degrees'));
  63. //* arg:degrees *// block.value = logo.parseArg(logo, turtle, conns[1]) * (180/Math.PI);
  64. //* block:radians *// simpleOneArgBlock(_('radians'), _('to radians'));
  65. //* arg:radians *// block.value = logo.parseArg(logo, turtle, conns[1]) * (Math.PI/180);
  66. //* block:pi *// staticBlock('pi', 'π');
  67. //* arg:pi *// block.value = Math.PI;
  68. //* block:e *// staticBlock('e', 'e');
  69. //* arg:e *// block.value = Math.E;
  70. //* palette-icon:maths *//
  71. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  72. <!-- Created with Inkscape (http://www.inkscape.org/) -->
  73. <svg
  74. xmlns:dc="http://purl.org/dc/elements/1.1/"
  75. xmlns:cc="http://creativecommons.org/ns#"
  76. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  77. xmlns:svg="http://www.w3.org/2000/svg"
  78. xmlns="http://www.w3.org/2000/svg"
  79. version="1.1"
  80. width="55"
  81. height="55"
  82. viewBox="0 0 55 55"
  83. id="svg2"
  84. xml:space="preserve"><metadata
  85. id="metadata13"><rdf:RDF><cc:Work
  86. rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
  87. rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
  88. id="defs11" /><g
  89. id="toolbar-trigonometry"
  90. style="fill:#000000;display:block"><path
  91. d="m 11.852704,38.123539 31.294591,0 -31.294591,-26.247077 z"
  92. id="path5"
  93. style="fill:none;stroke:#ffffff;stroke-width:3.53326035" /><path
  94. d="m 11.852704,30.047514 8.076024,0 0,8.076025"
  95. id="path7"
  96. style="fill:none;stroke:#ffffff;stroke-width:1.51425433" /></g></svg>
  97. //* palette-fill:maths *// #ff0066
  98. //* palette-stroke:maths *// #ef003e
  99. //* palette-highlight:maths *// #ffb1b3
  100. //* palette-stroke-highlight:maths *// #000000