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

Author Topic: Blending colors  (Read 1699 times)

0 Members and 1 Guest are viewing this topic.

Jereli

  • Newbie
  • *
  • Posts: 1
    • View Profile
Blending colors
« on: April 09, 2016, 09:27:19 pm »
Hi. I have are simple task. Mix the three colors (Cyan, Magenta, Yellow) to obtain black color. How i can get this?
My try dosent working right.
int main() {
        sf::RenderWindow window (sf::VideoMode(winW, winH), "CMYK CMYK CMYK");

        sf::Color cl_c(0, 255, 255, 85); //Cyan
        sf::Color cl_m(255, 0, 255, 85); //Magenta
        sf::Color cl_y(255, 255, 0, 85); //Yellow
       
        sf::CircleShape c1(50);
        c1.setPosition(70, 30);
        c1.setFillColor(cl_c);

        sf::CircleShape c2(50);
        c2.setPosition(150, 20);
        c2.setFillColor(cl_m);

        sf::CircleShape c3(50);
        c3.setPosition(100, 60);
        c3.setFillColor(cl_y);

       
        sf::Event event;
        while (window.isOpen()) {
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed) {
                                window.close();
                                return 0;
                        }
                       
                        window.clear(sf::Color::White);
                        window.draw(c1);
                        window.draw(c2);
                        window.draw(c3);

                        window.display();
                }
        }
        return 0;
}

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Blending colors
« Reply #1 on: April 09, 2016, 11:01:17 pm »
This blending will work only in CMYK while SFML is working in RGB.
« Last Edit: April 09, 2016, 11:08:46 pm by Mr_Blame »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Blending colors
« Reply #2 on: April 09, 2016, 11:26:50 pm »
Unfortunately you can't just draw on top of things and expect them to blend. You should probably look at blend modes. In this case I believe you want sf::BlendMultiply (255 * 255 * 0 = 0 == Black).