"Translating" Colors

I tried to transfer a XML file into a Panorama X database. The particular source is the “SyncedRules.plist” file from Mail.app.

Mail rules can mark mails with a given color when certain criteria are met.

You choose those colors in the Mail preferences > Rules dialog in a popup menu with 6 Apple Highlight Colors and, additionally, the Apple Color Picker.

The chosen colors are saved in the “SyncedRules.plist” XML file as 7- or 8-digit numbers.

Here is a table of my findings:

  • 9158119 light blue
  • 10209791 blue
  • 13095131 grey
  • 13235369 green
  • 14136549 violet
  • 14819865 violet
  • 16750738 red
  • 16763531 orange
  • 16773531 yellow

I would like to use those numbers directly to display the color in a rectangle object on my form.

Has anyone knowledge about the color definition that Apple is using here — and how to translate it into Panorama X’s color system?

I’d like to understand those numbers and would prefer using a conversion formula instead of manually researching every single RGB value from the Color Picker in Mail.

I believe this will properly convert the numbers into their hex HTML equivalents:

theNumber=hexstr(theNumber)[-6,-1]

theNumber would have to converted from a string to a value if needed.

I can verify that Gary’s formula works correctly. For example your blue

hexstr(10209791)[-6,-1]

calculates to

9BC9FF

and the red

hexstr(16750738)[-6,-1]

calculates to

FF9892

Thank you, Gary!

I have now the following code implemented in a .CurrentRecord procedure, and it works perfectly:

changeobject "ColorSample", "Color", ?(Color="","FFFFFF",htmlrgb(hexstr(val(Color))[-6,-1]))

If the field “Color” is empty, the sample area is white.
If there is a color number, the color gets displayed.
Nice!

This may be a useful site:

https://www.rapidtables.com/web/color/RGB_Color.html#color-table

By the way, there is no “Panorama color system”, it uses Apple’s standard NSColor class.

I take the chance to ask: What stands the “NS” in NSColor for?

There is a field “HighlightTextUsingColor” in my database. If this field contains the text “true”, I would like to display that field text in the color given in the field “Color”.

I tried that using a Text Display object and rich text. But as you see in my screenshot: I am getting an inverted color. Instead of red it appears as kind of cyan.

What is wrong with my formula?

Thank you, Michael!

OK, I found it: It is a relict from NEXTSTEP.

1 Like

Solved it myself: A syntax error.

Here is the corrected formula of the Text Display object:

?(HighlightTextUsingColor,
    "<color:"+hexstr(val(Color))[-6,-1]+">"+HighlightTextUsingColor+"</color>",
HighlightTextUsingColor)
1 Like