Open nilssonH opened 7 years ago
@nilshoenson they are binary plist data encoded to base64 😉
@rborn Thanks, didn't know that! Will take a look at it.
@nilshoenson just a note, the base64 string has some escaped chars like \/
, you will need to unescape them. I lost some time till I figured out this 😄
@nilshoenson @rborn Did either of you successfully get the base64 plist converted into rgba or hex, using pure javascript? I'm trying to create a very similar Sketch Color Parser, but I really need to be able to access text colors in addition to shape colors.
Here is a snippet of my app, along with the console output. I'm logging 1) the raw encoded NSColor archive, 2) the decoded base64 string, and 3) the plist file that I parsed from the decoded string.
Yet, this plist file is thousands of key/string pairs that look like total gibberish (here's an excerpt of the plist output):
Have y'all had more success than I have in terms of converting an NSColor to a HEX color? Is there anything noticeably wrong with my code or my output?
Also, I just noticed upon closer examination that the exact rgba color value of my text is nested inside of the decoded archive string (see highlighted section):
I suppose I could use regex to extract this string from the decoded archive, but that seems like a very buggy approach...
Currently the only colors that get parsed are used on shapes. The current JSON output of Sketch archived the colors of a Text layer, so I still need to find a way to unarchive it.