Skip to content

Commit

Permalink
chore: make cx and cy optional in Circle and Ellipse (#2314)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj authored May 31, 2023
1 parent dfb46c1 commit d6018d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/warm-needles-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@react-pdf/renderer': patch
'@react-pdf/render': patch
---

Make `cx` and `cy` optional in `Circle` and `Ellipse`
2 changes: 1 addition & 1 deletion packages/render/src/primitives/renderEllipse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0);

export const drawEllipse = (ctx, cx, cy, rx, ry) => {
export const drawEllipse = (ctx, cx = 0, cy = 0, rx, ry) => {
const x = cx - rx;
const y = cy - ry;
const ox = rx * KAPPA;
Expand Down
10 changes: 5 additions & 5 deletions packages/renderer/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ declare namespace ReactPDF {
language?: string;
pdfVersion?: PDFVersion;
pageMode?: PageMode;
pageLayout ?: PageLayout;
pageLayout?: PageLayout;
onRender?: (props: OnRenderProps) => any;
}

Expand Down Expand Up @@ -318,8 +318,8 @@ declare namespace ReactPDF {

interface CircleProps extends SVGPresentationAttributes {
style?: SVGPresentationAttributes;
cx: string | number;
cy: string | number;
cx?: string | number;
cy?: string | number;
r: string | number;
}

Expand All @@ -330,8 +330,8 @@ declare namespace ReactPDF {

interface EllipseProps extends SVGPresentationAttributes {
style?: SVGPresentationAttributes;
cx: string | number;
cy: string | number;
cx?: string | number;
cy?: string | number;
rx: string | number;
ry: string | number;
}
Expand Down

0 comments on commit d6018d5

Please sign in to comment.