You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: event.rs
    path of file: ./repos/vizia/crates/vizia_core/src/context
    
    the code of the file until where you have to start completion: use std::any::{Any, TypeId};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
#[cfg(feature = "clipboard")]
use std::error::Error;
use std::rc::Rc;

use femtovg::Transform2D;
use fnv::FnvHashMap;
use instant::{Duration, Instant};
use vizia_storage::TreeIterator;
use vizia_style::{ClipPath, Filter, Scale, Translate};

use crate::animation::{AnimId, Interpolator};
use crate::cache::CachedData;
use crate::environment::ThemeMode;
use crate::events::{TimedEvent, TimedEventHandle, Timer, TimerState, ViewHandler};
use crate::model::ModelDataStore;
use crate::prelude::*;
use crate::resource::ResourceManager;
use crate::style::{Abilities, IntoTransform, PseudoClassFlags, Style, SystemFlags};
use crate::tree::{focus_backward, focus_forward, is_navigatable};
use crate::window::DropData;
use vizia_id::GenerationalId;
use vizia_input::{Modifiers, MouseState};

use crate::context::EmitContext;
use crate::text::TextContext;
#[cfg(feature = "clipboard")]
use copypasta::ClipboardProvider;

use super::{DARK_THEME, LIGHT_THEME};

/// A context used when handling events.
///
/// The [`EventContext`] is provided by the [`event`](crate::prelude::View::event) method in [`View`], or the [`event`](crate::model::Model::event) method in [`Model`], and can be used to mutably access the
/// desired style and layout properties of the current view.
///
/// # Example
/// ```
/// # use vizia_core::prelude::*;
/// # use vizia_core::vg;
/// # let cx = &mut Context::default();
///
/// pub struct CustomView {}
///
/// impl CustomView {
///     pub fn new(cx: &mut Context) -> Handle<Self> {
///         Self{}.build(cx, |_|{})
///     }
/// }
///
/// impl View for CustomView {
///     fn event(&mut self, cx: &mut EventContext, event: &mut Event) {
///         event.map(|window_event, _| match window_event {
///             WindowEvent::Press{..} => {
///                 // Change the view background color to red when pressed.
///                 cx.set_background_color(Color::red());
///             }
///
///             _=> {}
///         });
///     }
/// }
/// ```
pub struct EventContext<'a> {
    pub(crate) current: Entity,
    pub(crate) captured: &'a mut Entity,
    pub(crate) focused: &'a mut Entity,
    pub(crate) hovered: &'a Entity,
    pub(crate) triggered: &'a mut Entity,
    pub(crate) style: &'a mut Style,
    pub(crate) entity_identifie
    
    pub fn transform(&self) -> Transform2D {
        let mut transform = Transform2D::identity();

        let bounds = self.bounds();
        let scale_factor = self.scale_factor();

        // Apply transform origin.
        let mut origin = self
            .style
            .transform_origin
            .get(self.current)
            .map(|transform_origin| {
                let mut origin = Transform2D::new_translation(bounds.left(), bounds.top());
                let offset = transform_origin.as_transform(bounds, scale_factor);
                origin.premultiply(&offset);
                origin
            })
            .unwrap_or(Transform2D::new_translation(bounds.center().0, bounds.center().1));
        transform.premultiply(&origin);
        origin.inverse();

        // Apply translation.
        if let Some(translate) = self.style.translate.get(self.current) {
            transform.premultiply(&translate.as_transform(bounds, scale_factor));
        }

        // Apply rotation.
        if let Some(rotate) = self.style.rotate.get(self.current) {
            transform.premultiply(&rotate.as_transform(bounds, scale_factor));
        }

        // Apply scaling.
        if let Some(scale) = self.style.scale.get(self.current) {
            transform.premultiply(&scale.as_transform(bounds, scale_factor));
        }

        // Apply transform functions.
        if let Some(transforms) = self.style.transform.get(self.current) {
            // Check if the transform is currently animating
            // Get the animation state
            // Manually interpolate the value to get the overall transform for the current frame
            if let Some(animation_state) = self.style.transform.get_active_animation(self.current) {
                if let Some(start) = animation_state.keyframes.first() {
                    if let Some(end) = animation_state.keyframes.last() {
                        let start_transform = start.value.as_transform(bounds, scale_factor);
                        let end_transform = end.value.as_transform(bounds, scale_factor);
                        let t = animation_state.t;
                        let animated_transform =
                            Transform2D::interpolate(&start_transform, &end_transform, t);
                        transform.premultiply(&animated_transform);
                    }
                }
            } else {
                transform.premultiply(&transforms.as_transform(bounds, scale_factor));
            }
        }

        transform.premultiply(&origin);

        transform
    }