Пример #1
0
/**
 * \brief Draws the transition effect on a surface.
 * \param dst_surface The destination surface.
 */
void TransitionFade::draw(Surface& dst_surface) {

  // Draw the transition effect on the surface.
  int alpha_impl = std::min(alpha, 255);

  if (!colored) {
    // Set the opacity on the surface.
    // Only possible for software destinations.
    Debug::check_assertion(dst_surface.is_software_destination()
        || !Video::is_acceleration_enabled(),
        "Cannot apply fade transition: this surface is in read-only mode");
    dst_surface.set_opacity(alpha_impl);
  }
  else {
    // Add a colored foreground surface with the appropriate opacity.
    uint8_t r, g, b, a;
    transition_color.get_components(r, g, b, a);
    // A full opaque transition corresponds to a foreground with full alpha.
    Color fade_color(r, g, b, 255 - std::min(alpha_impl, (int) a));

    dst_surface.fill_with_color(fade_color);
  }

  this->dst_surface = &dst_surface;
}
Пример #2
0
void shadow_helper(Block* b, SDL_Surface* s)
{
    SDL_Rect shadow;
    shadow.x = b->getX() * BLOCK_WIDTH;
    shadow.y = b->getY() * BLOCK_WIDTH;
    shadow.w = BLOCK_WIDTH;
    shadow.h = nextris::options::get_options().game.height * BLOCK_WIDTH;
    SDL_Color color = scintColors[b->getColor()];
    //SDL_FillRect(s, &shadow, );
    vertical_gradient(s, shadow, fade_color(color, 2));
}