}
draw(ctx) {
- var options = this.options;
- var rects = boundingRects(this);
- var outer = rects.outer;
- var inner = rects.inner;
+ const options = this.options;
+ const {inner, outer} = boundingRects(this);
- ctx.fillStyle = options.backgroundColor;
- ctx.fillRect(outer.x, outer.y, outer.w, outer.h);
+ ctx.save();
- if (outer.w === inner.w && outer.h === inner.h) {
- return;
+ if (outer.w !== inner.w || outer.h !== inner.h) {
+ ctx.beginPath();
+ ctx.rect(outer.x, outer.y, outer.w, outer.h);
+ ctx.clip();
+ ctx.rect(inner.x, inner.y, inner.w, inner.h);
+ ctx.fillStyle = options.borderColor;
+ ctx.fill('evenodd');
}
- ctx.save();
- ctx.beginPath();
- ctx.rect(outer.x, outer.y, outer.w, outer.h);
- ctx.clip();
- ctx.fillStyle = options.borderColor;
- ctx.rect(inner.x, inner.y, inner.w, inner.h);
- ctx.fill('evenodd');
+ ctx.fillStyle = options.backgroundColor;
+ ctx.fillRect(inner.x, inner.y, inner.w, inner.h);
+
ctx.restore();
}