Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: More predefined sf::Colors  (Read 4225 times)

0 Members and 1 Guest are viewing this topic.

nnard1616

  • Newbie
  • *
  • Posts: 2
    • View Profile
More predefined sf::Colors
« on: March 09, 2019, 09:31:50 am »
HTML has something like 140 standard color names, I'd think it would be cool to have them all as predefined sf::Colors.

Perhaps SFML doesn't need that many predefines, but it would be nice to have more common colors like Orange and Brown included. 


On my personal build of SFML I've already included all of the HTML color names.  If anybody is interested in including these in their own SFML builds, you can copy this text for the Color.hpp, and this for the Color.cpp.  Keep in mind that HTML's color names don't 100% correspond with SFML predefines.  EG, sf::Color::Green is called Lime in HTML.   So if you use my HTML based predefines you'll be overwriting SFML's predefines.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: More predefined sf::Colors
« Reply #1 on: March 10, 2019, 01:52:03 pm »
Keep in mind that HTML's color names don't 100% correspond with SFML predefines.  EG, sf::Color::Green is called Lime in HTML.   So if you use my HTML based predefines you'll be overwriting SFML's predefines.
This shows that current sf::Color cannot be extended in a backwards compatible way. Overall, it seems much more meaningful to write your own namespace HtmlColors with the constants you need -- there's no need to intrusively modify SFML (and the need to merge changes when SFML updates).

This being said, thanks for providing the list of colors! :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

nnard1616

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: More predefined sf::Colors
« Reply #2 on: March 11, 2019, 06:46:14 pm »
Ah, I didn't think about backwards compatibility.  Thank you for pointing that out and your other suggestions.

Looking at the original predefines, I've realized they're the basic RGB/CMYK+white&transparent. Considering this and the ideology of SFML, it seems to me that additional color predefines is unnecessary and antithetical.

But, it would be nice to have HTML colors ready at one's fingertips, so I've implemented your HtmlColors suggestion.  My refactored text can be found here.  Just stick it somewhere in your project or include it in your personal SFML build if you wish.


Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: More predefined sf::Colors
« Reply #3 on: March 12, 2019, 01:32:39 pm »
I would suggest to put this on a github repo, or maybe the wiki :) Easier to keep it and maintain it! Good job and thanks for doing this!
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

 

anything