{
transform.draw_effect = NONE_EFFECT;
transform.zoom = 1;
+transform.alpha = 255;
}
DrawingContext::~DrawingContext()
request.drawing_effect = drawing_effect;
request.drawing_effect = transform.draw_effect | drawing_effect;
request.zoom = transform.zoom;
+ request.alpha = transform.alpha;
drawingrequests.push_back(request);
}
request.layer = layer;
request.pos = transform.apply(dest);
request.drawing_effect = drawing_effect;
+ request.alpha = transform.alpha;
SurfacePartRequest* surfacepartrequest = new SurfacePartRequest();
surfacepartrequest->size = size;
void
DrawingContext::draw_text(Font* font, const std::string& text,
const Vector& position, int allignment, int layer,
- Uint32 drawing_effect, int alpha)
+ Uint32 drawing_effect)
{
DrawingRequest request;
request.layer = layer;
request.pos = transform.apply(position);
request.drawing_effect = drawing_effect;
+ request.alpha = transform.alpha;
TextRequest* textrequest = new TextRequest;
textrequest->font = font;
textrequest->text = text;
textrequest->allignment = allignment;
- textrequest->alpha = alpha;
request.request_data = textrequest;
drawingrequests.push_back(request);
surfacepartrequest->surface->impl->draw_part(
surfacepartrequest->source.x, surfacepartrequest->source.y,
request.pos.x, request.pos.y,
- surfacepartrequest->size.x, surfacepartrequest->size.y, 255,
+ surfacepartrequest->size.x, surfacepartrequest->size.y, request.alpha,
request.drawing_effect);
delete surfacepartrequest;
{
TextRequest* textrequest = (TextRequest*) request.request_data;
- textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, textrequest->alpha);
+ textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, request.alpha);
delete textrequest;
}
if(i->zoom != 1.0)
surface->impl->draw_stretched(i->pos.x * i->zoom, i->pos.y * i->zoom,
(int)(surface->w * i->zoom), (int)(surface->h * i->zoom),
- 255, i->drawing_effect);
+ i->alpha, i->drawing_effect);
else
- surface->impl->draw(i->pos.x, i->pos.y, 255, i->drawing_effect);
+ surface->impl->draw(i->pos.x, i->pos.y, i->alpha, i->drawing_effect);
break;
}
case SURFACE_PART:
{
transform.zoom = zoom;
}
+
+void
+DrawingContext::set_alpha(int alpha)
+{
+ transform.alpha = alpha;
+}
/// Draws a text.
void draw_text(Font* font, const std::string& text, const Vector& position,
int allignment, int layer,
- Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
+ Uint32 drawing_effect = NONE_EFFECT);
/// Draws a color gradient onto the whole screen */
void draw_gradient(Color from, Color to, int layer);
/// Fills a rectangle.
void set_drawing_effect(int effect);
/// apply that zoom in the next draws */
void set_zooming(float zoom);
+ /// apply that alpha in the next draws */
+ void set_alpha(int alpha);
private:
class Transform
Uint32 draw_effect;
float zoom;
+ int alpha;
};
/// the transform stack
Font* font;
std::string text;
int allignment;
- int alpha;
};
struct GradientRequest
int layer;
Uint32 drawing_effect;
float zoom;
+ int alpha;
RequestType type;
Vector pos;