Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
35 changes: 27 additions & 8 deletions src/rmc/exporters/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -85,14 +105,13 @@ def blocks_to_svg(blocks: Iterable[Block], output, debug=0):
output.write(' <g id="p1" style="display:inline">\n')
output.write(' <filter id="blurMe"><feGaussianBlur in="SourceGraphic" stdDeviation="10" /></filter>\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')
Expand Down
16 changes: 9 additions & 7 deletions src/rmc/exporters/writing_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"


Expand Down Expand Up @@ -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"


Expand Down