Skip to content
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

Different styles for objetcs with the same text #18

Open
CapitanPrimate opened this issue Aug 31, 2017 · 2 comments
Open

Different styles for objetcs with the same text #18

CapitanPrimate opened this issue Aug 31, 2017 · 2 comments

Comments

@CapitanPrimate
Copy link

Hello.

First of all, thank you very much for this great piece of work.

In my daily work I generate "heat tables" which consist of cells with fixed colors and varying values, like the example below:
image

I have seen in the documentation that you can define the attributes for certain objets by selecting them via regular expressions. For example, I could select the cell with the value/id "18" and make it have a yellow background. But that wouldn't work with cells containing the value/id "1", since they need different colors.

Is there a way to accomplish this with shaape?

Thanks in advance.

@christiangoltz
Copy link
Owner

Hi @CapitanPrimate,
this is not supported out of the box. Unfortunately I didn't implement a method to name the shapes without showing the names.

There are 2 possibilities that I see:

  1. There is a very stupid version that I think might work:
    Draw your boxes like this
+-------+
| green |
| +---+ |
| | 1 | |
| +---+ |
+-------+

After that you can use the styling to style the inner rectangle (which would match [0-9]+) to have an invisible frame and background by setting the alpha to 0. Additionally you would style the green box to have a green background and invisible text. In theory this will give you a black number in front of a green box. I didn't try this though, but would be really interesting to see ;)

  1. As I am not actively building new features for this, you could still do named shapes yourself and submit a pull request, e.g. extend the TextParser and Text to support something like actual names, maybe denoted by a colon at the start of the text and then change the drawing backend to only draw text that isn't names.

@CapitanPrimate
Copy link
Author

CapitanPrimate commented Aug 31, 2017

Thank you for your quick response, @christiangoltz !

Based on your suggestion, I tried this:

+-----+-----+-----+-----+-----+
|y    |y    |r    |r    |r    |
|  1  |  2  |  3  |  4  |  5  |
|     |     |     |     |     |
+-----+-----+-----+-----+-----+
|g    |y    |r    |r    |r    |
|  6  |  7  |  8  |  9  |  A  |
|     |     |     |     |     |
+-----+-----+-----+-----+-----+
|g    |y    |y    |y    |r    |
|  B  |  C  |  D  |  E  |  F  |
|     |     |     |     |     |
+-----+-----+-----+-----+-----+
|g    |y    |y    |y    |y    |
|  G  |  H  |  I  |  J  |  K  |
|     |     |     |     |     |
+-----+-----+-----+-----+-----+
|g    |g    |g    |g    |y    |
|  L  |  M  |  N  |  Ñ  |  O  |
|     |     |     |     |     |
+-----+-----+-----+-----+-----+
options:
- ".*" : {text : ["Sans 16"]}
- "r" : {text : ["Sans 11", [0, 0, 0, 0]], fill : [[1.0000, 0.3451, 0.3961, 1]]}
- "g" : {text : ["Sans 11", [0, 0, 0, 0]], fill : [[1.0000, 0.9686, 0.4941, 1]]}
- "y" : {text : ["Sans 11", [0, 0, 0, 0]], fill : [[0.7020, 0.8941, 0.5529, 1]]}

and got this:
image

Works like a charm!

However, in order to get the same image of my original post (white text on red background, black text elsewhere), your solution will apply perfectly.

Regarding item 2, I am not fluent in Python, but I can take a look at it ;)

Thank you very much again!

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

No branches or pull requests

2 participants