ricklupton / rmscene

Read v6 .rm files from the reMarkable tablet
MIT License
86 stars 15 forks source link

New colors #30

Open ChenghaoMou opened 2 weeks ago

ChenghaoMou commented 2 weeks ago

Seems that the colors in RMPP are somehow different :( When I use this library to parse one of the rm files with Yellow Highlight, it complained about "9 is not a valid PenColor". As soon as I add a dummy placeholder for 9, it works perfectly.

Device: RMPP System: 3.14.4.0

I can help test all colors on RMPP over the weekend and create a PR if needed.

Thanks for this awesome tool!

Azeirah commented 2 weeks ago

There are definitely new colours! :D

A PR would be more than welcome.

Azeirah commented 2 weeks ago

Oh and note, different pens have different color palettes. Tricky detail!

Azeirah commented 2 weeks ago

Another extremely important detail, the screen displays the color exceptionally differently from computer monitors. Perhaps we need to use a tool that can read colors in CIELAB from the RM display or whatever uber-accurate color standard is all the hype at the moment internationally..

RGB is at least uhh.. not sufficient. And "yellow" is as meaningless as "potato"

ChenghaoMou commented 2 weeks ago

I have tested the 3 color palettes (1 for highlighter, 1 for shader, and 1 for the rest) here is what I have found:

  1. highlighters and shaders use the same code for color (9) with some unknown extra data:
    SceneGlyphItemBlock(extra_data=b'\xa4\x01u\xed\xff\xff',
                    parent_id=CrdtId(0, 11),
                    item=CrdtSequenceItem(item_id=CrdtId(1, 68),
                                          left_id=CrdtId(1, 67),
                                          right_id=CrdtId(0, 0),
                                          deleted_length=0,
                                          value=GlyphRange(start=0,
                                                           length=24,
                                                           text='This is a '
                                                                'test '
                                                                'sentence.',
                                                           color=<PenColor.HIGHLIGHT: 9>,
                                                           rectangles=[Rectangle(x=-745.6001286517348,
                                                                                 y=216.30249228933826,
                                                                                 w=367.2576832785053,
                                                                                 h=51.87304513156414)])))
    SceneGlyphItemBlock(extra_data=b'\xa4\x01\xfe\xea\xbe\xff',
                    parent_id=CrdtId(0, 11),
                    item=CrdtSequenceItem(item_id=CrdtId(1, 69),
                                          left_id=CrdtId(1, 68),
                                          right_id=CrdtId(0, 0),
                                          deleted_length=0,
                                          value=GlyphRange(start=26,
                                                           length=14,
                                                           text='This is a '
                                                                'test',
                                                           color=<PenColor.HIGHLIGHT: 9>,
                                                           rectangles=[Rectangle(x=-745.6001286517348,
                                                                                 y=262.1636306812288,
                                                                                 w=210.46279888632853,
                                                                                 h=51.87304513156414)])))
SceneLineItemBlock(extra_data=b'!@',
                   parent_id=CrdtId(0, 11),
                   item=CrdtSequenceItem(item_id=CrdtId(1, 121),
                                         left_id=CrdtId(1, 120),
                                         right_id=CrdtId(0, 0),
                                         deleted_length=0,
                                         value=Line(color=<PenColor.HIGHLIGHT: 9>,
                                                    tool=<Pen.SHADER: 23>,
                                                    points=[Point(x=-8.726122856140137,
                                                                  y=409.3048095703125,
                                                                  speed=0,
                                                                  direction=0,
                                                                  width=34,
                                                                  pressure=12),
  1. There is a new pen type SHADER = 23;
  2. There is also a new green with a code 10;

    # All highlighter colors seem to share the same value.
    HIGHLIGHT = 9
    
    GREEN_2 = 10
    CYAN = 11
    MAGENTA = 12

However, I can't find the place where the color name is translated into colorspace values. Am I missing something?

Azeirah commented 2 weeks ago

Ah sorry, I got a bit overenthusiastic. This library doesn't perform the actual color conversions itself. It just builds the scene tree in a very friendly Python datastructure.

This contribution alone does a lot!

Some potential next steps: