Merge pull request #17514 from calixteman/issue17418
[Editor] Draw a line instead of a Bezier curve when an Ink has only one point
This commit is contained in:
commit
7769018316
@ -4397,6 +4397,11 @@ class InkAnnotation extends MarkupAnnotation {
|
|||||||
buffer.push(
|
buffer.push(
|
||||||
`${numberToString(bezier[0])} ${numberToString(bezier[1])} m`
|
`${numberToString(bezier[0])} ${numberToString(bezier[1])} m`
|
||||||
);
|
);
|
||||||
|
if (bezier.length === 2) {
|
||||||
|
buffer.push(
|
||||||
|
`${numberToString(bezier[0])} ${numberToString(bezier[1])} l S`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
for (let i = 2, ii = bezier.length; i < ii; i += 6) {
|
for (let i = 2, ii = bezier.length; i < ii; i += 6) {
|
||||||
const curve = bezier
|
const curve = bezier
|
||||||
.slice(i, i + 6)
|
.slice(i, i + 6)
|
||||||
@ -4405,6 +4410,7 @@ class InkAnnotation extends MarkupAnnotation {
|
|||||||
buffer.push(`${curve} c`);
|
buffer.push(`${curve} c`);
|
||||||
}
|
}
|
||||||
buffer.push("S");
|
buffer.push("S");
|
||||||
|
}
|
||||||
appearanceBuffer.push(buffer.join("\n"));
|
appearanceBuffer.push(buffer.join("\n"));
|
||||||
}
|
}
|
||||||
const appearance = appearanceBuffer.join("\n");
|
const appearance = appearanceBuffer.join("\n");
|
||||||
|
@ -628,7 +628,7 @@ class InkEditor extends AnnotationEditor {
|
|||||||
|
|
||||||
this.parent.addInkEditorIfNeeded(/* isCommitting = */ true);
|
this.parent.addInkEditorIfNeeded(/* isCommitting = */ true);
|
||||||
|
|
||||||
// When commiting, the position of this editor is changed, hence we must
|
// When committing, the position of this editor is changed, hence we must
|
||||||
// move it to the right position in the DOM.
|
// move it to the right position in the DOM.
|
||||||
this.moveInDOM();
|
this.moveInDOM();
|
||||||
this.div.focus({
|
this.div.focus({
|
||||||
@ -994,6 +994,14 @@ class InkEditor extends AnnotationEditor {
|
|||||||
const points = [];
|
const points = [];
|
||||||
for (let j = 0, jj = bezier.length; j < jj; j++) {
|
for (let j = 0, jj = bezier.length; j < jj; j++) {
|
||||||
const [first, control1, control2, second] = bezier[j];
|
const [first, control1, control2, second] = bezier[j];
|
||||||
|
if (first[0] === second[0] && first[1] === second[1] && jj === 1) {
|
||||||
|
// We have only one point.
|
||||||
|
const p0 = s * first[0] + shiftX;
|
||||||
|
const p1 = s * first[1] + shiftY;
|
||||||
|
buffer.push(p0, p1);
|
||||||
|
points.push(p0, p1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
const p10 = s * first[0] + shiftX;
|
const p10 = s * first[0] + shiftX;
|
||||||
const p11 = s * first[1] + shiftY;
|
const p11 = s * first[1] + shiftY;
|
||||||
const p20 = s * control1[0] + shiftX;
|
const p20 = s * control1[0] + shiftX;
|
||||||
|
@ -8458,5 +8458,43 @@
|
|||||||
"structTreeParentId": null
|
"structTreeParentId": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue17418",
|
||||||
|
"file": "pdfs/empty.pdf",
|
||||||
|
"md5": "2bfd06746bd5c2e6fc3492c83c152bc5",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"save": true,
|
||||||
|
"print": true,
|
||||||
|
"annotationStorage": {
|
||||||
|
"pdfjs_internal_editor_0": {
|
||||||
|
"annotationType": 15,
|
||||||
|
"color": [ 53, 228, 47 ],
|
||||||
|
"thickness": 20,
|
||||||
|
"opacity": 1,
|
||||||
|
"paths": [
|
||||||
|
{
|
||||||
|
"bezier": [
|
||||||
|
279.9183673469388,
|
||||||
|
477.0105263157895
|
||||||
|
],
|
||||||
|
"points": [
|
||||||
|
279.9183673469388,
|
||||||
|
477.0105263157895
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pageIndex": 0,
|
||||||
|
"rect": [
|
||||||
|
269.9183673469388,
|
||||||
|
443.93684210526317,
|
||||||
|
312.9387755102041,
|
||||||
|
487.0105263157895
|
||||||
|
],
|
||||||
|
"rotation": 0,
|
||||||
|
"structTreeParentId": null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user