Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface for a paper that may be implemented either via VML or SVG, see RaphaelTechnology.

The paper that represents a drawing surface, implemented via SVG.

You can use the paper to draw shapes such as circles or paths.

Type Parameters

  • TTechnology extends RaphaelTechnology = "SVG" | "VML"

    Type of the technology used by this paper, either SVG or VML.

Hierarchy

  • RaphaelPaper

Index

Properties

bottom: null | RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGElement, Element>[TTechnology]>

Points to the bottom element on the paper. null when there is no element.

canvas: RaphaelElementByTechnologyMap<SVGElement, Element>[TTechnology]

The SVG element used by this paper.

customAttributes: Record<keyof RaphaelAttributes, RaphaelCustomAttribute<TTechnology, any>>

If you have a set of attributes that you would like to represent as a function of some number you can do it easily with custom attributes:

paper.customAttributes.hue = function (num) {
num = num % 1;
return {fill: "hsb(" + num + ", .75, 1)"};
};

// Custom attribute "hue" will change fill
// to be given hue with fixed saturation and brightness.
// Now you can use it like this:
var c = paper.circle(10, 10, 10).attr({hue: .45});
// or even like this:
c.animate({hue: 1}, 1e3);

// You could also create custom attribute
// with multiple parameters:
paper.customAttributes.hsb = function (h, s, b) {
return {fill: "hsb(" + [h, s, b].join(",") + ")"};
};
c.attr({hsb: ".5 .8 1"});
c.animate({hsb: "1 0 .5"}, 1e3);

Note to TypeScript users

To declare your plugin, you should extend the raphael module and add to the RaphaelAttributes:

import { RaphaelAttributes } from "raphael"
declare module "raphael" {
interface RaphaelAttributes {
hue: number;
hsb: string;
}
}
height: number

The height of this pager.

raphael: RaphaelStatic<TTechnology>

Points to the Raphael object/function.

top: null | RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGElement, Element>[TTechnology]>

Points to the topmost element on the paper. null when there is no element.

width: number

The width of this paper.

Methods

  • Draws a circle.

    Parameters

    • x: number

      x coordinate of the center.

    • y: number

      y coordinate of the center.

    • radius: number

      Radius of the circle.

    Returns RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGCircleElement, Element>[TTechnology]>

    The newly created element representing the circle.

  • clear(): void
  • Clears the paper, i.e. removes all the elements.

    Returns void

  • Draws a connection between two mindmap nodes.

    Parameters

    • obj1: RaphaelElement<"SVG" | "VML", Element | SVGElement>

      Source node where the connection starts.

    • obj2: RaphaelElement<"SVG" | "VML", Element | SVGElement>

      Target node where the connection ends.

    • line: null | string

      Color of the connection.

    • bg: null | string

      Background specifier for the connection.

    • effectSpeed: number

      Effect speed for showing the new connection, in milliseconds.

    Returns undefined | MindmapConnection

    An object with the newly created connection and the given source and target nodes.

  • Draws an ellipse.

    Parameters

    • x: number

      x coordinate of the center.

    • y: number

      y coordinate of the center.

    • radiusX: number

      Horizontal half-axis of the ellipse.

    • radiusY: number

      Vertical half-axis of the ellipse.

    Returns RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGEllipseElement, Element>[TTechnology]>

    The newly created element representing the ellipse.

  • Executes given function for each element on the paper

    If callback function returns false it will stop the loop running.

    Type Parameters

    • T = Window

    Parameters

    Returns RaphaelPaper<TTechnology>

    this paper for chaining.

  • Returns an element by its internal ID.

    Parameters

    • id: number

      ID of an element to fetch.

    Returns null | RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGElement, Element>[TTechnology]>

    The element with the given ID, or null if no such element exists.

  • Return the topmost element at given point.

    paper.getElementByPoint(mouseX, mouseY).attr({stroke: "#f00"});
    

    Parameters

    • x: number

      x coordinate from the top left corner of the window.

    • y: number

      y coordinate from the top left corner of the window.

    Returns null | RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGElement, Element>[TTechnology]>

    The topmost element at given point, null if no such element exists..

  • getFont(family: string, weight?: string | number, style?: string, stretch?: string): undefined | RaphaelFont
  • Finds font object in the registered fonts by given parameters. You could specify only one word from the font name, like Myriad for Myriad Pr.

    paper.print(100, 100, "Test string", paper.getFont("Times", 800), 30);
    

    Parameters

    • family: string

      Font family name or any word from it

    • Optional weight: string | number

      Font weight

    • Optional style: string

      Font style

    • Optional stretch: string

      Font stretch

    Returns undefined | RaphaelFont

    The font object with the given options, or undefined if no such font exists.

  • Embeds an image into this paper.

    var c = paper.image("apple.png", 10, 10, 80, 80);
    

    Parameters

    • src: string

      URI of the source image.

    • x: number

      x coordinate position

    • y: number

      y coordinate position

    • width: number

      Width of the image

    • height: number

      Height of the image

    Returns RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGImageElement, Element>[TTechnology]>

    The newly created element representing the image.

  • Creates a path element by given path data string.

    Path string consists of one-letter commands, followed by comma separated arguments in numerical form:

    "M10,20L30,40"
    

    For example:

    var c = paper.path("M10 10L90 90");
    // draw a diagonal line:
    // move to 10,10, line to 90,90

    Parameters

    Returns RaphaelPath<TTechnology>

    The newly created element representing the path.

  • Creates set of shapes to represent given font at given position with given size. Result of the method is set object (see set) which contains each letter as separate path object.

    var txt = r.print(10, 50, "print", r.getFont("Arial"), 30).attr({fill: "#fff"});
    // following line will paint first letter in red
    txt[0].attr({fill: "#f00"});

    Parameters

    • x: number

      x Position of the text

    • y: number

      y Position of the text

    • str: string

      Text to print

    • font: RaphaelFont

      Font object, see getFont.

    • Optional size: number

      Size of the font, default is 16.

    • Optional origin: RaphaelFontOrigin

      Whether the text is centered on the baseline or middle line.

    • Optional letterSpacing: number

      Number between -1 and 1, default is 0.

    Returns RaphaelSet<TTechnology>

    Each letter as separate path object.

  • Draws a rectangle.

    Parameters

    • x: number

      x coordinate of the top left corner.

    • y: number

      y coordinate of the top left corner

    • width: number

      Width of th rectangle.

    • height: number

      Height of th rectangle.

    • Optional r: number

      Radius for rounded corners, default is 0.

    Returns RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGRectElement, Element>[TTechnology]>

    The newly created element representing the rectangle.

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

    Returns void

  • renderfix(): void
  • Fixes the issue of Firefox and IE9 regarding subpixel rendering. If paper is dependant on other elements after reflow it could shift half pixel which cause for lines to lost their crispness. This method fixes the issue.

    Returns void

  • safari(): void
  • There is an inconvenient rendering bug in Safari (WebKit): sometimes the rendering should be forced. This method should help with dealing with this bug.

    Returns void

  • Creates array-like object to keep and operate several elements at once. Warning: it doesn't create any elements for itself in the page, it just groups existing elements. Sets act as pseudo elements - all methods available to an element can be used on a set.

    Parameters

    Returns RaphaelSet<TTechnology>

    A newly created set with the given elements.

  • Creates array-like object to keep and operate several elements at once. Warning: it doesn't create any elements for itself in the page, it just groups existing elements. Sets act as pseudo elements - all methods available to an element can be used on a set.

    var st = paper.set();
    st.push(
    paper.circle(10, 10, 5),
    paper.circle(30, 10, 5)
    );
    st.attr({fill: "red"}); // changes the fill of both circles

    Parameters

    Returns RaphaelSet<TTechnology>

    A newly created set with the given elements.

  • See setStart. This method finishes catching elements and returns the resulting set.

    Returns RaphaelSet<TTechnology>

    A set with all the elements added to this paper since setStart was called.

  • setSize(width: number, height: number): RaphaelPaper<TTechnology>
  • If you need to change dimensions of the canvas, call this method.

    Parameters

    • width: number

      New width of the canvas.

    • height: number

      New height of the canvas.

    Returns RaphaelPaper<TTechnology>

    this paper for chaining.

  • setStart(): void
  • Creates a set. All elements that will be created after calling this method and before calling setFinish will be added to the set.

    paper.setStart();
    paper.circle(10, 10, 5),
    paper.circle(30, 10, 5)
    var st = paper.setFinish();
    st.attr({fill: "red"}); // changes the fill of both circles

    Returns void

  • setViewBox(x: number, y: number, w: number, h: number, fit?: boolean): RaphaelPaper<TTechnology>
  • Sets the view box of the paper. Practically it gives you ability to zoom and pan whole paper surface by specifying new boundaries.

    Parameters

    • x: number

      New x position, default is 0.

    • y: number

      New y position, default is 0.

    • w: number

      New width of the canvas.

    • h: number

      New height of the canvas.

    • Optional fit: boolean

      true if you want graphics to fit into new boundary box

    Returns RaphaelPaper<TTechnology>

    this paper for chaining.

  • Draws a text string. If you need line breaks, put \n in the string.

    Parameters

    • x: number

      x coordinate position.

    • y: number

      y coordinate position.

    • text: string

      The text string to draw.

    Returns RaphaelElement<TTechnology, RaphaelElementByTechnologyMap<SVGTextElement, Element>[TTechnology]>

    The newly created element representing the drawn text.

Generated using TypeDoc