diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b01a0e5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: Current File", + "type": "debugpy", + "request": "launch", + "program": "src/rmc/cli.py", + "args": ["/home/rob/Dropbox/reMarkable/xochitl/29b36d85-0318-4162-82e6-20be5ac2363f/668493a4-3959-4bbe-9e69-9c7b8ab034c7.rm", + "-o", "/tmp/tmp.oyxSeaWZWE/p2.svg"], + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/src/rmc/exporters/svg.py b/src/rmc/exporters/svg.py index 2e78638..05b55f2 100644 --- a/src/rmc/exporters/svg.py +++ b/src/rmc/exporters/svg.py @@ -77,6 +77,26 @@ def blocks_to_svg(blocks: Iterable[Block], output, debug=0): # get document dimensions svg_doc_info = get_dimensions(blocks, debug) + firstBlocks = [] + secondBlocks = [] + + for block in blocks: + if isinstance(block, SceneLineItemBlock): + if block.value is not None: + # check if it's a highlighter block + if block.value.tool.name.startswith("HIGHLIGHTER"): + # put it in the first blocks + firstBlocks.append(block) + continue + + secondBlocks.append(block) + + elif isinstance(block, RootTextBlock): + secondBlocks.append(block) + else: + if debug > 0: + print(f'warning: not converting block: {block.__class__}') + # add svg header output.write(SVG_HEADER.substitute(height=svg_doc_info.height, width=svg_doc_info.width)) output.write('\n') @@ -85,14 +105,13 @@ def blocks_to_svg(blocks: Iterable[Block], output, debug=0): output.write(' \n') output.write(' \n') - for block in blocks: - if isinstance(block, SceneLineItemBlock): - draw_stroke(block, output, svg_doc_info, debug) - elif isinstance(block, RootTextBlock): - draw_text(block, output, svg_doc_info, debug) - else: - if debug > 0: - print(f'warning: not converting block: {block.__class__}') + for blockGroup in [firstBlocks, secondBlocks]: + for block in blockGroup: + if isinstance(block, SceneLineItemBlock): + draw_stroke(block, output, svg_doc_info, debug) + elif isinstance(block, RootTextBlock): + draw_text(block, output, svg_doc_info, debug) + # Overlay the page with a clickable rect to flip pages output.write('\n') diff --git a/src/rmc/exporters/writing_tools.py b/src/rmc/exporters/writing_tools.py index 9023779..ad02c3a 100644 --- a/src/rmc/exporters/writing_tools.py +++ b/src/rmc/exporters/writing_tools.py @@ -20,14 +20,12 @@ 1: [125, 125, 125], # WHITE = 2 2: [255, 255, 255], - # https://www.color-name.com/highlighter-yellow.color # YELLOW = 3 - 3: [251, 247, 25], + 3: [255, 255, 99], # GREEN = 4 4: [0, 255, 0], # PINK = 5 - # https://www.rapidtables.com/web/color/pink-color.html - 5: [255, 192, 203], + 5: [255, 20, 147], # BLUE = 6 6: [0, 0, 255], # RED = 7 @@ -121,7 +119,10 @@ def create(cls, pen_nr, color_id, width): class Fineliner(Pen): def __init__(self, base_width, base_color_id): super().__init__(base_width, base_color_id) - self.base_width = (base_width ** 2.1) * 1.3 + if base_width == 1: self.base_width = 1.5 + elif base_width == 2: self.base_width = 4.0 + elif base_width == 3: self.base_width = 6.0 + else: self.base_width = (base_width ** 2.1) * 1.3 self.name = "Fineliner" @@ -217,8 +218,9 @@ class Highlighter(Pen): def __init__(self, base_width, base_color_id): super().__init__(base_width, base_color_id) self.stroke_linecap = "square" - self.base_opacity = 0.3 - self.stroke_opacity = 0.2 + self.base_opacity = 0.25 + self.stroke_opacity = 0.15 + self.base_width = self.base_width * 1.5 self.name = "Highlighter"