Skip to content

Import hex values #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scottclowe opened this issue Nov 10, 2015 · 1 comment
Open

Import hex values #10

scottclowe opened this issue Nov 10, 2015 · 1 comment

Comments

@scottclowe
Copy link
Owner

scottclowe commented Nov 10, 2015

I expect a reasonable number of people will want to create a new color scheme based on an existing one implemented for a different editor.

At the moment people can port the color scheme across by manually choosing how to map the between the entities in the two formats and converting any hexadecimal colours with color2javaRGBint. However, having to convert all the colours into RGB integer format one at a time is tedious. Also, it becomes hard to keep track of what colour the value encodes.

It would make it much easier for users to simply copy over the hexadecimal values into the template prf file. Not only would such a thing be much faster, it will also make porting a colour scheme more accessible.

This will make the format incompatible with the actual MATLAB .prf format (which does not have any hexadecimal values), but this can be fixed by importing the color scheme and exporting it again with schemer_export. After the hex values are successfully imported, the colour values will be exported into RGB int format instead.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28132465-import-hex-values?utm_campaign=plugin&utm_content=tracker%2F19271142&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F19271142&utm_medium=issues&utm_source=github).
@auxym
Copy link

auxym commented Feb 27, 2025

I'm not sure if this is just an old issue, but in case people are not aware, this actually already works, as long as the hex code is prefixed with "0x". This works because str2double in Matlab (at least in R2022b which I'm using at the moment) can take hex literals when prefixed like this:

>> str2double('0x002b36')

ans =

       11062

Also note that the java.awt.Color constructor that takes a single int (https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html#Color-int-) does not use the first byte for alpha, so as far as I understand, it is not necessary to add FF in front of all color codes.

As a proof of concept, see this copy of solarized-dark that uses all hex color codes: https://github.com/auxym/matlab-schemer/blob/hex/schemes/solarized-dark-hex.prf. It was converted from the original with the quick python script I wrote: https://github.com/auxym/matlab-schemer/blob/hex/scripts/convert_prf_to_hex.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants