mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
[Editor] Add the possibility to change line opacity in Ink editor
This commit is contained in:
parent
45b9e8417d
commit
7831a100b3
10 changed files with 215 additions and 19 deletions
|
@ -3757,7 +3757,7 @@ class InkAnnotation extends MarkupAnnotation {
|
|||
}
|
||||
|
||||
static async createNewAppearanceStream(annotation, xref, params) {
|
||||
const { color, rect, rotation, paths, thickness } = annotation;
|
||||
const { color, rect, rotation, paths, thickness, opacity } = annotation;
|
||||
const [x1, y1, x2, y2] = rect;
|
||||
let w = x2 - x1;
|
||||
let h = y2 - y1;
|
||||
|
@ -3770,6 +3770,11 @@ class InkAnnotation extends MarkupAnnotation {
|
|||
`${thickness} w 1 J 1 j`,
|
||||
`${getPdfColor(color, /* isFill */ false)}`,
|
||||
];
|
||||
|
||||
if (opacity !== 1) {
|
||||
appearanceBuffer.push("/R0 gs");
|
||||
}
|
||||
|
||||
const buffer = [];
|
||||
for (const { bezier } of paths) {
|
||||
buffer.length = 0;
|
||||
|
@ -3800,6 +3805,17 @@ class InkAnnotation extends MarkupAnnotation {
|
|||
appearanceStreamDict.set("Matrix", matrix);
|
||||
}
|
||||
|
||||
if (opacity !== 1) {
|
||||
const resources = new Dict(xref);
|
||||
const extGState = new Dict(xref);
|
||||
const r0 = new Dict(xref);
|
||||
r0.set("CA", opacity);
|
||||
r0.set("Type", Name.get("ExtGState"));
|
||||
extGState.set("R0", r0);
|
||||
resources.set("ExtGState", extGState);
|
||||
appearanceStreamDict.set("Resources", resources);
|
||||
}
|
||||
|
||||
const ap = new StringStream(appearance);
|
||||
ap.dict = appearanceStreamDict;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue