Exemple #1
0
  static constexpr ActivePixelTraits::color_type Import(Color color) {
#ifdef GREYSCALE
    return Luminosity8(color.GetLuminosity());
#else
    return BGRA8Color(color.Red(), color.Green(), color.Blue(), color.Alpha());
#endif
  }
Exemple #2
0
void
Canvas::DrawFilledRectangle(int left, int top, int right, int bottom,
                            Color color)
{
  if (left >= right || top >= bottom)
    return;

  SDLRasterCanvas canvas(buffer);
  const auto raster_color = canvas.Import(color);
  if (color.IsOpaque())
    canvas.FillRectangle(left, top, right, bottom, raster_color);
  else
    canvas.FillRectangle(left, top, right, bottom, raster_color, 
                         AlphaPixelOperations<ActivePixelTraits>(color.Alpha()));
}
   void GraphicsManager::RenderText (int x, int y, const std::string& text, const Color& color, TTF_Font* font)
   {
      SDL_Color sdlColor   = { color.Red(), color.Green(), color.Blue(), color.Alpha() };
      SDL_Surface* surface = nullptr;
      SDL_Texture* texture = nullptr;

      ScopeGuard guard([&surface, &texture] () {
         if (texture != nullptr) { SDL_DestroyTexture(texture); texture = nullptr; }
         if (surface != nullptr) { SDL_FreeSurface(surface); surface = nullptr; }
      });

      surface = TTF_RenderText_Blended(font, text.c_str(), sdlColor);
      if (surface == nullptr) throw error::Create("Failed to create surface!", ERROR_LOCATION);

      texture = SDL_CreateTextureFromSurface(device, surface);
      if (texture == nullptr) throw error::Create("Failed to create texture from surface!", ERROR_LOCATION);

      SDL_Rect destRect = { x, y, 0, 0 };

      SDL_QueryTexture(texture, nullptr, nullptr, &destRect.w, &destRect.h);
      SDL_RenderCopy(device, texture, nullptr, &destRect);
   }
sf::Color SfmlConverter::GetSFColor(const Color& color)
{
	return sf::Color(color.R(),color.G(),color.B(),color.Alpha());
}
 void HostTransferFunction::SetBreakpoint(double s, const Color& c)
 {
   SetBreakpoint(s, c, c.Alpha());
 }
Exemple #6
0
 bool operator==(const Color& lhs, const Color& rhs)
 {
   return lhs.Red() == rhs.Red() && lhs.Green() == rhs.Green() &&
          lhs.Blue() == rhs.Blue() && lhs.Alpha() == rhs.Alpha();
 }
Exemple #7
0
 Color operator*(const Color& lhs, const ElVisFloat& s)
 {
   Color result(
     lhs.Red() * s, lhs.Green() * s, lhs.Blue() * s, lhs.Alpha() * s);
   return result;
 }
Exemple #8
0
 Color operator-(const Color& lhs, const Color& rhs)
 {
   Color result(lhs.Red() - rhs.Red(), lhs.Green() - rhs.Green(),
                lhs.Blue() - rhs.Blue(), lhs.Alpha() - rhs.Alpha());
   return result;
 }