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.

86 lines
2.6 KiB

  1. // Copyright (c) 2016,17 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. // The trashcan is an area at the bottom of the screen where stacks of
  12. // blocks can be dragged. Once in the trash area, they are marked as
  13. // trash and hidden. There is a menu button that can be used to
  14. // restore trash.
  15. requirejs(['activity/utils']);
  16. var BOUNDARYWIDTH = 1200;
  17. var BOUNDARYHEIGHT = 900;
  18. function Boundary () {
  19. this._stage = null;
  20. this._container = null;
  21. this.setStage = function (stage) {
  22. this._stage = stage;
  23. return this;
  24. };
  25. this.resizeEvent = function (scale) {
  26. };
  27. this.init = function () {
  28. this._container = new createjs.Container();
  29. this._stage.addChild(this._container);
  30. this._stage.setChildIndex(this._container, 0);
  31. };
  32. this.setScale = function (w, h, scale) {
  33. this.destroy();
  34. this.create(w, h, scale);
  35. };
  36. this.destroy = function () {
  37. if (this._container.children.length > 0) {
  38. this._container.removeChild(this._container.children[0]);
  39. }
  40. };
  41. this.offScreen = function (x, y) {
  42. return (x < this.x || x > this.x + this.dx || y < this.y || y > this.y + this.dy);
  43. };
  44. this.create = function (w, h, scale) {
  45. this.w = w / scale;
  46. this.x = 55 + 13;
  47. this.dx = this.w - (110 + 26);
  48. this.h = h / scale;
  49. this.y = 55 + 13;
  50. this.dy = this.h - (55 + 26);
  51. that = this;
  52. function __makeBoundary() {
  53. var img = new Image();
  54. img.onload = function () {
  55. bitmap = new createjs.Bitmap(img);
  56. that._container.addChild(bitmap);
  57. };
  58. img.src = 'data:image/svg+xml;base64,' + window.btoa(
  59. unescape(encodeURIComponent(BOUNDARY.replace('HEIGHT', that.h).replace('WIDTH', that.w).replace('Y', that.y).replace('X', that.x).replace('DY', that.dy).replace('DX', that.dx).replace('stroke_color', '#e08080'))));
  60. };
  61. __makeBoundary();
  62. };
  63. this.hide = function () {
  64. this._container.visible = false;
  65. };
  66. this.show = function () {
  67. this._container.visible = true;
  68. };
  69. };