indexing description: "[ The DEMO_TEXT is a demo text for the tile_pattern demo. This class demonstrate how to implement `draw' in a much easier way than it is usually done in EiffelMedia. You can only use this technique if the width and the height of the drawable is constant over time or doesn't change very often since making a surface is a slow operation. The other possibility how to build an EM_DRAWABLE is by using or inherit from EM_DRAWABLE_CONTAINER as the car class from the em_sprites example demonstrate. ]" date: "$Date$" revision: "$Revision$" class DEMO_TEXT inherit EM_DRAWABLE EM_SHARED_STANDARD_FONTS export {NONE} all end EM_SHARED_BITMAP_FACTORY export {NONE} all end create make feature {NONE} -- Initialization make is -- Create a DEMO_TEXT make a demo text. do font := standard_bmp_fonts.medium_vera_font -- First we create a surface with the same format as the screen bitmap_factory.create_empty_bitmap (width, height) surface := bitmap_factory.last_bitmap surface.set_transparent_color (0, 0, 0) -- Then we draw to the surface. This is very fast since we only need -- to draw once to the surface. This is only possible if what you draw -- is not animated. If it is animated you have to draw to the surface -- every `draw' as the commented code in `draw' shows. font.draw_string (" -- EiffelMedia --", surface, 0, font.height(' ')) font.draw_string (" NEVER ENDING DEMO", surface, 0, font.height(' ') * 2) font.draw_string (" eiffelmedia.origo.ethz.ch", surface, 0, font.height(' ') * 3) end feature -- Commands draw (a_drawing_int: EM_SURFACE) is -- Draws `current' to `a_surface' do -- -- The following part would be necessary if the text changes over time (is animated somehow). -- font.draw_string (" -- EiffelMedia --", a_drawing_int, 0, font.height(' ')) -- font.draw_string (" TILE PATTERN DEMO", a_drawing_int, 0, font.height(' ') * 2) -- font.draw_string (" eiffelmedia.origo.ethz.ch", a_drawing_int, 0, font.height(' ') * 3) -- Instead of this we can just draw the surface where the text has already been drawn too. surface.set_x_y (x, y) surface.draw (a_drawing_int) end feature -- Status width:INTEGER is -- The `width' of `Current' do result := 32*19 end height:INTEGER is -- The `height' of `Current' do result := 32*5 end feature {NONE} -- Implementation font: EM_FONT -- Font to use to draw the text surface: EM_BITMAP -- Surface where the text is drawn to end