Giter VIP home page Giter VIP logo

Comments (8)

jube avatar jube commented on August 23, 2024

Investigating this weird bug...

from gf.

jube avatar jube commented on August 23, 2024

I cannot reproduce your bug. I created a test case in tests/bugs/bug6.cc (in the develop branch) and it displays a gray text as expected. Could you give me a piece of code that does not work?

from gf.

Ilohama avatar Ilohama commented on August 23, 2024

This is my function to store a Color in a gf::Color4u :
m_mainMenuLabel.setColor(gf::Color::Grey(0.5f));

and this is my function to render the final text on screen :

void Label::render(gf::RenderTarget &target) {
    gf::Text text(m_text, m_font, m_characterSize);
    text.setPosition(m_position);
    text.setColor(m_color);
    target.draw(text);
}

from gf.

Ilohama avatar Ilohama commented on August 23, 2024

I found that using gf::Color::Grey() with a gf::Color4u isn't working.

from gf.

jube avatar jube commented on August 23, 2024

Your bug is here. You should use gf::Color4f and not gf::Color4u. When you assign a gray color to a gf::Color4u, there is an implicit conversion from float to uint8_t which results in 0.5f being 1 (or 0). And then, when you use it in setColor, there is another conversion from uint8_t to float so 1.0f (or 0.0f) which results in white or black.

from gf.

Ilohama avatar Ilohama commented on August 23, 2024

So to store a Grey value in a gf::Color4u, values should looks like { 150, 150, 150, 255} ?

from gf.

jube avatar jube commented on August 23, 2024

Use a gf::Color4f, that's the simplest way to do. Otherwise, you can use gf::Color::rgba() and gf::Color::convert() (in the develop branch, the names are ugly and may change in the future) to convert from one format to another.

from gf.

Ilohama avatar Ilohama commented on August 23, 2024

Okay okay, anyway, i wanted to switch to gf::Color4f, looks like a way more simplier.

from gf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.