indexing description: "[ Bitmap background with an offset in the bitmap. The bitmap will not be repeated. ]" date: "$Date$" revision: "$Revision$" class EM_SHIFTED_BITMAP_BACKGROUND inherit EM_BITMAP_BACKGROUND redefine draw_on, set_bitmap end create make_from_bitmap_offset, make_from_bitmap, make_from_file feature {NONE} -- Initialisation make_from_bitmap_offset (a_bitmap: like bitmap; a_x, a_y: INTEGER) is -- Initialise background with `a_bitmap' and offset `a_x' `a_y'. require a_bitmap_not_void: a_bitmap /= Void a_x_in_range: a_x >= 0 and a_x < a_bitmap.width a_y_in_range: a_y >= 0 and a_y < a_bitmap.width do make_from_bitmap (a_bitmap) x := a_x y := a_y ensure bitmap_set: bitmap = a_bitmap x_set: x = a_x y_set: y = a_y end feature -- Access x: INTEGER -- X offset of bitmap y: INTEGER -- Y offset of bitmap feature -- Element change set_offset (a_x: like x; a_y: like y) is -- Set offset to `a_x' `a_y'. require a_x_in_range: a_x >= 0 and a_x < bitmap.width a_y_in_range: a_y >= 0 and a_y < bitmap.width do x := a_x y := a_y ensure x_set: x = a_x y_set: y = a_y end set_bitmap (a_bitmap: like bitmap) is -- Set `bitmap' to `a_bitmap'. -- If the coordinates `x' and `y' are outside `a_bitmap' they will be reset to 0. do Precursor {EM_BITMAP_BACKGROUND} (a_bitmap) if x >= a_bitmap.width then x := 0 end if y >= a_bitmap.height then y := 0 end ensure then x_reset_if_out_of_range: x >= a_bitmap.width implies x = 0 y_reset_if_out_of_range: y >= a_bitmap.height implies y = 0 end feature -- Drawing draw_on (a_widget: EM_WIDGET) is -- Draw background on `a_widget'. do a_widget.surface.blit_surface_part (bitmap, x, y, bitmap.width-x, bitmap.height-y, 0, 0) end invariant x_in_range: x >= 0 and x < bitmap.width y_in_range: y >= 0 and y < bitmap.width end