-
Notifications
You must be signed in to change notification settings - Fork 0
fix(masks): use luminosity mask by default - CU-86c97q74b #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -689,9 +689,9 @@ export default function (doc, svg, x, y, options) { | |
| doc.page.xobjects[group.name] = group.xobj; | ||
| doc.addContent('/' + group.name + ' Do'); | ||
| } | ||
| function docApplyMask(group) { | ||
| let name = 'M' + (doc._maskCount = (doc._maskCount || 0) + 1); | ||
| let gstate = doc.ref({ | ||
| function docApplyAlphaMask(group) { | ||
| const name = 'M' + (doc._maskCount = (doc._maskCount || 0) + 1); | ||
| const gstate = doc.ref({ | ||
| Type: 'ExtGState', | ||
| CA: 1, | ||
| ca: 1, | ||
|
Comment on lines
+692
to
697
|
||
|
|
@@ -706,6 +706,28 @@ export default function (doc, svg, x, y, options) { | |
| doc.page.ext_gstates[name] = gstate; | ||
| doc.addContent('/' + name + ' gs'); | ||
| } | ||
| function docApplyMask(group) { | ||
| const name = 'M' + (doc._maskCount = (doc._maskCount || 0) + 1); | ||
| // backdrop should be black | ||
| let bc = [0, 0, 0]; | ||
| if (doc._activeColorProfile && doc._activeColorProfile.type === 'cmyk') { | ||
| bc = [1, 1, 1, 1]; | ||
| } | ||
| const gstate = doc.ref({ | ||
| Type: 'ExtGState', | ||
| CA: 1, | ||
| ca: 1, | ||
| BM: 'Normal', | ||
| SMask: { | ||
| S: 'Luminosity', | ||
| G: group.xobj, | ||
| BC: bc, | ||
| }, | ||
| }); | ||
| gstate.end(); | ||
| doc.page.ext_gstates[name] = gstate; | ||
| doc.addContent('/' + name + ' gs'); | ||
| } | ||
| function applyBlendMode(group, blendMode) { | ||
| // map svg blendMode to pdf | ||
| const key = String(blendMode || '').toLowerCase(); | ||
|
|
@@ -3297,7 +3319,7 @@ export default function (doc, svg, x, y, options) { | |
| this.drawChildren(true, false); | ||
| doc.restore(); | ||
| docEndGroup(group); | ||
| docApplyMask(group); | ||
| docApplyAlphaMask(group); | ||
| }; | ||
| }; | ||
|
|
||
|
|
@@ -3321,11 +3343,16 @@ export default function (doc, svg, x, y, options) { | |
| if (this.attr('maskContentUnits') === 'objectBoundingBox') { | ||
| doc.transform(bBox[2] - bBox[0], 0, 0, bBox[3] - bBox[1], bBox[0], bBox[1]); | ||
| } | ||
| const maskType = this.attr('mask-type') ?? 'luminance'; | ||
| this.clip(); | ||
| this.drawChildren(false, true); | ||
| doc.restore(); | ||
| docEndGroup(group); | ||
| docApplyMask(group); | ||
| if (maskType === 'alpha') { | ||
| docApplyAlphaMask(group); | ||
| } else { | ||
| docApplyMask(group); | ||
| } | ||
|
Comment on lines
+3346
to
+3355
|
||
| }; | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The public
iccProfile(...)API now accepts a newtypeparameter, but the TypeScript declarations still expose only 4 parameters (seetypes/pdfkit.d.ts). Please update the.d.tssignature to keep the public API consistent for typed consumers.