indexing description: "[ Exhibit box showcasing borders and backgrounds ]" author: "" date: "$Date$" revision: "$Revision$" class EXHIBIT_DECORATOR_BOX inherit EXHIBIT_BOX create make feature -- Access title: STRING is -- Title "Border- and Background-Boxes" description: STRING is -- Description "Besides container boxes like horizontal-boxes or tables that can contain % %several other boxes, there are also a special kind of container boxes % %in EiffelMedia Viz: Decorator-boxes, which hold a single other box.%N% %The two most important decorator boxes are background and border boxes, % %which add just that to their child item.%N% %The white background and the black border you see around the main exhibit % %are also rendered using just these decorator boxes.%N% %" illuminator: EM_VIZ_LIGHT_BOX [EM_VIZ_BOX] -- Light border1, border2: EM_VIZ_BORDER_BOX [EM_VIZ_BOX] -- Borders background1, background2: EM_VIZ_BACKGROUND_BOX [EM_VIZ_BOX] -- Backgrounds color_box1, color_box2: EM_VIZ_COLOR_BOX -- Colored cubes box_size: DOUBLE is 50.0 -- Size of color box border_size: DOUBLE is 20.0 -- Size of border on average background_size: DOUBLE is 100.0 -- Initial size of background feature -- Manufacturing create_exhibit is -- Create content do create_column_layout (2) -- First box put_column_title ("A blue box with a white 3d background and a translucent red border", 1) create color_box1.make ([box_size,box_size,box_size], [0, 0, 255]) create border1.make ([border_size,border_size,border_size]) border1.set_border_color ([255, 0, 0, 127]) create background1.make ([background_size,background_size,background_size]) background1.set_color ([255, 255, 255]) background1.put_depth -- Align to front background1.set_depth_alignment (Align_front) put_column_content (background1, 1) -- Second box put_column_title ( "A flat, red background and a flat blue box with an invisible border. % %The border and the blue box are aligned to the left of the background.", 2 ) create color_box2.make ([box_size,box_size,0.0], [0, 0, 255]) create border2.make ([border_size,border_size,0.0]) border2.set_border_hidden (True) create background2.make ([background_size,background_size,0.0]) background2.set_color ([255, 0, 0]) background2.set_horizontal_alignment (Align_left) put_column_content (background2, 2) -- Assemble border1.put (color_box1) background1.put (border1) border2.put (color_box2) background2.put (border2) -- Light scene create illuminator.make illuminator.set_light_direction ([0.4, 0.2, 1.0]) illuminator.put (column_layout) exhibit := illuminator end feature -- Animation animate_borders (a_time: INTEGER) is -- Dynamically resize borders local s: DOUBLE do s := border_size * (1 + cosine (a_time * 0.001)) background1.set_size ([background_size,background_size,background_size]) border1.set_border_size ([s, s, s]) background2.set_size ([background_size,background_size,0.0]) border2.set_border_size ([s, s, 0.0]) end go_to_time (a_time: INTEGER) is -- Animate do animate_borders (a_time) end end