andrewgioia / mana

Magic: the Gathering mana symbol pictographic font
300 stars 32 forks source link

Programmatically-friendly color indicator style names #89

Closed dpdearing closed 1 year ago

dpdearing commented 2 years ago

The style names for the multi-color Color Indicators at https://mana.andrewgioia.com/icons.html don't appear to lend themselves well to programmatically concatenating the combinations from the WUBRG color characters.

For example, the urw of Jeskai's ci-urw style are not in alphabetic order (ruw) or in WUBRG order (wur). Unless I'm missing it, there doesn't appear to be any consistency across the style names, which would make it much easier to generate the correct styles.

Would it be possible to add an alias for the multicolor indicators that's easier to generate dynamically from the characters themselves?

The workaround is to produce my own mapping from each combination to the Mana Font combination (i.e., { "RUW" : "ci-urw" }) which is easy enough, but cumbersome.

gbartholomeu commented 1 year ago

Hi @dpdearing you can assign multiple classes in the css file to better fit your needs. So for example if you have

.ms-ci-urw,
.ms-ci-jeskai {
background: conic-gradient(#c6553e 60deg, #fff 60deg 180deg, #3b6ba0 180deg 300deg, #c6553e 300deg);
}

and you want the same style to be applied when you use ci-ruw, just add .ci-ruw after a comma just like is happening with the jeskai or as it is done with the phyrexian mana. Since all the colors share the same symbol, all of them are declared with the same content:

.ms-p::before,
.ms-wp::before,
.ms-up::before,
.ms-bp::before,
.ms-rp::before,
.ms-gp::before (...)

edit: formatting

dpdearing commented 1 year ago

you can assign multiple classes in the css file to better fit your needs

Thanks for the suggestion, @gbartholomeu. I have actually been loading the font via CDN instead of including the CSS file so modifying it directly isn't really an option.

KingSupernova31 commented 1 year ago

I believe the order of the class names (for both the color indicators and the hybrid mana symbols) follows the same rules as the order of mana symbols on actual cards. You can see those rules described here and here.

andrewgioia commented 1 year ago

Thanks all for the helpful responses here, yes just echoing what @KingSupernova31 said and linked to. Mana follows the order set by WOTC in cards printed, with the last change in Khans I believe (e.g., Narset, Enlightened Master with URW).

There are printed exceptions before Khans like Zedruu the Greathearted with RUW. It certainly wouldn't be tough to make these default variables, but that wouldn't solve the issue for people using the CDN. We'd have to add aliases, perhaps as an optional heavier build.

I'll think about it a bit more and welcome feedback!

KingSupernova31 commented 1 year ago

Since you asked for feedback, I'll just note that I had run into this issue as a slight annoyance in my program as well, but it's pretty easy to get around. It only takes a few minutes to write a function that accepts mana symbols in any order and returns them in the correct order.

Of course it also wouldn't hurt to add in those aliases; the CSS for that would still be small enough that it wouldn't noticeably increase loading times, and a one-time effort expenditure to save a bunch of future programmers a few minutes each may still be worth it.

andrewgioia commented 1 year ago

Need to add this to the changelog but I put this in 1.15.5! Every permutation is now an alias FYI.