MCPcopy Create free account
hub / github.com/LibPDF-js/core / createLinearGradient

Method createLinearGradient

src/api/pdf.ts:2289–2295  ·  view source on GitHub ↗

* Create a linear gradient using angle and length (CSS-style). * * @param options - Gradient options including angle, length, and color stops * @returns PDFShading resource for use with page.registerShading() * * @example * ```typescript * const gradient = pdf.createLinearGradie

(options: LinearGradientOptions)

Source from the content-addressed store, hash-verified

2287 * ```
2288 */
2289 createLinearGradient(options: LinearGradientOptions): PDFShading {
2290 const coords = PDFShading.calculateAxialCoords(options.angle, options.length);
2291 const dict = PDFShading.createAxialDict({ coords, stops: options.stops });
2292 const ref = this.register(dict);
2293
2294 return new PDFShading(ref, "axial");
2295 }
2296
2297 // ─────────────────────────────────────────────────────────────────────────────
2298 // Low-Level Drawing API - Patterns

Callers 2

factory.test.tsFile · 0.80

Calls 3

registerMethod · 0.95
calculateAxialCoordsMethod · 0.80
createAxialDictMethod · 0.80

Tested by

no test coverage detected