From 325647332dae7995a3d78ee2d3c15eff916f611f Mon Sep 17 00:00:00 2001 From: Andrew Dillon Date: Mon, 25 May 2020 09:04:59 -0500 Subject: [PATCH] Make lineCap prop optional (#460) * Make lineCap prop optional * Update tests * Cleanup --- apps/deno/tests/test3.ts | 8 +++++++- apps/node/tests/test3.ts | 8 +++++++- apps/rn/src/tests/test3.js | 8 +++++++- apps/web/test3.html | 8 +++++++- src/api/PDFPageOptions.ts | 2 +- src/api/operations.ts | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/apps/deno/tests/test3.ts b/apps/deno/tests/test3.ts index 69250ade4..bba677e14 100644 --- a/apps/deno/tests/test3.ts +++ b/apps/deno/tests/test3.ts @@ -72,13 +72,19 @@ export default async (assets: Assets) => { end: { x: 30 + lastPageTextWidth, y: 205 }, color: hotPink, thickness: 5, - lineCap: LineCapStyle.Round, }); page2.drawImage(cmykImage, { ...cmykDims, x: 30, y: 30, }); + page2.drawLine({ + start: { x: 30, y: 240 }, + end: { x: 30 + lastPageTextWidth, y: 240 }, + color: hotPink, + thickness: 5, + lineCap: LineCapStyle.Round, + }); console.log('Title:', pdfDoc.getTitle()); console.log('Author:', pdfDoc.getAuthor()); diff --git a/apps/node/tests/test3.ts b/apps/node/tests/test3.ts index ee431c922..2c0e14c9c 100644 --- a/apps/node/tests/test3.ts +++ b/apps/node/tests/test3.ts @@ -71,13 +71,19 @@ export default async (assets: Assets) => { end: { x: 30 + lastPageTextWidth, y: 205 }, color: hotPink, thickness: 5, - lineCap: LineCapStyle.Round, }); page2.drawImage(cmykImage, { ...cmykDims, x: 30, y: 30, }); + page2.drawLine({ + start: { x: 30, y: 240 }, + end: { x: 30 + lastPageTextWidth, y: 240 }, + color: hotPink, + thickness: 5, + lineCap: LineCapStyle.Round, + }); console.log('Title:', pdfDoc.getTitle()); console.log('Author:', pdfDoc.getAuthor()); diff --git a/apps/rn/src/tests/test3.js b/apps/rn/src/tests/test3.js index e80c7bddb..a69b54195 100644 --- a/apps/rn/src/tests/test3.js +++ b/apps/rn/src/tests/test3.js @@ -72,13 +72,19 @@ export default async () => { end: { x: 30 + lastPageTextWidth, y: 205 }, color: hotPink, thickness: 5, - lineCap: LineCapStyle.Round, }); page2.drawImage(cmykImage, { ...cmykDims, x: 30, y: 30, }); + page2.drawLine({ + start: { x: 30, y: 240 }, + end: { x: 30 + lastPageTextWidth, y: 240 }, + color: hotPink, + thickness: 5, + lineCap: LineCapStyle.Round, + }); console.log('Title:', pdfDoc.getTitle()); console.log('Author:', pdfDoc.getAuthor()); diff --git a/apps/web/test3.html b/apps/web/test3.html index f80fc921b..d0aef5f09 100644 --- a/apps/web/test3.html +++ b/apps/web/test3.html @@ -120,13 +120,19 @@ end: { x: 30 + lastPageTextWidth, y: 205 }, color: hotPink, thickness: 5, - lineCap: LineCapStyle.Round, }); page2.drawImage(cmykImage, { ...cmykDims, x: 30, y: 30, }); + page2.drawLine({ + start: { x: 30, y: 240 }, + end: { x: 30 + lastPageTextWidth, y: 240 }, + color: hotPink, + thickness: 5, + lineCap: LineCapStyle.Round, + }); console.log('Title:', pdfDoc.getTitle()); console.log('Author:', pdfDoc.getAuthor()); diff --git a/src/api/PDFPageOptions.ts b/src/api/PDFPageOptions.ts index c90d42376..114e4443a 100644 --- a/src/api/PDFPageOptions.ts +++ b/src/api/PDFPageOptions.ts @@ -55,9 +55,9 @@ export interface PDFPageDrawRectangleOptions { export interface PDFPageDrawLineOptions { start: { x: number; y: number }; end: { x: number; y: number }; - lineCap: LineCapStyle | undefined; thickness?: number; color?: Color; + lineCap?: LineCapStyle; } export interface PDFPageDrawSquareOptions { diff --git a/src/api/operations.ts b/src/api/operations.ts index a7c17344b..549500282 100644 --- a/src/api/operations.ts +++ b/src/api/operations.ts @@ -135,8 +135,8 @@ export const drawLine = (options: { start: { x: number | PDFNumber; y: number | PDFNumber }; end: { x: number | PDFNumber; y: number | PDFNumber }; thickness: number | PDFNumber; - lineCap: LineCapStyle | undefined; color: Color | undefined; + lineCap?: LineCapStyle; }) => [ pushGraphicsState(),