Options
All
  • Public
  • Public/Protected
  • All
Menu

Base interface implemented by all elements: RaphaelElement, RaphaelPath, and RaphaelSet.

An element is an object that can be drawn on the screen, such as via SVG or VML.

Type Parameters

Hierarchy

Index

Properties

The current transform matrix representing the total transform of this element.

Methods

  • Set the given attribute of this element to the given value.

    Type Parameters

    Parameters

    • attributeName: K

      Name of an attribute to set.

    • attributeValue: undefined | RaphaelAttributes[K]

      New value for the attribute.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Finds the current value of the given attribute.

    Type Parameters

    Parameters

    • attributeName: K

      Name of the attribute to read.

    Returns undefined | RaphaelReadAttributes[K]

    The value of the given attribute, or undefined if the attribute is unset or does not exist.

  • Finds the current value of the given attributes.

    Type Parameters

    Parameters

    • attributeNames: K

      Names of the attributes to read.

    Returns { [ P in string | number | symbol]: K[P] extends keyof RaphaelReadAttributes ? undefined | RaphaelReadAttributes[any[any]] : never }

    A tuple with the values of the given attribute names.

  • Writes the given attributes to this element.

    Parameters

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Create a new element with all properties and attributes of this element.

    Returns RaphaelBaseElement<TTechnology>

    A clone of this element.

  • Retrieves the value associated with the given key. See also removeData.

    Parameters

    • key: string

      Key of the datum to retrieve.

    Returns any

    The data associated with the given key.

  • Adds the given value associated with the given key. See also removeData.

    Parameters

    • key: string

      Key of the datum to store.

    • value: any

      Datum to store.

    Returns RaphaelBaseElement<TTechnology>

  • Adds the event handlers for a drag of this element.

    Type Parameters

    • MoveThisContext = RaphaelBaseElement<TTechnology>

      Type of the this context for the onMove handler.

    • StartThisContext = RaphaelBaseElement<TTechnology>

      Type of the this context for the onStart handler.

    • EndThisContext = RaphaelBaseElement<TTechnology>

      Type of the this context for the onEnd handler.

    Parameters

    • onMoveHandler: RaphaelDragOnMoveHandler<MoveThisContext>

      Handler for when the pointer is moved while dragging.

    • onStartHandler: RaphaelDragOnStartHandler<StartThisContext>

      Handler for when the dragging starts.

    • onEndHandler: RaphaelDragOnEndHandler<EndThisContext>

      Handler for when the dragging ends.

    • Optional moveThisContext: MoveThisContext

      The this context with which the onMove handler is invoked.

    • Optional startThisContext: StartThisContext

      The this context with which the onStart handler is invoked.

    • Optional endThisContext: EndThisContext

      The this context with which the onEnd handler is invoked.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Returns a bounding box for this element.

    Parameters

    • Optional isWithoutTransform: boolean

      true if you want to have bounding box before transformations are applied. Default is false.

    Returns RaphaelAxisAlignedBoundingBox

    The smallest bounding box that contains this element.

  • Return a set of elements that create a glow-like effect around this element.

    Note: Glow is not connected to the element. If you change element attributes it will not adjust itself.

    Parameters

    Returns RaphaelSet<TTechnology>

    A set of elements that produce the given glow effect.

  • Adds event handlers for the hover events to this element.

    Type Parameters

    • HoverInThisContext = RaphaelBaseElement<TTechnology>

      Type of the this context for the onHoverIn handler.

    • HoverOutThisContext = RaphaelBaseElement<TTechnology>

      Type of the this context for the onHoverOut handler.

    Parameters

    • onHoverInHandler: RaphaelBasicEventHandler<HoverInThisContext, MouseEvent>

      Handler for when the pointer enters this element.

    • onHoverOutHandler: RaphaelBasicEventHandler<HoverOutThisContext, MouseEvent>

      Handler for when the pointer leaves this element.

    • Optional hoverInThisContext: HoverInThisContext

      The this context with which the onHoverIn handler is invoked.

    • Optional hoverOutThisContext: HoverOutThisContext

      The this context with which the onHoverOut handler is invoked.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • isPointInside(x: number, y: number): boolean
  • Determine if given point is inside this element’s shape

    Parameters

    • x: number

      x coordinate of the point

    • y: number

      y coordinate of the point

    Returns boolean

    true if point inside the shape

  • Stops an animation of this element with the ability to resume it later on.

    Parameters

    • Optional anim: RaphaelAnimation

      Animation to pause. If not given, pauses all current animations.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • remove(): void
  • Removes this element from the paper.

    Returns void

  • Removes the value associated with this element by the given key. If the key is not provided, removes all the data of this element.

    Parameters

    • Optional key: string

      Key of the datum to remove.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Rotates this element by the given angle around the given point.

    Parameters

    • degrees: number

      Angle in degrees by which to rotate.

    • centerX: number

      Horizontal coordinate of the center of rotation.

    • centerY: number

      Vertical coordinate of the center of rotation.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Rotates this element by the given angle around the center of this shape.

    Parameters

    • degrees: number

      Angle in degrees by which to rotate.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • scale(scaleFactorX: number, scaleFactorY: number, centerX: number, centerY: number): RaphaelBaseElement<TTechnology>
  • scale(scaleFactorX: number, scaleFactorY?: number): RaphaelBaseElement<TTechnology>
  • Scales this element by the given scale factor, relative to the given center.

    Parameters

    • scaleFactorX: number

      Horizontal part of the scale factor.

    • scaleFactorY: number

      Vertical part of the scale factor.

    • centerX: number

      Horizontal coordinate of the center of the scaling operation.

    • centerY: number

      Vertical coordinate of the center of the scaling operation.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Scales this element by the given scale factor. The center of this shape is used as the center of the scaling operation.

    Parameters

    • scaleFactorX: number

      Horizontal part of the scale factor.

    • Optional scaleFactorY: number

      Vertical part of the scale factor. If not given, defaults to scaleFactorX.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Sets the status of animation of the element in milliseconds. Similar to status method.

    Parameters

    • animation: RaphaelAnimation

      Animation for which to set the status.

    • value: number

      Number of milliseconds from the beginning of the animation.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Gets the status (normalized animation time) of the current animations of this element.

    Returns RaphaelAnimationStatus[]

    The status of all animations currently playing.

  • Gets the status of the given animation of this element.

    Parameters

    Returns number

    The current value (normalized animation time) of the given animation.

  • Sets the status of the given animation of this element to the given value. This will cause the animation to jump to the given position.

    Parameters

    • animation: RaphaelAnimation

      Animation object for which to set the status.

    • value: number

      New value (normalized animation time) for the animation, between 0 and 1.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Stops all or the the given animation of this element.

    Parameters

    • Optional animation: RaphaelAnimation

      An animation to stop. If not given, stops all animations currently playing.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Moves this element so it is the furthest from the viewer’s eyes, behind other elements.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Moves this element so it is the closest to the viewer’s eyes, on top of other elements.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Returns the current transformation of this element. This transformation is separate to other attributes, i.e. translation does not change x or y of the rectangle. The format of transformation string is similar to the path string syntax:

    "t100,100r30,100,100s2,2,100,100r45s1.5"
    

    Each letter is a command. There are four commands:

    • t is for translate
    • r is for rotate,
    • s is for scale
    • m is for matrix.

    So, the example line above could be read like

    translate by 100, 100;
    rotate 30° around 100, 100;
    scale twice around 100, 100;
    rotate 45° around centre;
    scale 1.5 times relative to centre

    As you can see rotate and scale commands have origin coordinates as optional parameters, the default is the centre point of the element. Matrix accepts six parameters.

    // to get current value call it without parameters
    console.log(el.transform());

    Returns string

    The current transformation of this element.

  • Adds transformation to this element which is separate to other attributes, i.e. translation does not change x or y of the rectangle. The format of transformation string is similar to the path string syntax:

    "t100,100r30,100,100s2,2,100,100r45s1.5"
    

    Each letter is a command. There are four commands:

    • t is for translate
    • r is for rotate,
    • s is for scale
    • m is for matrix.

    So, the example line above could be read like

    translate by 100, 100;
    rotate 30° around 100, 100;
    scale twice around 100, 100;
    rotate 45° around centre;
    scale 1.5 times relative to centre

    As you can see rotate and scale commands have origin coordinates as optional parameters, the default is the centre point of the element. Matrix accepts six parameters.

    var el = paper.rect(10, 20, 300, 200);

    // translate 100, 100, rotate 45°, translate -100, 0
    el.transform("t100,100r45t-100,0");

    // if you want you can append or prepend transformations
    el.transform("...t50,50");
    el.transform("s2...");

    // or even wrap
    el.transform("t50,50...t-50-50");

    // to reset transformation call method with empty string
    el.transform("");

    Parameters

    • transformString: string

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Translates this element by the given amount.

    Parameters

    • deltaX: number

      Amount by which to translate in the horizontal direction.

    • deltaY: number

      Amount by which to translate in the vertical direction.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

  • Removes all drag event handlers from this element.

    Returns RaphaelBaseElement<TTechnology>

    this element for chaining.

Generated using TypeDoc