@up-group/react-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
41 lines • 1.57 kB
JavaScript
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
;