| 122253 | return gradient2; |
| 122254 | } |
| 122255 | function gradient(context26, spec, bounds2) { |
| 122256 | const w5 = bounds2.width(), h10 = bounds2.height(); |
| 122257 | let gradient3; |
| 122258 | if (spec.gradient === "radial") gradient3 = context26.createRadialGradient(bounds2.x1 + value(spec.x1, 0.5) * w5, bounds2.y1 + value(spec.y1, 0.5) * h10, Math.max(w5, h10) * value(spec.r1, 0), bounds2.x1 + value(spec.x2, 0.5) * w5, bounds2.y1 + value(spec.y2, 0.5) * h10, Math.max(w5, h10) * value(spec.r2, 0.5)); |
| 122259 | else { |
| 122260 | // linear gradient |
| 122261 | const x1 = value(spec.x1, 0), y1 = value(spec.y1, 0), x2 = value(spec.x2, 1), y2 = value(spec.y2, 0); |
| 122262 | if (x1 === x2 || y1 === y2 || w5 === h10) // axis aligned: use normal gradient |
| 122263 | gradient3 = context26.createLinearGradient(bounds2.x1 + x1 * w5, bounds2.y1 + y1 * h10, bounds2.x1 + x2 * w5, bounds2.y1 + y2 * h10); |
| 122264 | else { |
| 122265 | // not axis aligned: render gradient into a pattern (#2365) |
| 122266 | // this allows us to use normalized bounding box coordinates |
| 122267 | const image1 = (0, _vegaCanvas.canvas)(Math.ceil(w5), Math.ceil(h10)), ictx = image1.getContext("2d"); |
| 122268 | ictx.scale(w5, h10); |
| 122269 | ictx.fillStyle = addStops(ictx.createLinearGradient(x1, y1, x2, y2), spec.stops); |
| 122270 | ictx.fillRect(0, 0, w5, h10); |
| 122271 | return context26.createPattern(image1, "no-repeat"); |
| 122272 | } |
| 122273 | } |
| 122274 | return addStops(gradient3, spec.stops); |
| 122275 | } |
| 122276 | function color(context27, item, value5) { |
| 122277 | return isGradient(value5) ? gradient(context27, value5, item.bounds) : value5; |
| 122278 | } |