/* * BEE::Sprite::draw() - Draw the sprite with a given subimage timing using the given attributes * @x: the x-coordinate to draw the sprite at * @y: the y-coordinate to draw the sprite at * @subimage_time: the frame of animation to choose the subimage from * @w: the width to scale the sprite to * @h: the height to scale the sprite to * @angle: the number of degrees to rotate the sprite clockwise * @new_color: the color to paint the sprite in * @flip: the type of flip to draw the sprite with */ int BEE::Sprite::draw(int x, int y, Uint32 subimage_time, int w, int h, double angle, RGBA new_color, SDL_RendererFlip flip) { // Calculate the current subimage to draw from the given animation frame unsigned int current_subimage = (unsigned int)round(speed*(game->get_ticks()-subimage_time)/game->fps_goal) % subimage_amount; if (current_subimage == 0) { // If the first frame is being drawn, set the animation boolean is_animated = true; } return draw_subimage(x, y, current_subimage, w, h, angle, new_color, flip); // Return the result of drawing the subimage }
void render_slide(slide *sl) { /* Returns a specially allocated surface only if the "except" subimage != NULL; otherwise uses the slide's built-in render surface. */ style *st = sl->st; displaylinevector *repr = sl->repr; displayline *out; DrawMode *dm; SDL_Surface *surface; if(export_html == 1) printf("Rendering %s\n", sl->content->line); if(sl->image_file != NULL) return; if(sl->render != NULL) SDL_FreeSurface(sl->render); sl->render = alloc_surface(sl->des_w, sl->des_h); reallocate_surfaces(sl); surface = sl->render; render_background(sl, surface); // Render the text lines: dm = new DrawMode; dm->ttmode = dm->boldmode = dm->italicmode = 0; dm->current_text_colour_index = st->textcolour; dm->lastshift = 0; for(int i = 0; i < repr->count(); i++) { out = repr->item(i); render_line(sl, out, dm, surface); } delete dm; draw_logos(sl, st, surface); // Draw embedded images: subimage *img; for(int i = 0; i < sl->visible_images->count(); i++) { img = sl->visible_images->item(i); if(img->surface == NULL) load_subimage(img); draw_subimage(surface, img); } if(sl->deck_size > 1) render_decorations(sl); scale(sl); }