Options
All
  • Public
  • Public/Protected
  • All
Menu

Type Parameters

Hierarchy

  • RaphaelStatic

Callable

  • Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.

    Raphaël is a small JavaScript library that should simplify your work with vector graphics on the web. If you want to create your own specific chart or image crop and rotate widget, for example, you can achieve it simply and easily with this library.

    You use this library via the globally available {@link RaphaelStatic|Raphael} object:

    // Creates canvas 320 × 200 at 10, 50
    var paper = Raphael(10, 50, 320, 200);

    // Creates circle at x = 50, y = 40, with radius 10
    var circle = paper.circle(50, 40, 10);

    // Sets the fill attribute of the circle to red (#f00)
    circle.attr("fill", "#f00");

    // Sets the stroke attribute of the circle to white
    circle.attr("stroke", "#fff");

    See https://dmitrybaranovskiy.github.io/raphael/

    Parameters

    • container: string | HTMLElement

      DOM element or its ID which is going to be a parent for drawing surface.

    • width: number

      Width for the canvas.

    • height: number

      Height for the canvas.

    • Optional callback: ((this: RaphaelPaper<TTechnology>) => void)

      Callback function which is going to be executed in the context of newly created paper.

    Returns RaphaelPaper<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

  • Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.

    Raphaël is a small JavaScript library that should simplify your work with vector graphics on the web. If you want to create your own specific chart or image crop and rotate widget, for example, you can achieve it simply and easily with this library.

    You use this library via the globally available {@link RaphaelStatic|Raphael} object:

    // Creates canvas 320 × 200 at 10, 50
    var paper = Raphael(10, 50, 320, 200);

    // Creates circle at x = 50, y = 40, with radius 10
    var circle = paper.circle(50, 40, 10);

    // Sets the fill attribute of the circle to red (#f00)
    circle.attr("fill", "#f00");

    // Sets the stroke attribute of the circle to white
    circle.attr("stroke", "#fff");

    See https://dmitrybaranovskiy.github.io/raphael/

    Parameters

    • x: number

      x coordinate of the viewport where the canvas is created.

    • y: number

      y coordinate of the viewport where the canvas is created.

    • width: number

      Width for the canvas.

    • height: number

      Height for the canvas.

    • Optional callback: ((this: RaphaelPaper<TTechnology>) => void)

      Callback function which is going to be executed in the context of newly created paper.

    Returns RaphaelPaper<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

  • Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.

    Raphaël is a small JavaScript library that should simplify your work with vector graphics on the web. If you want to create your own specific chart or image crop and rotate widget, for example, you can achieve it simply and easily with this library.

    You use this library via the globally available {@link RaphaelStatic|Raphael} object:

    // Creates canvas 320 × 200 at 10, 50
    var paper = Raphael(10, 50, 320, 200);

    // Creates circle at x = 50, y = 40, with radius 10
    var circle = paper.circle(50, 40, 10);

    // Sets the fill attribute of the circle to red (#f00)
    circle.attr("fill", "#f00");

    // Sets the stroke attribute of the circle to white
    circle.attr("stroke", "#fff");

    See https://dmitrybaranovskiy.github.io/raphael/

    Parameters

    Returns RaphaelSet<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

  • Interface for the main object exported by the Raphaël library.

    Raphaël is a small JavaScript library that should simplify your work with vector graphics on the web. If you want to create your own specific chart or image crop and rotate widget, for example, you can achieve it simply and easily with this library.

    You use this library via the globally available {@link RaphaelStatic|Raphael} object:

    // Creates canvas 320 × 200 at 10, 50
    var paper = Raphael(10, 50, 320, 200);

    // Creates circle at x = 50, y = 40, with radius 10
    var circle = paper.circle(50, 40, 10);

    // Sets the fill attribute of the circle to red (#f00)
    circle.attr("fill", "#f00");

    // Sets the stroke attribute of the circle to white
    circle.attr("stroke", "#fff");

    See https://dmitrybaranovskiy.github.io/raphael/

    Parameters

    • Optional onReadyCallback: ((this: Window) => void)

      Function that is going to be called on DOM ready event. You can also subscribe to this event via Eve's DOMLoad event. In this case the method returns undefined.

        • (this: Window): void
        • Parameters

          • this: Window

          Returns void

    Returns RaphaelPaper<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

Index

Constructors

  • Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.

    Parameters

    • container: string | HTMLElement

      DOM element or its ID which is going to be a parent for drawing surface.

    • width: number

      Width for the canvas.

    • height: number

      Height for the canvas.

    • Optional callback: ((this: RaphaelPaper<TTechnology>) => void)

      Callback function which is going to be executed in the context of newly created paper.

    Returns RaphaelPaper<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

  • Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.

    Parameters

    • x: number

      x coordinate of the viewport where the canvas is created.

    • y: number

      y coordinate of the viewport where the canvas is created.

    • width: number

      Width for the canvas.

    • height: number

      Height for the canvas.

    • Optional callback: ((this: RaphaelPaper<TTechnology>) => void)

      Callback function which is going to be executed in the context of newly created paper.

    Returns RaphaelPaper<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

  • Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.

    Parameters

    Returns RaphaelSet<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

  • Parameters

    • Optional onReadyCallback: ((this: Window) => void)

      Function that is going to be called on DOM ready event. You can also subscribe to this event via Eve's DOMLoad event. In this case the method returns undefined.

        • (this: Window): void
        • Parameters

          • this: Window

          Returns void

    Returns RaphaelPaper<TTechnology>

    A new raphael paper that can be used for drawing shapes to the canvas.

Properties

Object that contains easing formulas for animation. You could extend it with your own. By default it has the easing methods as defined in RaphaelBuiltinEasingFormula.

You can add your own method to elements. This is useful when you want to hack default functionality or want to wrap some common transformation or attributes in one method. In contrast to canvas methods, you can redefine element method at any time. Expending element methods would not affect set.

Raphael.el.red = function () {
this.attr({fill: "#f00"});
};
// then use it
paper.circle(100, 100, 20).red();

Note to TypeScript users

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

import { RaphaelElement } from "raphael"
declare module "raphael" {
interface RaphaelElement {
red(): void;
colored(r: number, g: number, b: number): this;
}
}
fn: RaphaelPaperPluginRegistry<TTechnology, RaphaelPaper<TTechnology>>

You can add your own method to the canvas. For example if you want to draw a pie chart, you can create your own pie chart function and ship it as a Raphaël plugin. To do this you need to extend the Raphael.fn object.

Please note that you can create your own namespaces inside the fn object, methods will be run in the context of the canvas. You should alter the fn object before a Raphaël instance is created, otherwise it will take no effect.

Raphael.fn.arrow = function (x1, y1, x2, y2, size) {
return this.path( ... );
};
// or create namespace
Raphael.fn.mystuff = {
arrow: function () {…},
star: function () {…},
// etc...
};

var paper = Raphael(10, 10, 630, 480);
// then use it
paper.arrow(10, 10, 30, 30, 5).attr({fill: "#f00"});
paper.mystuff.arrow();
paper.mystuff.star();

Note to TypeScript users

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

import { RaphaelPaper, RaphaelPath } from "raphael"
declare module "raphael" {
interface RaphaelPaper {
arrow(x1: number, y1: number, x2: number, y2: number, size: number): RaphaelPath;
mystuff: {
arrow(flag: boolean): number;
star(): void;
};
}
}

On each call returns next colour in the spectrum. Also contains a utility method to reset it back to red via Raphael.getColor.reset

st: RaphaelSetPluginRegistry<TTechnology>

You can add your own method to elements and sets. It is wise to add a set method for each element method you added, so you will be able to call the same method on sets too. See also el.

Raphael.el.red = function() {
this.attr({fill: "#f00"});
};

Raphael.st.red = function() {
this.forEach(function () {
this.red();
});
};

// then use it
paper.set(paper.circle(100, 100, 20), paper.circle(110, 100, 20)).red();

Note to TypeScript users

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

import { RaphaelSet } from "raphael"
declare module "raphael" {
interface RaphaelSet {
green(): void;
colorized(r: number, g: number, b: number): this;
}
}
svg: boolean

true if browser supports SVG (scalable vector graphics), or false otherwise.

type: TTechnology

The technology used by Raphaël for the graphics.

vml: boolean

True if browser supports VML (vector markup language).

Methods

  • angle(x1: number, y1: number, x2: number, y2: number, x3?: number, y3?: number): number
  • Returns angle between two or three points

    Parameters

    • x1: number

      x coordinate of first point

    • y1: number

      y coordinate of first point

    • x2: number

      x coordinate of second point

    • y2: number

      y coordinate of second point

    • Optional x3: number

      x coordinate of third point

    • Optional y3: number

      y coordinate of third point

    Returns number

    The angle in degrees.

  • deg(radians: number): number
  • Transform angle from radians to degrees.

    Parameters

    • radians: number

      An angle in radians.

    Returns number

    The given angle in degrees.

  • findDotsAtSegment(startPointX: number, startPointY: number, anchor1X: number, anchor1Y: number, anchor2X: number, anchor2Y: number, endPointX: number, endPointY: number, positionOnCurve: number): RaphaelCubicBezierCurvePointInfo
  • Utility method to find dot coordinates on the given cubic bezier curve at the given position.

    Parameters

    • startPointX: number

      x of the first point of the curve.

    • startPointY: number

      y of the first point of the curve.

    • anchor1X: number

      x of the first anchor of the curve.

    • anchor1Y: number

      y of the first anchor of the curve.

    • anchor2X: number

      x of the second anchor of the curve.

    • anchor2Y: number

      y of the second anchor of the curve.

    • endPointX: number

      x of the second point of the curve.

    • endPointY: number

      y of the second point of the curve.

    • positionOnCurve: number

      Position on the curve, between 0 and 1.

    Returns RaphaelCubicBezierCurvePointInfo

    The point at the specified cubic bezier curve at the given position.

  • format(token: string, ...parameters: any[]): string
  • Simple format function. Replaces construction of type {<number>} with the corresponding argument.

    var x = 10;
    var y = 20;
    var width = 40;
    var height = 50;

    // this will draw a rectangular shape equivalent to "M10,20h40v50h-40z"
    paper.path(Raphael.format("M{1},{2}h{3}v{4}h{5}z", x, y, width, height, -width));

    See also format.

    Parameters

    • token: string

      String to format.

    • Rest ...parameters: any[]

      Arguments that will be treated as parameters for replacement. They will be coerced to type string.

    Returns string

    The formatted string.

  • fullfill(token: string, json: Record<string, any>): string
  • A little bit more advanced format function than format. Replaces construction of type {<name>} with the corresponding argument.

    // this will draw a rectangular shape equivalent to "M10,20h40v50h-40z"
    paper.path(Raphael.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
    x: 10,
    y: 20,
    dim: {
    width: 40,
    height: 50,
    "negative width": -40
    }
    }));

    Parameters

    • token: string

      String to format.

    • json: Record<string, any>

      Object with properties that will be used as a replacement.

    Returns string

    The formatted string.

  • Return coordinates of the point located at the given length on the given path.

    Parameters

    • path: string

      SVG path string.

    • length: number

      Length at which to get the point.

    Returns RaphaelCartesianCurvePoint

    The point located at the given length on the given path.

  • Parses a color string as an RGB object. Takes a color string in one of the following formats:

    • Colour name (red, green, cornflowerblue, etc)
    • #RGB - shortened HTML colour: (#000, #fc0, etc)
    • #RRGGBB - full length HTML colour: (#000000, #bd2300)
    • rgb(RRR, GGG, BBB) - red, green and blue channels' values: (rgb(200, 100, 0))
    • rgb(RRR%, GGG%, BBB%) - same as above, but in %: (rgb(100%, 175%, 0%))
    • hsb(HHH, SSS, BBB) - hue, saturation and brightness values: (hsb(0.5, 0.25, 1))
    • hsb(HHH%, SSS%, BBB%) - same as above, but in %
    • hsl(HHH, SSS, LLL) - same as hsb
    • hsl(HHH%, SSS%, LLL%) - same as hsb

    Parameters

    • color: string

      Color string to be parsed.

    Returns RaphaelPotentialFailure<RaphaelRgbComponentInfo>

    The RGB components of the parsed color string.

  • getSubpath(path: string, from: number, to: number): string
  • Return sub path of a given path from given length to given length.

    Parameters

    • path: string

      SVG path string

    • from: number

      Position of the start of the segment

    • to: number

      Position of the end of the segment

    Returns string

    Path string for the segment.

  • getTotalLength(path: string): number
  • Returns length of the given path in pixels.

    Parameters

    • path: string

      SVG path string.

    Returns number

    The length of the path.

  • hsb(hue: number, saturation: number, brightness: number): string
  • Converts HSB values to hex representation of the color.

    Parameters

    • hue: number

      Hue channel

    • saturation: number

      Saturation channel.

    • brightness: number

      Brightness channel.

    Returns string

    Hex representation of the color.

  • Converts HSB values to RGB object.

    Parameters

    • hue: number

      Hue channel.

    • saturation: number

      Saturation channel.

    • brightness: number

      Brightness channel.

    Returns RaphaelRgbComponentInfo

    The color in the RGB color system.

  • hsl(hue: number, saturation: number, luminosity: number): string
  • Converts HSL values to hex representation of the colour.

    Parameters

    • hue: number

      Hue channel.

    • saturation: number

      Saturation channel.

    • luminosity: number

      Luminosity channel.

    Returns string

    Hex representation of the color.

  • Converts HSL values to RGB object.

    Parameters

    • hue: number

      Hue channel.

    • saturation: number

      Saturation channel.

    • luminosity: number

      Luminosity channel.

    Returns RaphaelRgbComponentInfo

    The color in the RGB color system.

  • is(object: any, type: "undefined"): object is undefined
  • is(object: any, type: "null"): object is null
  • is(object: any, type: "boolean"): object is boolean
  • is(object: any, type: "number"): object is number
  • is(object: any, type: "symbol"): object is symbol
  • is(object: any, type: "string"): object is string
  • is(object: any, type: "object"): object is null | object
  • is(object: any, type: "function"): object is ((...args: any[]) => any)
  • is(object: any, type: "array"): object is any[]
  • is(object: any, type: string): boolean
  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "undefined"

      Type to check.

    Returns object is undefined

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "null"

      Type to check.

    Returns object is null

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "boolean"

      Type to check.

    Returns object is boolean

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "number"

      Type to check.

    Returns object is number

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "symbol"

      Type to check.

    Returns object is symbol

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "string"

      Type to check.

    Returns object is string

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "object"

      Type to check.

    Returns object is null | object

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "function"

      Type to check.

    Returns object is ((...args: any[]) => any)

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: "array"

      Type to check.

    Returns object is any[]

    true if the object is of the given type, or false otherwise.

  • Handy replacement for typeof operator.

    Parameters

    • object: any

      An object whose type to check.

    • type: string

      Type to check for.

    Returns boolean

    true if the object is of the given type, or false otherwise.

  • Returns true if given point is inside the bounding box.

    Parameters

    Returns boolean

    true if point the point is inside

  • matrix(a: number, b: number, c: number, d: number, e: number, f: number): RaphaelMatrix
  • Utility method for creating a 2x3 matrix based on given parameters:

    +---+---+---+
    | a | c | e |
    | b | d | f |
    +---+---+---+

    Parameters

    • a: number

      The matrix component at the first row, first column.

    • b: number

      The matrix component at the second row, first column.

    • c: number

      The matrix component at the first row, second column.

    • d: number

      The matrix component at the second row, second column.

    • e: number

      The matrix component at the third row, first column.

    • f: number

      The matrix component at the third row, second column.

    Returns RaphaelMatrix

    A matrix based on the given parameters.

  • If you want to leave no trace of Raphaël (Well, Raphaël creates only one global variable Raphael, but anyway.) You can use ninja method. Beware, that in this case plugins could stop working, because they are depending on the existence of the global variable.

    Returns RaphaelStatic<TTechnology>

    The Raphael object with all available methods.

  • Utility method that parses given path string into an array of arrays of path segments.

    Parameters

    Returns RaphaelPathSegment[]

    Array of path segments.

  • rad(degrees: number): number
  • Transform angle from degrees to radians.

    Parameters

    • degrees: number

      An angle in degrees.

    Returns number

    The given angle in radians.

  • Adds given font to the registered set of fonts for Raphaël. Should be used as an internal call from within Cufón's font file. Returns original parameter, so it could be used with chaining.

    Parameters

    Returns RaphaelFont

    The font you passed in

  • rgb(red: number, green: number, blue: number): string
  • Converts RGB values to hex representation of the colour.

    Parameters

    • red: number

      The red channel.

    • green: number

      The green channel.

    • blue: number

      The blue channel.

    Returns string

    Hex representation of the color.

  • Converts RGB values to HSB values.

    Parameters

    • red: number

      The red channel.

    • green: number

      The green channel.

    • blue: number

      The blue channel.

    Returns RaphaelHsbComponentInfo

    The given color in the HSB color format.

  • Converts RGB values to HSB values.

    Parameters

    • red: number

      The red channel.

    • green: number

      The green channel.

    • blue: number

      The blue channel.

    Returns RaphaelHslComponentInfo

    The given color in the HSL color format.

  • setWindow(newWindow: Window): void
  • Used when you need to draw in IFRAME. Switches window to the iframe one.

    Parameters

    • newWindow: Window

      The new window object

    Returns void

  • snapTo(values: number | readonly number[], value: number, tolerance?: number): number
  • Snaps the given value to the given grid.

    Parameters

    • values: number | readonly number[]

      Array of grid values or step of the grid.

    • value: number

      Value to adjust.

    • Optional tolerance: number

      Tolerance for snapping. Default is 10.

    Returns number

    The adjusted value.

Generated using TypeDoc