Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.video.animation

Class EM_TRANSFORMER


Direct ancestors

EM_DRAWABLE, DOUBLE_MATH, EM_SHARED_SUBSYSTEMS

Creation

Features

Invariants

indexing

description

A wrapper / adaptor for a drawable to make it rotateable and zoomable.

The position and size of such objects is defined through the transformed drawable.
Changing the position of an EM_TRANSFORMER is posiible (set_x_y)
but changing any of the transformation parameters will recalculate Currents position.

EM_TRANSFORMER should not be used to excessively because it uses a buffer to draw
the drawable before rotating it. Especially when you only want to zoom and/or scroll
your drawable, beter use an EM_ZOOMABLE_CONTAINER.

date

$Date: 2005/10/23 16:40:13 $

revision

$Revision: 1.5 $

class

EM_TRANSFORMER

inherit

EM_DRAWABLE
DOUBLE_MATH
MATH_CONST

create

make_with_drawable (a_drawable: EM_DRAWABLE)

-- Initialize Current to transform a_drawable when drawing.

ensure
drawable_set: drawable = a_drawable

feature -- Initialization

make_with_drawable (a_drawable: EM_DRAWABLE)

-- Initialize Current to transform a_drawable when drawing.

ensure
drawable_set: drawable = a_drawable

feature -- Access

arc_cosine (v: DOUBLE): DOUBLE

-- Trigonometric arccosine of radian v
-- in the range [0, pi]

-- (From DOUBLE_MATH)

arc_sine (v: DOUBLE): DOUBLE

-- Trigonometric arcsine of radian v
-- in the range [-pi/2, +pi/2]

-- (From DOUBLE_MATH)

arc_tangent (v: DOUBLE): DOUBLE

-- Trigonometric arctangent of radian v
-- in the range [-pi/2, +pi/2]

-- (From DOUBLE_MATH)

ceiling (v: DOUBLE): DOUBLE

-- Least integral greater than or equal to v

-- (From DOUBLE_MATH)

cosine (v: DOUBLE): DOUBLE

-- Trigonometric cosine of radian v approximated
-- in the range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

dabs (v: DOUBLE): DOUBLE

-- Absolute of v

-- (From DOUBLE_MATH)

exp (x: DOUBLE): DOUBLE

-- Exponential of v.

-- (From DOUBLE_MATH)

floor (v: DOUBLE): DOUBLE

-- Greatest integral less than or equal to v

-- (From DOUBLE_MATH)

log (v: DOUBLE): DOUBLE

-- Natural logarithm of v

-- (From DOUBLE_MATH)

log10 (v: DOUBLE): DOUBLE

-- Base 10 logarithm of v

-- (From DOUBLE_MATH)

log_2 (v: DOUBLE): DOUBLE

-- Base 2 logarithm of v

-- (From DOUBLE_MATH)

sine (v: DOUBLE): DOUBLE

-- Trigonometric sine of radian v approximated
-- in range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

sqrt (v: DOUBLE): DOUBLE

-- Square root of v

-- (From DOUBLE_MATH)

tangent (v: DOUBLE): DOUBLE

-- Trigonometric tangent of radian v approximated
-- in range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

feature -- Status report

drawable: EM_DRAWABLE

-- Drawable that is transformed

height: INTEGER

-- Height of Current

-- (From EM_DRAWABLE)

ensure
result_not_negative: Result >= 0
is_anti_aliasing_enabled: BOOLEAN

-- Is the transformation done with anti aliasing?

is_size_fixed: BOOLEAN

-- Should Current not scale when drawed?
-- True means that the object will be drawed unscaled
-- but its position (reference_point) will still be transformed correctly
-- if drawed on a transformed scaled coordinate system
-- (This is handled accordingly by draw_object of EM_SURFACE)

-- (From EM_DRAWABLE)

rotation_angle: DOUBLE

-- Rotation angle by which to rotate drawable around rotation_center (in degree)

rotation_center: EM_VECTOR_2D

-- Rotation center relative to position of drawable

width: INTEGER

-- Width of Current

-- (From EM_DRAWABLE)

ensure
result_not_negative: Result >= 0
x: INTEGER

-- Horizontal position, distance in pixels from left

-- (From EM_DRAWABLE)

y: INTEGER

-- Vertical position, distance in pixels from top

-- (From EM_DRAWABLE)

zoom_factor: DOUBLE

-- Zoom factor by which to zoom drawable

feature -- Status setting

draw (a_drawing_interface: EM_SURFACE)

-- Draw Current with a_drawing_interface.

-- (From EM_DRAWABLE)

require
a_surface_not_void: a_surface /= Void
set_anti_aliasing_enabled (a_bool: BOOLEAN)

-- Set is_anti_aliasing_enabled to a_bool.

ensure
is_anti_aliasing_enabled_set: is_anti_aliasing_enabled = a_bool
set_drawable (a_drawable: EM_DRAWABLE)

-- Set drawable to a_drawable.

require
a_drawable_not_void: a_drawable /= Void
ensure
drawable_set: drawable = a_drawable
set_rotation_angle (an_angle: DOUBLE)

-- Set rotation_angle to an_angle in degrees.

ensure
rotation_angle_set: rotation_angle = an_angle
set_rotation_center (a_position: EM_VECTOR_2D)

-- Set rotation_center to a_position.

require
a_position_not_void: a_position /= Void
ensure
rotation_center_set: rotation_center = a_position
set_size_fixed (a_boolean: BOOLEAN)

-- Set is_size_fixed to a_boolean.

-- (From EM_DRAWABLE)

ensure
size_fixed_set: is_size_fixed = a_boolean
set_x (x_position: INTEGER)

-- Set x to x_position.

-- (From EM_DRAWABLE)

ensure
x_set: x = x_position
set_x_y (an_x, a_y: INTEGER)

-- Set x to an_x and y to a_y.

-- (From EM_DRAWABLE)

ensure
x_set: x = an_x
y_set: y = a_y
set_y (y_position: INTEGER)

-- Set y to y_position.

-- (From EM_DRAWABLE)

ensure
y_set: y = y_position
set_zoom_factor (a_zoom_factor: DOUBLE)

-- Set zoom_factor to a_zoom_factor.

require
a_zoom_factor_positive: a_zoom_factor > 0
ensure
zoom_factor_set: zoom_factor = a_zoom_factor
update_bounding_box

-- Calculate bounding_box where Current draws the transformed drawable.

feature -- Drawing

draw_part (a_rect: EM_RECT; a_surface: EM_SURFACE)

-- Draw rectangular part of Current defined by a_rect to a_surface.
-- (Subclasses could redefine this feature for providing an implementation
-- with better performance, otherwise its just done per default by
-- transforming and clipping coordinates on a_surface before calling draw).

-- (From EM_DRAWABLE)

require
a_surface_not_void: a_surface /= Void
a_rect_not_void: a_rect /= Void

feature -- Mouse events

events_initialized: BOOLEAN

-- Have events been initialized?

-- (From EM_DRAWABLE)

initialize_events

-- Event initialization.
-- Needs to be called before subscribing for events.

-- (From EM_DRAWABLE)

require
not_yet_initialized: not events_initialized
ensure
events_initialized: events_initialized
mouse_button_down_event_initialized: mouse_button_down_event /= Void
mouse_button_up_event_initialized: mouse_button_up_event /= Void
mouse_motion_event_initialized: mouse_motion_event /= Void
mouse_button_down_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button down event,
-- gets published when the mouse button is pressed over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

-- (From EM_DRAWABLE)

mouse_button_up_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

-- (From EM_DRAWABLE)

mouse_motion_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEMOTION_EVENT is passed as argument

-- (From EM_DRAWABLE)

publish_mouse_event (a_mouse_event: EM_MOUSE_EVENT)

-- Publish mouse event when a_mouse_event occured on Current.
-- Descendants should redefine this feature
-- for only catching and publishing their mouse events when mouse pointer
-- is realy inside object or for
-- distributing mouse events to child objects.

-- (From EM_DRAWABLE)

require
a_mouse_event_not_void: a_mouse_event /= Void

feature -- Queries

bounding_box: EM_ORTHOGONAL_RECTANGLE

-- Orthogonal rectangle surrounding Current; (i.e. usefull
-- for visibility testing if it intersects with
-- coordinate_area of EM_SURFACE) TODO: We create a new
-- one on each call. Maybe there is a more efficient way to
-- do that?

-- (From EM_DRAWABLE)

ensure
result_not_void: Result /= Void
reference_point: EM_VECTOR_2D

-- Reference point of Current relative to which it should be positioned.
-- (i.e. important when drawn on a scaled coordinate system and is_size_fixed is True)

-- (From EM_DRAWABLE)

ensure
result_not_void: Result /= Void

invariant

-- From EM_DRAWABLE
mouse_button_down_event_initialized: events_initialized implies mouse_button_down_event /= Void
mouse_button_up_event_initialized: events_initialized implies mouse_button_up_event /= Void
mouse_motion_event_initialized: events_initialized implies mouse_motion_event /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end