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.

73 lines
3.3 KiB

  1. //* comment *//
  2. Copyright (C) 2015 Ignacio Rodríguez
  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. This plugin provides logical bit operations in Turtle Art,
  14. such as AND, OR, XOR, NOT, logical shift left, logical shift right.
  15. //* arg-globals *//
  16. var block = logo.blocks.blockList[blk];
  17. var conns = block.connections;
  18. //* block-globals *//
  19. var LogicTwoArgBlock = function (name, label) {
  20. var block = new ProtoBlock(name);
  21. block.palette = palettes.dict['logic'];
  22. blocks.protoBlockDict[name] = block;
  23. block.staticLabels.push(label);
  24. block.adjustWidthToLabel();
  25. block.twoArgMathBlock();
  26. block.defaults.push(1);
  27. block.defaults.push(1);
  28. };
  29. var LogicArgBlock = function (name, label) {
  30. var block = new ProtoBlock(name);
  31. block.palette = palettes.dict['logic'];
  32. blocks.protoBlockDict[name] = block;
  33. block.staticLabels.push(label);
  34. block.adjustWidthToLabel();
  35. block.oneArgMathBlock();
  36. block.defaults.push(0);
  37. };
  38. //* block:myxor *// LogicTwoArgBlock('myxor', 'XOR');
  39. //* arg:myxor *// block.value = logo.parseArg(logo, turtle, conns[1]) >> logo.parseArg(logo, turtle, conns[2]);
  40. //* block:myand *// LogicTwoArgBlock('myand', 'AND');
  41. //* arg:myand *// block.value = logo.parseArg(logo, turtle, conns[1]) & logo.parseArg(logo, turtle, conns[2]);
  42. //* block:myor *// LogicTwoArgBlock('myor', 'OR');
  43. //* arg:myor *// block.value = logo.parseArg(logo, turtle, conns[1]) | logo.parseArg(logo, turtle, conns[2]);
  44. //* block:mysl *// LogicTwoArgBlock('mysl', '&lt;&lt;');
  45. //* arg:mysl *// block.value = logo.parseArg(logo, turtle, conns[1]) << logo.parseArg(logo, turtle, conns[2]);
  46. //* block:mysr *// LogicTwoArgBlock('mysr', '&gt;&gt;');
  47. //* arg:mysr *// block.value = logo.parseArg(logo, turtle, conns[1]) >> logo.parseArg(logo, turtle, conns[2]);
  48. //* block:mynot *// LogicArgBlock('mynot', 'NOT');
  49. //* arg:mynot *// block.value = ~ logo.parseArg(logo, turtle, conns[1]);
  50. //* palette-icon:logic *//
  51. <svg xmlns="http://www.w3.org/2000/svg" width="55" height="55" viewBox="0 0 55 55"><g transform="matrix(1.25 0 0 1.25-7.5-6.25)"><g font-family="Sans" word-spacing="0" line-height="125%" letter-spacing="0" font-size="11"><text x="33.891" y="39.844"><tspan x="33.891" y="39.844" fill="#fff">0</tspan></text><g fill="#000"><text x="33.792" y="27"><tspan x="33.792" y="27" fill="#fff">1</tspan></text><text x="19.18" y="40"><tspan x="19.18" y="40" fill="#fff">1</tspan></text><text x="19.275" y="26.844"><tspan x="19.275" y="26.844" fill="#fff">0</tspan></text></g></g><g fill="#fff" stroke="#fff"><path d="m10.5 14.5h35"/><path d="m15.5 44.5v-35"/></g></g></svg>
  52. //* palette-fill:logic *// #ff00ff
  53. //* palette-stroke:logic *// #C700D3
  54. //* palette-highlight:logic *// #FF9FFF
  55. //* palette-stroke-highlight:logic *// #000000