XFA - Draw arcs correctly

- it aims to fix #14315;
- take into account the startAngle to compute the coordinates of the final point.
This commit is contained in:
Calixte Denizet 2021-11-27 17:34:05 +01:00
parent e439f4d620
commit 31e13515f5
4 changed files with 12 additions and 4 deletions

View File

@ -475,7 +475,7 @@ class Arc extends XFAObject {
}, },
}; };
if (this.startAngle === 0 && this.sweepAngle === 360) { if (this.sweepAngle === 360) {
arc = { arc = {
name: "ellipse", name: "ellipse",
attributes: { attributes: {
@ -490,12 +490,12 @@ class Arc extends XFAObject {
} else { } else {
const startAngle = (this.startAngle * Math.PI) / 180; const startAngle = (this.startAngle * Math.PI) / 180;
const sweepAngle = (this.sweepAngle * Math.PI) / 180; const sweepAngle = (this.sweepAngle * Math.PI) / 180;
const largeArc = this.sweepAngle - this.startAngle > 180 ? 1 : 0; const largeArc = this.sweepAngle > 180 ? 1 : 0;
const [x1, y1, x2, y2] = [ const [x1, y1, x2, y2] = [
50 * (1 + Math.cos(startAngle)), 50 * (1 + Math.cos(startAngle)),
50 * (1 - Math.sin(startAngle)), 50 * (1 - Math.sin(startAngle)),
50 * (1 + Math.cos(sweepAngle)), 50 * (1 + Math.cos(startAngle + sweepAngle)),
50 * (1 - Math.sin(sweepAngle)), 50 * (1 - Math.sin(startAngle + sweepAngle)),
]; ];
arc = { arc = {

View File

@ -489,3 +489,4 @@
!issue14267.pdf !issue14267.pdf
!PDFBOX-4352-0.pdf !PDFBOX-4352-0.pdf
!REDHAT-1531897-0.pdf !REDHAT-1531897-0.pdf
!xfa_issue14315.pdf

Binary file not shown.

View File

@ -1037,6 +1037,13 @@
"lastPage": 1, "lastPage": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "xfa_issue14315",
"file": "pdfs/xfa_issue14315.pdf",
"md5": "e239710875f9dea72fd94c20672a29e1",
"rounds": 1,
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_issue14071", { "id": "xfa_issue14071",
"file": "pdfs/xfa_issue14071.pdf", "file": "pdfs/xfa_issue14071.pdf",
"md5": "7ef09705091602668ce22086c83a90f3", "md5": "7ef09705091602668ce22086c83a90f3",