1 | import { __extends } from "tslib";
|
2 | import Path from '../Path.js';
|
3 | import * as roundRectHelper from '../helper/roundRect.js';
|
4 | import { subPixelOptimizeRect } from '../helper/subPixelOptimize.js';
|
5 | var RectShape = (function () {
|
6 | function RectShape() {
|
7 | this.x = 0;
|
8 | this.y = 0;
|
9 | this.width = 0;
|
10 | this.height = 0;
|
11 | }
|
12 | return RectShape;
|
13 | }());
|
14 | export { RectShape };
|
15 | var subPixelOptimizeOutputShape = {};
|
16 | var Rect = (function (_super) {
|
17 | __extends(Rect, _super);
|
18 | function Rect(opts) {
|
19 | return _super.call(this, opts) || this;
|
20 | }
|
21 | Rect.prototype.getDefaultShape = function () {
|
22 | return new RectShape();
|
23 | };
|
24 | Rect.prototype.buildPath = function (ctx, shape) {
|
25 | var x;
|
26 | var y;
|
27 | var width;
|
28 | var height;
|
29 | if (this.subPixelOptimize) {
|
30 | var optimizedShape = subPixelOptimizeRect(subPixelOptimizeOutputShape, shape, this.style);
|
31 | x = optimizedShape.x;
|
32 | y = optimizedShape.y;
|
33 | width = optimizedShape.width;
|
34 | height = optimizedShape.height;
|
35 | optimizedShape.r = shape.r;
|
36 | shape = optimizedShape;
|
37 | }
|
38 | else {
|
39 | x = shape.x;
|
40 | y = shape.y;
|
41 | width = shape.width;
|
42 | height = shape.height;
|
43 | }
|
44 | if (!shape.r) {
|
45 | ctx.rect(x, y, width, height);
|
46 | }
|
47 | else {
|
48 | roundRectHelper.buildPath(ctx, shape);
|
49 | }
|
50 | };
|
51 | Rect.prototype.isZeroArea = function () {
|
52 | return !this.shape.width || !this.shape.height;
|
53 | };
|
54 | return Rect;
|
55 | }(Path));
|
56 | Rect.prototype.type = 'rect';
|
57 | export default Rect;
|