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

Author Topic: Attempting to set shape color to blue gives black  (Read 1493 times)

0 Members and 1 Guest are viewing this topic.

Bill_n

  • Newbie
  • *
  • Posts: 4
    • View Profile
Attempting to set shape color to blue gives black
« on: July 26, 2010, 08:04:38 am »
I can set the background displayed to blue just fine using Clear(sf::Color(0,0,255)).

I'm trying to set a shape's color to blue by using the Shape::SetColor method as follows:

Code: [Select]
crit.getShape().SetColor(sf::Color(0,0,255));

crit is an object that has a sf::Shape member variable, accessed by the following function:
Code: [Select]
sf::Shape& Critter::getShape()
{
return shape;
}


and shape is instantiated in the object's constructor as follows:
Code: [Select]
shape = sf::Shape::Circle(0, 0, 15, sf::Color(128, 128, 0, 255));

When I try to set the shape's color to blue, it yields a black circle. If I set it to (0,0,255,123) it yields a grey circle when viewed against a white background.

Is there some blending mode of the Shape that is interfering with my attempt?

(255,0,0) yields red     :)
(0,255,0) yields green :)
(0,0,255) yields black  :?:
(255,255,0) and (255,255,0) both yield yellow  :!:
This seems to indicate to me there's some sort of masking going on that is ignoring blue component, but i have no idea where to look for this

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Attempting to set shape color to blue gives black
« Reply #1 on: July 26, 2010, 09:06:19 am »
The color that you pass to the Shape::Circle function is assigned to the shape's points. This is not the global shape color (inherited from sf::Drawable), these two are separate and modulated when the shape is drawn. So you should leave the shape's points with a white color, and play only with the global color (SetColor).
Laurent Gomila - SFML developer

Bill_n

  • Newbie
  • *
  • Posts: 4
    • View Profile
Attempting to set shape color to blue gives black
« Reply #2 on: July 26, 2010, 09:14:43 am »
Quote from: "Laurent"
The color that you pass to the Shape::Circle function is assigned to the shape's points. This is not the global shape color (inherited from sf::Drawable), these two are separate and modulated when the shape is drawn. So you should leave the shape's points with a white color, and play only with the global color (SetColor).


OK, thanks for the clarification. It's a bit confusing because the Circle constructor's color argument is just described as "Color used to fill the circle" in the docs.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Attempting to set shape color to blue gives black
« Reply #3 on: July 26, 2010, 09:18:23 am »
I know, I should add something to the doc to make it less confusing :)
Laurent Gomila - SFML developer

 

anything