SFML community forums
Help => Graphics => Topic started by: Boogiwoogie on March 17, 2009, 04:23:20 pm
-
hi all!
yesterday i checked out the tutorial on displaying text and downloaded the corresponding source at the bottom of the page.
http://www.sfml-dev.org/tutorials/1.4/graphics-fonts.php
having played around a little with it, i started to add some rectangles, and didnt manage to set the color for it. once the rect is created, the setcolor() method doesnt work as it should (imho).
however, if no setcolor() is called, the rect is displayed correctly, so as a workaround one may use a set of rects, one for each color...
code snippet (its pretty much at the end of the tutorial-code)
// Make the second string rotate
Bonjour.Rotate(App.GetFrameTime() * 100.f);
// Clear screen
App.Clear();
sf::Shape r = sf::Shape::Rectangle(100, 100, 200, 200, sf::Color(255, 50, 50)); // bright red
sf::Color col(50, 255, 50); // bright green
r.SetColor(col);
r.SetColor(sf::Color(50, 50, 255)); //bright blue
App.Draw(r);
// Draw our strings
App.Draw(Hello);
App.Draw(Bonjour);
if i comment out the setcolor()-lines, i get different results, none of
them actually predictable (except if i get rid of both the lines).
if i replace the rgb values that are 50 by the value 10 (leaving all the 255 as they are ;), i dont get a rectangle at all.
boogie
-
The color you pass when creating your rectangle is assigned to every point. It has nothing to do with the global color set with SetColor. What you get is a combination (modulation) of both: the global color and the points color.
-
The color you pass when creating your rectangle is assigned to every point. It has nothing to do with the global color set with SetColor. What you get is a combination (modulation) of both: the global color and the points color.
uhh - i see. works for me now... ;)
so actually its smart to construct it using white, then setcolor does all the magic i need.
thx for quick help!
boogie