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

Author Topic: determine color  (Read 1615 times)

0 Members and 1 Guest are viewing this topic.

wvtrammell

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
determine color
« on: October 16, 2010, 05:14:12 pm »
App.Draw(sf::Shape::Circle(x,y,radius,sf::Color(255,0,0)));
App.Display();

The above code will place a red circle on the screen.
Is there code that I can use to tell me the color the circle?
Thanks
Warren

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
determine color
« Reply #1 on: October 16, 2010, 05:26:10 pm »
Try this after the Display() :

Code: [Select]
sf::Image screen = sf::Image::CopyScreen(App);

Then parse your image and get the color of each pixels with sf::Image::GetPixel(x, y), but it will be horribly slow.

The color of the sf::Shape::Circle function give the color of each vertices of the circle. If you want a global color, create your circle like this :

Code: [Select]

sf::Shape circle = sf::Shape::Circle(x, y, radius, sf::Color::White);
circle.SetColor(sf::Color::Red);


Then you can get the global color of your circle with GetColor().