| 139 | } |
| 140 | |
| 141 | export default class BarElement extends Element { |
| 142 | |
| 143 | static id = class="st">'bar'; |
| 144 | |
| 145 | /** |
| 146 | * @type {any} |
| 147 | */ |
| 148 | static defaults = { |
| 149 | borderSkipped: class="st">'start', |
| 150 | borderWidth: 0, |
| 151 | borderRadius: 0, |
| 152 | inflateAmount: class="st">'auto', |
| 153 | pointStyle: undefined |
| 154 | }; |
| 155 | |
| 156 | /** |
| 157 | * @type {any} |
| 158 | */ |
| 159 | static defaultRoutes = { |
| 160 | backgroundColor: class="st">'backgroundColor', |
| 161 | borderColor: class="st">'borderColor' |
| 162 | }; |
| 163 | |
| 164 | constructor(cfg) { |
| 165 | super(); |
| 166 | |
| 167 | this.options = undefined; |
| 168 | this.horizontal = undefined; |
| 169 | this.base = undefined; |
| 170 | this.width = undefined; |
| 171 | this.height = undefined; |
| 172 | this.inflateAmount = undefined; |
| 173 | |
| 174 | if (cfg) { |
| 175 | Object.assign(this, cfg); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | draw(ctx) { |
| 180 | const {inflateAmount, options: {borderColor, backgroundColor}} = this; |
| 181 | const {inner, outer} = boundingRects(this); |
| 182 | const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath; |
| 183 | |
| 184 | ctx.save(); |
| 185 | |
| 186 | if (outer.w !== inner.w || outer.h !== inner.h) { |
| 187 | ctx.beginPath(); |
| 188 | addRectPath(ctx, inflateRect(outer, inflateAmount, inner)); |
| 189 | ctx.clip(); |
| 190 | addRectPath(ctx, inflateRect(inner, -inflateAmount, outer)); |
| 191 | ctx.fillStyle = borderColor; |
| 192 | ctx.fill(class="st">'evenodd'); |
| 193 | } |
| 194 | |
| 195 | ctx.beginPath(); |
| 196 | addRectPath(ctx, inflateRect(inner, inflateAmount)); |
| 197 | ctx.fillStyle = backgroundColor; |
| 198 | ctx.fill(); |
nothing calls this directly
no outgoing calls
no test coverage detected