mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[Editor] Refactor the free highlight stuff in order to be able to use the code for more general drawing
One goal is to make the code for drawing with the Ink tool similar to the one to free highlighting: it doesn't really make sense to have so different ways to do almost the same thing. When the zoom level is high, it'll avoid to create a too big canvas covering all the page which consume more memory, makes the drawing very slow and the overall user xp pretty bad. A second goal is to be able to easily implement more drawing tools where we would just have to implement how to draw from the pointer coordinates.
This commit is contained in:
parent
9108848743
commit
5a9607b2ad
7 changed files with 633 additions and 476 deletions
|
@ -25,7 +25,7 @@ const {
|
|||
TextLayer,
|
||||
XfaLayer,
|
||||
} = pdfjsLib;
|
||||
const { Outliner } = pdfjsTestingUtils;
|
||||
const { HighlightOutliner } = pdfjsTestingUtils;
|
||||
const { GenericL10n, parseQueryString, SimpleLinkService } = pdfjsViewer;
|
||||
|
||||
const WAITING_TIME = 100; // ms
|
||||
|
@ -370,19 +370,19 @@ class Rasterize {
|
|||
}
|
||||
// We set the borderWidth to 0.001 to slighly increase the size of the
|
||||
// boxes so that they can be merged together.
|
||||
const outliner = new Outliner(boxes, /* borderWidth = */ 0.001);
|
||||
const outliner = new HighlightOutliner(boxes, /* borderWidth = */ 0.001);
|
||||
// We set the borderWidth to 0.0025 in order to have an outline which is
|
||||
// slightly bigger than the highlight itself.
|
||||
// We must add an inner margin to avoid to have a partial outline.
|
||||
const outlinerForOutline = new Outliner(
|
||||
const outlinerForOutline = new HighlightOutliner(
|
||||
boxes,
|
||||
/* borderWidth = */ 0.0025,
|
||||
/* innerMargin = */ 0.001
|
||||
);
|
||||
const drawLayer = new DrawLayer({ pageIndex: 0 });
|
||||
drawLayer.setParent(div);
|
||||
drawLayer.highlight(outliner.getOutlines(), "orange", 0.4);
|
||||
drawLayer.highlightOutline(outlinerForOutline.getOutlines());
|
||||
drawLayer.draw(outliner.getOutlines(), "orange", 0.4);
|
||||
drawLayer.drawOutline(outlinerForOutline.getOutlines());
|
||||
|
||||
svg.append(foreignObject);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue