indexing description: "[ In a EM_TILE_PATTERN_VERTICAL a EM_DRAWABLE is glued together in vertical direction exactly `times' times ]" date: "$Date$" revision: "$Revision$" class EM_TILE_PATTERN_VERTICAL inherit EM_TILE_PATTERN create make feature {NONE} -- creation make (a_drawable: EM_DRAWABLE; an_integer: INTEGER) is -- Create a EM_TILE_PATTERN_VERTICAL that draws `a_drawable' `an_integer' times require a_drawable_not_void: a_drawable /= void an_integer_greater_zero: an_integer > 0 do -- create upper_part_rect.make (0, 0, 0, 0) -- create lower_part_rect.make (0, 0, 0, 0) img := a_drawable times := an_integer set_visible (True) ensure set: img = a_drawable and times = an_integer end feature -- commands draw (a_surface: EM_SURFACE) is -- Draws `current' to `a_surface' local i: INTEGER translation, translation_step: EM_VECTOR_2D do if is_visible then -- Set up coordinate system to draw image at the right position create translation.make (x - img.x, y - img.y) a_surface.translate_coordinates (translation) -- Calculate step to translate after each image. create translation_step.make (0, img.height) -- Draw image `times' times moved by `translation_diff'. from i := 0 until i >= times loop a_surface.draw_object (img) i := i + 1 a_surface.translate_coordinates (translation_step) end -- Retranslate corrdinates by the whole distance. translation_step.scale (i) translation := translation + translation_step a_surface.translate_coordinates (- translation) -- -- -- -- img.set_x_y (x, y) -- from -- i := 0 -- until -- i >= times -- loop -- img.draw (a_surface) -- img.set_y (img.y + img.height) -- i := i + 1 -- end end end -- draw_part (rect: EM_BLITTING_RECTANGLE; a_surface: EM_SURFACE) is -- -- Draws `rect' part of `current' to `a_surface' -- do -- img.set_x_y (x,y) -- if rect.y < height then -- -- upper_part_rect.set_x (rect.x) -- upper_part_rect.set_y (0) -- upper_part_rect.set_width (rect.width) -- upper_part_rect.set_height (rect.y \\ img.height) -- -- lower_part_rect.set_x (rect.x) -- lower_part_rect.set_y (rect.y \\ img.height) -- lower_part_rect.set_width (rect.width) -- lower_part_rect.set_height (min (img.height - rect.y \\ img.height, img.height)) -- -- draw_it (a_surface, min (rect.height, height - rect.y)) -- end -- end feature -- Status width: INTEGER is -- The `width' of `current' do result := img.width end height: INTEGER is -- The `height' of `current' do result := img.height * times end feature {NONE} -- implementation -- draw_it (a_surface: EM_SURFACE; max_height: INTEGER) is -- -- Draws exactly `max_height' pixel to `a_surface' to position starting at `x' `y'. -- -- Use `upper_part_rect' and `lower_part_rect' as the two parts of the img. -- local -- cur_height: INTEGER -- do -- img.set_x (x) -- from -- cur_height := 0 -- until -- cur_height + lower_part_rect.height >= max_height -- loop -- if lower_part_rect.height > 0 then -- img.set_y (y + cur_height) -- img.draw_part (lower_part_rect, a_surface) -- cur_height := cur_height + lower_part_rect.height -- end -- if upper_part_rect.height > 0 then -- if not ( cur_height + upper_part_rect.height > max_height ) then -- img.set_y (y + cur_height) -- img.draw_part(upper_part_rect, a_surface) -- cur_height := cur_height + upper_part_rect.height -- else -- -- draw the rest -- upper_part_rect.set_height (max_height - cur_height) -- img.set_y (y + cur_height) -- img.draw_part (upper_part_rect, a_surface) -- cur_height := cur_height + ( max_height - cur_height ) -- check -- cur_height = max_height -- end -- end -- end -- end -- if cur_height < max_height then -- -- draw the rest if any -- lower_part_rect.set_height ( max_height - cur_height ) -- img.set_y (y + cur_height) -- img.draw_part (lower_part_rect, a_surface) -- cur_height := cur_height + ( max_height - cur_height ) -- end -- check -- cur_height = max_height -- end -- end -- -- upper_part_rect: EM_BLITTING_RECTANGLE -- -- The left part of `img' to be drawen -- -- lower_part_rect: EM_BLITTING_RECTANGLE -- -- The right part of `img' to be drawen end