UNPKG

@up-group-ui/react-controls

Version:
40 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Shape = (function () { function Shape(x, y, w, h, fill, ref) { var _this = this; this.draw = function (ctx) { ctx.fillStyle = 'rgba(5,203,133,.1)'; ctx.fillRect(_this.x, _this.y, _this.w, _this.h); ctx.strokeStyle = '#434343'; ctx.lineWidth = 2; ctx.strokeRect(_this.x, _this.y, _this.w, _this.h); if (_this.ref) { var centerX = _this.x - 20; var centerY = _this.y + 5; var radius = 15; ctx.beginPath(); ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI, false); ctx.fillStyle = 'rgba(5,203,133,.6)'; ctx.fill(); ctx.textBaseline = 'middle'; ctx.font = 'bold 18pt Calibri'; ctx.textAlign = 'center'; ctx.fillStyle = '#FFFFFF'; ctx.fillText(_this.ref, centerX, centerY, 10); } }; this.contains = function (mx, my, scale) { return (_this.x / scale <= mx && _this.x / scale + _this.w >= mx && _this.y / scale <= my && _this.y / scale + _this.h >= my); }; this.x = x || 0; this.y = y || 0; this.w = w || 1; this.h = h || 1; this.ref = ref || ''; this.fill = fill; } return Shape; }()); exports.default = Shape; //# sourceMappingURL=Shape.js.map