X-Git-Url: http://git.roojs.org/?p=raphael;a=blobdiff_plain;f=reference.html;h=51a85cdb697fe302fd72ebc7b496445a3d3339b1;hp=b998b3c79aef1d2a7016fe80cc46bc33df6d53aa;hb=300aa589f5a0ba7fce667cd62c7cdda0bd5ad904;hpb=12bea8afa5fc8084070d300297bc518f5d96b02e diff --git a/reference.html b/reference.html index b998b3c..51a85cd 100644 --- a/reference.html +++ b/reference.html @@ -1,8 +1,8 @@ -Raphaël Reference
  1. Animation
  2. Animation.delay()
  3. Animation.repeat()
  4. Element
  5. Element.animate()
  6. Element.animateWith()
  7. Element.attr()
  8. Element.clone()
  9. Element.drag()
  10. Element.getBBox()
  11. Element.getPointAtLength()
  12. Element.getSubpath()
  13. Element.getTotalLength()
  14. Element.glow()
  15. Element.hide()
  16. Element.hover()
  17. Element.id
  18. Element.insertAfter()
  19. Element.insertBefore()
  20. Element.next
  21. Element.node
  22. Element.onDragOver()
  23. Element.paper
  24. Element.pause()
  25. Element.prev
  26. Element.raphael
  27. Element.remove()
  28. Element.resume()
  29. Element.rotate()
  30. Element.scale()
  31. Element.setTime()
  32. Element.show()
  33. Element.status()
  34. Element.stop()
  35. Element.toBack()
  36. Element.toFront()
  37. Element.transform()
  38. Element.translate()
  39. Element.undrag()
  40. Element.unhover()
  41. Paper
  42. Paper.bottom
  43. Paper.circle()
  44. Paper.clear()
  45. Paper.customAttributes
  46. Paper.ellipse()
  47. Paper.forEach()
  48. Paper.getById()
  49. Paper.getElementByPoint()
  50. Paper.image()
  51. Paper.path()
  52. Paper.raphael
  53. Paper.rect()
  54. Paper.remove()
  55. Paper.safari()
  56. Paper.set()
  57. Paper.setSize()
  58. Paper.setViewBox()
  59. Paper.text()
  60. Paper.top
  61. Raphael()
  62. Raphael.angle()
  63. Raphael.animation()
  64. Raphael.deg()
  65. Raphael.easing_formulas
  66. Raphael.el
  67. Raphael.findDotsAtSegment()
  68. Raphael.fn
  69. Raphael.getColor()
  70. Raphael.getColor.reset()
  71. Raphael.getPointAtLength()
  72. Raphael.getRGB()
  73. Raphael.getSubpath()
  74. Raphael.getTotalLength()
  75. Raphael.hsb()
  76. Raphael.hsb2rgb()
  77. Raphael.hsl()
  78. Raphael.hsl2rgb()
  79. Raphael.is()
  80. Raphael.parsePathString()
  81. Raphael.parseTransformString()
  82. Raphael.path2curve()
  83. Raphael.pathToRelative()
  84. Raphael.rad()
  85. Raphael.rgb()
  86. Raphael.rgb2hsb()
  87. Raphael.rgb2hsl()
  88. Raphael.setWindow()
  89. Raphael.snapTo()
  90. Raphael.svg
  91. Raphael.type
  92. Raphael.vml
  93. Set
  94. Set.forEach()
  95. Set.pop()
  96. Set.push()

Raphaël Reference

Check out the source: raphael.js

Animation

-

Animation.delay(delay)

-

Creates copy of existing animation object with given delay. +Raphaël Reference

  1. Animation
  2. Animation.delay()
  3. Animation.repeat()
  4. Element
  5. Element.animate()
  6. Element.animateWith()
  7. Element.attr()
  8. Element.click()
  9. Element.clone()
  10. Element.data()
  11. Element.dblclick()
  12. Element.drag()
  13. Element.getBBox()
  14. Element.getPointAtLength()
  15. Element.getSubpath()
  16. Element.getTotalLength()
  17. Element.glow()
  18. Element.hide()
  19. Element.hover()
  20. Element.id
  21. Element.insertAfter()
  22. Element.insertBefore()
  23. Element.mousedown()
  24. Element.mousemove()
  25. Element.mouseout()
  26. Element.mouseover()
  27. Element.mouseup()
  28. Element.next
  29. Element.node
  30. Element.onDragOver()
  31. Element.paper
  32. Element.pause()
  33. Element.prev
  34. Element.raphael
  35. Element.remove()
  36. Element.removeData()
  37. Element.resume()
  38. Element.rotate()
  39. Element.scale()
  40. Element.setTime()
  41. Element.show()
  42. Element.status()
  43. Element.stop()
  44. Element.toBack()
  45. Element.toFront()
  46. Element.touchcancel()
  47. Element.touchend()
  48. Element.touchmove()
  49. Element.touchstart()
  50. Element.transform()
  51. Element.translate()
  52. Element.unclick()
  53. Element.undblclick()
  54. Element.undrag()
  55. Element.unhover()
  56. Element.unmousedown()
  57. Element.unmousemove()
  58. Element.unmouseout()
  59. Element.unmouseover()
  60. Element.unmouseup()
  61. Element.untouchcancel()
  62. Element.untouchend()
  63. Element.untouchmove()
  64. Element.untouchstart()
  65. Matrix
  66. Matrix.add()
  67. Matrix.clone()
  68. Matrix.invert()
  69. Matrix.rotate()
  70. Matrix.scale()
  71. Matrix.split()
  72. Matrix.toTransformString()
  73. Matrix.translate()
  74. Matrix.x()
  75. Matrix.y()
  76. Paper
  77. Paper.add()
  78. Paper.bottom
  79. Paper.ca
  80. Paper.circle()
  81. Paper.clear()
  82. Paper.customAttributes
  83. Paper.ellipse()
  84. Paper.forEach()
  85. Paper.getById()
  86. Paper.getElementByPoint()
  87. Paper.getFont()
  88. Paper.image()
  89. Paper.path()
  90. Paper.print()
  91. Paper.raphael
  92. Paper.rect()
  93. Paper.remove()
  94. Paper.renderfix()
  95. Paper.safari()
  96. Paper.set()
  97. Paper.setFinish()
  98. Paper.setSize()
  99. Paper.setStart()
  100. Paper.setViewBox()
  101. Paper.text()
  102. Paper.top
  103. Raphael()
  104. Raphael.angle()
  105. Raphael.animation()
  106. Raphael.color()
  107. Raphael.createUUID()
  108. Raphael.deg()
  109. Raphael.easing_formulas
  110. Raphael.el
  111. Raphael.findDotsAtSegment()
  112. Raphael.fn
  113. Raphael.format()
  114. Raphael.fullfill()
  115. Raphael.getColor()
  116. Raphael.getColor.reset()
  117. Raphael.getPointAtLength()
  118. Raphael.getRGB()
  119. Raphael.getSubpath()
  120. Raphael.getTotalLength()
  121. Raphael.hsb()
  122. Raphael.hsb2rgb()
  123. Raphael.hsl()
  124. Raphael.hsl2rgb()
  125. Raphael.is()
  126. Raphael.matrix()
  127. Raphael.ninja()
  128. Raphael.parsePathString()
  129. Raphael.parseTransformString()
  130. Raphael.path2curve()
  131. Raphael.pathToRelative()
  132. Raphael.rad()
  133. Raphael.registerFont()
  134. Raphael.rgb()
  135. Raphael.rgb2hsb()
  136. Raphael.rgb2hsl()
  137. Raphael.setWindow()
  138. Raphael.snapTo()
  139. Raphael.st
  140. Raphael.svg
  141. Raphael.type
  142. Raphael.vml
  143. Set
  144. Set.clear()
  145. Set.exclude()
  146. Set.forEach()
  147. Set.pop()
  148. Set.push()
  149. Set.splice()
  150. eve()
  151. eve.listeners()
  152. eve.nt()
  153. eve.on()
  154. eve.once()
  155. eve.stop()
  156. eve.unbind()
  157. eve.version

Raphaël Reference

 Animation

+

 Animation.delay(delay)

+

Creates a copy of existing animation object with given delay.

Parameters

@@ -11,8 +11,12 @@
number of ms to pass between animation start and actual animation

Returns: object new altered Animation object

-

Animation.repeat(repeat)

-

Creates copy of existing animation object with given repetition. +

var anim = Raphael.animation({cx: 10, cy: 20}, 2e3);
+circle1.animate(anim); // run the given animation immediately
+circle2.animate(anim.delay(500)); // run the given animation after 500 ms
+
+

 Animation.repeat(repeat)

+

Creates a copy of existing animation object with given repetition.

Parameters

@@ -21,9 +25,9 @@
number iterations of animation. For infinite animation pass Infinity

Returns: object new altered Animation object

-

Element

-

Element.animate(…)

-

Creates and starts animation for given element. +

 Element

+

 Element.animate(…)

+

Creates and starts animation for given element.

Parameters

@@ -36,7 +40,7 @@
easing
optional
string
-
easing type. Accept on of Raphael.easing_formulas or CSS format: cubic‐bezier(XX, XX, XX, XX)
+
easing type. Accept one of Raphael.easing_formulas or CSS format: cubic‐bezier(XX, XX, XX, XX)
callback
optional
function
@@ -49,15 +53,23 @@
animation object, see Raphael.animation

Returns: object original element

-

Element.animateWith(…)

-

Acts similar to Element.animate, but ensure that given animation runs in sync with another given element. +

 Element.animateWith(…)

+

Acts similar to Element.animate, but ensure that given animation runs in sync with another given element.

Parameters

-
params
+
element
+
object
+
element to sync with
+
anim
+
object
+
animation to sync with
+
params
+
optional
object
final attributes for the element, see also Element.attr
-
ms
+
ms
+
optional
number
number of milliseconds for animation to run
easing
@@ -71,13 +83,20 @@

or

-
animation
+
element
+
object
+
element to sync with
+
anim
+
object
+
animation to sync with
+
animation
+
optional
object
animation object, see Raphael.animation

Returns: object original element

-

Element.attr(…)

-

Sets the attributes of the element. +

 Element.attr(…)

+

Sets the attributes of the element.

Parameters

@@ -116,8 +135,8 @@
  1. arrow-endstringarrowhead on the end of the path. The format for string is <type>[-<width>[-<length>]]. Possible types: classic, block, open, oval, diamond, none, width: wide, narrow, midium, length: long, short, midium.
  2. clip-rectstringcomma or space separated values: x, y, width and height
  3. cursorstringCSS type of the cursor -
  4. cxnumber  -
  5. cynumber  +
  6. cxnumberthe x-axis coordinate of the center of the circle, or ellipse +
  7. cynumberthe y-axis coordinate of the center of the circle, or ellipse
  8. fillstringcolour, gradient or image
  9. fill-opacitynumber 
  10. fontstring  @@ -128,9 +147,9 @@
  11. hrefstringURL, if specified element behaves as hyperlink
  12. opacitynumber 
  13. pathstringSVG path string format -
  14. rnumber  -
  15. rxnumber  -
  16. rynumber  +
  17. rnumberradius of the circle, ellipse or rounded corner on the rect +
  18. rxnumberhorisontal radius of the ellipse +
  19. rynumbervertical radius of the ellipse
  20. srcstringimage URL, only works for Element.image element
  21. strokestringstroke colour
  22. stroke-dasharraystring[“”, “-”, “.”, “-.”, “-..”, “. ”, “- ”, “--”, “- .”, “--.”, “--..”] @@ -174,13 +193,62 @@ at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can o
  23. hsba(•••, •••, •••, •••) — same as above, but with opacity
  24. hsl(•••, •••, •••) — almost the same as hsb, see Wikipedia page
  25. hsl(•••%, •••%, •••%) — same as above, but in %
  26. -
  27. hsla(•••, •••, •••) — same as above, but with opacity
  28. +
  29. hsla(•••, •••, •••, •••) — same as above, but with opacity
  30. Optionally for hsb and hsl you could specify hue as a degree: “hsl(240deg, 1, .5)” or, if you want to go fancy, “hsl(240°, 1, .5)”
  31. -

Element.clone()

-

Returns: object clone of a given element

-

Element.drag(onmove, onstart, onend, [mcontext], [scontext], [econtext])

-

Adds event handlers for drag of the element. +

 Element.click(handler)

+

Adds event handler for click for the element. +

+

Parameters +

+
handler
+
function
+
handler for the event
+
+

Returns: object Element

+

 Element.clone()

+

Returns: object clone of a given element

+

 Element.data(key, [value])

+

Adds or retrieves given value asociated with given key. +See also Element.removeData +

+

Parameters +

+
key
+
string
+
key to store data
+
value
+
optional
+
any
+
value to store
+
+

Returns: object Element

+

or, if value is not specified: +

+

Returns: any value

+

Usage +

+
for (var i = 0, i < 5, i++) {
+    paper.circle(10 + 15 * i, 10, 10)
+         .attr({fill: "#000"})
+         .data("i", i)
+         .click(function () {
+            alert(this.data("i"));
+         });
+}
+
+

 Element.dblclick(handler)

+

Adds event handler for double click for the element. +

+

Parameters +

+
handler
+
function
+
handler for the event
+
+

Returns: object Element

+

 Element.drag(onmove, onstart, onend, [mcontext], [scontext], [econtext])

+

Adds event handlers for drag of the element.

Parameters

@@ -229,8 +297,8 @@ at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can o
  1. eventobjectDOM event object

Returns: object Element

-

Element.getBBox(isWithoutTransform)

-

Return bounding box for a given element +

 Element.getBBox(isWithoutTransform)

+

Return bounding box for a given element

Parameters

@@ -244,8 +312,8 @@ at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can o
  • width:numberwidth
  • height:numberheight
  • }
  • -

    Element.getPointAtLength(length)

    -

    Return coordinates of the point located at the given length on the given path. Only works for element of “path” type. +

     Element.getPointAtLength(length)

    +

    Return coordinates of the point located at the given length on the given path. Only works for element of “path” type.

    Parameters

    @@ -258,8 +326,8 @@ at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can o
  • y:numbery coordinate
  • alpha:numberangle of derivative
  • }
  • -

    Element.getSubpath(from, to)

    -

    Return subpath of a given element from given length to given length. Only works for element of “path” type. +

     Element.getSubpath(from, to)

    +

    Return subpath of a given element from given length to given length. Only works for element of “path” type.

    Parameters

    @@ -271,22 +339,36 @@ at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can o
    position of the end of the segment

    Returns: string pathstring for the segment

    -

    Element.getTotalLength()

    -

    Returns length of the path in pixels. Only works for element of “path” type. +

     Element.getTotalLength()

    +

    Returns length of the path in pixels. Only works for element of “path” type.

    Returns: number length.

    -

    Element.glow()

    -

    Return set of elements that create glow-like effect around given element. See Paper.set. +

     Element.glow([glow])

    +

    Return set of elements that create glow-like effect around given element. See Paper.set.

    -

    Note: Glow is not connected to the elment. If you change element attributes it won’t adjust itself. +

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

    +

    Parameters +

    +
    glow
    +
    optional
    +
    object
    +
    parameters object with all properties optional:
    +
    +
    1. {
      1. widthnumbersize of the glow, default is 10 +
      2. fillbooleanwill it be filled, default is false +
      3. opacitynumberopacity, default is 0.5 +
      4. offsetxnumberhorizontal offset, default is 0 +
      5. offsetynumbervertical offset, default is 0 +
      6. colorstringglow colour, default is black +
    2. }

    Returns: object Paper.set of elements that represents glow

    -

    Element.hide()

    -

    Makes element invisible. See Element.show. +

     Element.hide()

    +

    Makes element invisible. See Element.show.

    Returns: object Element

    -

    Element.hover(f_in, f_out, [icontext], [ocontext])

    -

    Adds event handlers for hover for the element. +

     Element.hover(f_in, f_out, [icontext], [ocontext])

    +

    Adds event handlers for hover for the element.

    Parameters

    @@ -306,23 +388,74 @@ at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can o
    context for hover out handler

    Returns: object Element

    -

    Element.id

    -
    number

    Unique id of the element. Especially usesful when you want to listen to events of the element, +

     Element.id

    +
    number

    Unique id of the element. Especially usesful when you want to listen to events of the element, because all events are fired in format <module>.<action>.<id>. Also useful for Paper.getById method.

    -

    Element.insertAfter()

    -

    Inserts current object after the given one. +

     Element.insertAfter()

    +

    Inserts current object after the given one. +

    +

    Returns: object Element

    +

     Element.insertBefore()

    +

    Inserts current object before the given one. +

    +

    Returns: object Element

    +

     Element.mousedown(handler)

    +

    Adds event handler for mousedown for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.mousemove(handler)

    +

    Adds event handler for mousemove for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.mouseout(handler)

    +

    Adds event handler for mouseout for the element. +

    +

    Parameters

    +
    handler
    +
    function
    +
    handler for the event
    +

    Returns: object Element

    -

    Element.insertBefore()

    -

    Inserts current object before the given one. +

     Element.mouseover(handler)

    +

    Adds event handler for mouseover for the element.

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +

    Returns: object Element

    -

    Element.next

    -
    object

    Reference to the next element in the hierarchy. +

     Element.mouseup(handler)

    +

    Adds event handler for mouseup for the element.

    -

    Element.node

    -
    object

    Gives you a reference to the DOM object, so you can assign event handlers or just mess around. +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.next

    +
    object

    Reference to the next element in the hierarchy. +

    +

     Element.node

    +
    object

    Gives you a reference to the DOM object, so you can assign event handlers or just mess around. +Note: Don’t mess with it.

    Usage

    @@ -332,17 +465,17 @@ c.node.onclick = function () { c.attr("fill", "red"); }; -

    Element.onDragOver(f)

    -

    Shortcut for assigning event handler for drag.over.<id> event, where id is id of the element (see Element.id). +

     Element.onDragOver(f)

    +

    Shortcut for assigning event handler for drag.over.<id> event, where id is id of the element (see Element.id).

    Parameters

    f
    function
    -
    handler for event
    +
    handler for event, first argument would be the element you are dragging over
    -

    Element.paper

    -
    object

    Internal reference to “paper” where object drawn. Mainly for use in plugins and element extensions. +

     Element.paper

    +
    object

    Internal reference to “paper” where object drawn. Mainly for use in plugins and element extensions.

    Usage

    @@ -352,8 +485,8 @@ c.node.onclick = function () { .attr({stroke: "red"}); } -

    Element.pause([anim])

    -

    Stops animation of the element with ability to resume it later on. +

     Element.pause([anim])

    +

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

    Parameters

    @@ -363,11 +496,11 @@ c.node.onclick = function () {
    animation object

    Returns: object original element

    -

    Element.prev

    -
    object

    Reference to the previous element in the hierarchy. +

     Element.prev

    +
    object

    Reference to the previous element in the hierarchy.

    -

    Element.raphael

    -
    object

    Internal reference to Raphael object. In case it is not available. +

     Element.raphael

    +
    object

    Internal reference to Raphael object. In case it is not available.

    Usage

    @@ -377,11 +510,23 @@ c.node.onclick = function () { this.attr({fill: this.paper.raphael.hsb2rgb(hsb).hex}); } -

    Element.remove()

    -

    Removes element form the paper. +

     Element.remove()

    +

    Removes element form the paper. +

    +

     Element.removeData([key])

    +

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

    -

    Element.resume([anim])

    -

    Resumes animation if it was paused with Element.pause method. +

    Parameters +

    +
    key
    +
    optional
    +
    string
    +
    key
    +
    +

    Returns: object Element

    +

     Element.resume([anim])

    +

    Resumes animation if it was paused with Element.pause method.

    Parameters

    @@ -391,8 +536,8 @@ c.node.onclick = function () {
    animation object

    Returns: object original element

    -

    Element.rotate(deg, [cx], [cy])

    -

    Adds rotation by given angle around given point to the list of +

     Element.rotate(deg, [cx], [cy])

    +

    Adds rotation by given angle around given point to the list of transformations of the element.

    Parameters @@ -412,8 +557,8 @@ transformations of the element.

    If cx & cy aren’t specified centre of the shape is used as a point of rotation.

    Returns: object Element

    -

    Element.scale(sx, sy, [cx], [cy])

    -

    Adds scale by given amount relative to given point to the list of +

     Element.scale(sx, sy, [cx], [cy])

    +

    Adds scale by given amount relative to given point to the list of transformations of the element.

    Parameters @@ -436,8 +581,8 @@ transformations of the element.

    If cx & cy aren’t specified centre of the shape is used instead.

    Returns: object Element

    -

    Element.setTime(anim, value)

    -

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

     Element.setTime(anim, value)

    +

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

    Parameters

    @@ -453,12 +598,12 @@ transformations of the element.

    On each animation frame event anim.frame.<id>, on start anim.start.<id> and on end anim.finish.<id>.

    -

    Element.show()

    -

    Makes element visible. See Element.hide. +

     Element.show()

    +

    Makes element visible. See Element.hide.

    Returns: object Element

    -

    Element.status([anim], [value])

    -

    Gets or sets the status of animation of the element. +

     Element.status([anim], [value])

    +

    Gets or sets the status of animation of the element.

    Parameters

    @@ -481,8 +626,8 @@ transformations of the element.

    or

    Returns: object original element if value is specified

    -

    Element.stop([anim])

    -

    Stops animation of the element. +

     Element.stop([anim])

    +

    Stops animation of the element.

    Parameters

    @@ -492,16 +637,56 @@ transformations of the element.
    animation object

    Returns: object original element

    -

    Element.toBack()

    -

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

     Element.toBack()

    +

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

    Returns: object Element

    -

    Element.toFront()

    -

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

     Element.toFront()

    +

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

    Returns: object Element

    -

    Element.transform([tstr])

    -

    Adds transformation to the element which is separate to other attributes, +

     Element.touchcancel(handler)

    +

    Adds event handler for touchcancel for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.touchend(handler)

    +

    Adds event handler for touchend for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.touchmove(handler)

    +

    Adds event handler for touchmove for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.touchstart(handler)

    +

    Adds event handler for touchstart for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.transform([tstr])

    +

    Adds transformation to the element which is separate to other attributes, i.e. translation doesn’t change x or y of the rectange. The format of transformation string is similar to the path string syntax:

    @@ -510,9 +695,11 @@ of transformation string is similar to the path string syntax:

    Each letter is a command. There are four commands: t is for translate, r is for rotate, s is for scale and m is for matrix.

    -

    So, example line could be read like “translate by 100, 100, rotate 30° around 100, 100, scale twice around 100, 100 -rotate 45° around centre and scale 1.5 times relative to centre”. As you see rotate and scale commands has origin -coordinates as a optional parameters. +

    There are also alternative “absolute” translation, rotation and scale: T, R and S. They will not take previous transformation into account. For example, ...T100,0 will always move element 100 px horisontally, while ...t100,0 could move it vertically if there is r90 before. Just compare results of r90t100,0 and r90T100,0. +

    +

    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.

    Usage @@ -543,8 +730,8 @@ console.log(el.transform());

    else

    Returns: object Element

    -

    Element.translate(dx, dy)

    -

    Adds translation by given amount to the list of transformations of the element. +

     Element.translate(dx, dy)

    +

    Adds translation by given amount to the list of transformations of the element.

    Parameters

    @@ -556,11 +743,31 @@ console.log(el.transform());
    vertical shift

    Returns: object Element

    -

    Element.undrag()

    -

    Removes all drag event handlers from given element. +

     Element.unclick(handler)

    +

    Removes event handler for click for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.undblclick(handler)

    +

    Removes event handler for double click for the element.

    -

    Element.unhover(f_in, f_out)

    -

    Removes event handlers for hover for the element. +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.undrag()

    +

    Removes all drag event handlers from given element. +

    +

     Element.unhover(f_in, f_out)

    +

    Removes event handlers for hover for the element.

    Parameters

    @@ -572,12 +779,260 @@ console.log(el.transform());
    handler for hover out

    Returns: object Element

    -

    Paper

    -

    Paper.bottom

    -

    Points to the bottom element on the paper +

     Element.unmousedown(handler)

    +

    Removes event handler for mousedown for the element.

    -

    Paper.circle(x, y, r)

    -

    Draws a circle. +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.unmousemove(handler)

    +

    Removes event handler for mousemove for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.unmouseout(handler)

    +

    Removes event handler for mouseout for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.unmouseover(handler)

    +

    Removes event handler for mouseover for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.unmouseup(handler)

    +

    Removes event handler for mouseup for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.untouchcancel(handler)

    +

    Removes event handler for touchcancel for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.untouchend(handler)

    +

    Removes event handler for touchend for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.untouchmove(handler)

    +

    Removes event handler for touchmove for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Element.untouchstart(handler)

    +

    Removes event handler for touchstart for the element. +

    +

    Parameters +

    +
    handler
    +
    function
    +
    handler for the event
    +
    +

    Returns: object Element

    +

     Matrix

    +

     Matrix.add(a, b, c, d, e, f, matrix)

    +

    Adds given matrix to existing one. +

    +

    Parameters +

    +
    a
    +
    number
    +
     
    +
    b
    +
    number
    +
     
    +
    c
    +
    number
    +
     
    +
    d
    +
    number
    +
     
    +
    e
    +
    number
    +
     
    +
    f
    +
    number
    +
     
    +
    matrix
    +
    object
    +
    Matrix
    +
    +

     Matrix.clone()

    +

    Returns copy of the matrix +

    +

    Returns: object Matrix

    +

     Matrix.invert()

    +

    Returns inverted version of the matrix +

    +

    Returns: object Matrix

    +

     Matrix.rotate(a, x, y)

    +

    Rotates the matrix +

    +

    Parameters +

    +
    a
    +
    number
    +
     
    +
    x
    +
    number
    +
     
    +
    y
    +
    number
    +
     
    +
    +

     Matrix.scale(x, [y], [cx], [cy])

    +

    Scales the matrix +

    +

    Parameters +

    +
    x
    +
    number
    +
     
    +
    y
    +
    optional
    +
    number
    +
     
    +
    cx
    +
    optional
    +
    number
    +
     
    +
    cy
    +
    optional
    +
    number
    +
     
    +
    +

     Matrix.split()

    +

    Splits matrix into primitive transformations +

    +

    Returns: object in format:

    +
    1. dxnumbertranslation by x +
    2. dynumbertranslation by y +
    3. scalexnumberscale by x +
    4. scaleynumberscale by y +
    5. shearnumbershear +
    6. rotatenumberrotation in deg +
    7. isSimplebooleancould it be represented via simple transformations +
    +

     Matrix.toTransformString()

    +

    Return transform string that represents given matrix +

    +

    Returns: string transform string

    +

     Matrix.translate(x, y)

    +

    Translate the matrix +

    +

    Parameters +

    +
    x
    +
    number
    +
     
    +
    y
    +
    number
    +
     
    +
    +

     Matrix.x(x, y)

    +

    Return x coordinate for given point after transformation described by the matrix. See also Matrix.y +

    +

    Parameters +

    +
    x
    +
    number
    +
     
    +
    y
    +
    number
    +
     
    +
    +

    Returns: number x

    +

     Matrix.y(x, y)

    +

    Return y coordinate for given point after transformation described by the matrix. See also Matrix.x +

    +

    Parameters +

    +
    x
    +
    number
    +
     
    +
    y
    +
    number
    +
     
    +
    +

    Returns: number y

    +

     Paper

    +

     Paper.add(json)

    +

    Imports elements in JSON array in format {type: type, <attributes>} +

    +

    Parameters +

    +
    json
    +
    array
    +
     
    +
    +

    Returns: object resulting set of imported elements

    +

    Usage +

    +
    paper.import([
    +    {
    +        type: "circle",
    +        cx: 10,
    +        cy: 10,
    +        r: 5
    +    },
    +    {
    +        type: "rect",
    +        x: 10,
    +        y: 10,
    +        width: 10,
    +        height: 10,
    +        fill: "#fc0"
    +    }
    +]);
    +
    +

     Paper.bottom

    +

    Points to the bottom element on the paper +

    +

     Paper.ca

    +
    object

    Shortcut for Paper.customAttributes +

    +

     Paper.circle(x, y, r)

    +

    Draws a circle.

    Parameters

    @@ -596,18 +1051,18 @@ console.log(el.transform());

    var c = paper.circle(50, 50, 40);
     
    -

    Paper.clear()

    -

    Clears the paper, i.e. removes all the elements. +

     Paper.clear()

    +

    Clears the paper, i.e. removes all the elements.

    -

    Paper.customAttributes

    -
    object

    If you have a set of attributes that you would like to represent +

     Paper.customAttributes

    +
    object

    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:

    Usage

    paper.customAttributes.hue = function (num) {
         num = num % 1;
    -    return {fill: "hsb(" + num + ", .75, 1)"};
    +    return {fill: "hsb(" + num + ", 0.75, 1)"};
     };
     // Custom attribute “hue” will change fill
     // to be given hue with fixed saturation and brightness.
    @@ -621,11 +1076,11 @@ c.animate({hue: 1}, 1e3);
     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);
    +c.attr({hsb: "0.5 .8 1"});
    +c.animate({hsb: [1, 0, 0.5]}, 1e3);
     
    -

    Paper.ellipse(x, y, rx, ry)

    -

    Draws an ellipse. +

     Paper.ellipse(x, y, rx, ry)

    +

    Draws an ellipse.

    Parameters

    @@ -637,7 +1092,7 @@ c.animate({hsb: "1 0 y coordinate of the centre
    rx
    number
    -
    horisontal radius
    +
    horizontal radius
    ry
    number
    vertical radius
    @@ -647,10 +1102,10 @@ c.animate({hsb: "1 0
    var c = paper.ellipse(50, 50, 40, 20);
     
    -

    Paper.forEach(callback, thisArg)

    -

    Executes given function for each element on the paper +

     Paper.forEach(callback, thisArg)

    +

    Executes given function for each element on the paper

    -

    If function returns false it will stop loop running. +

    If callback function returns false it will stop loop running.

    Parameters

    @@ -662,8 +1117,8 @@ c.animate({hsb: "1 0 context object for the callback

    Returns: object Paper object

    -

    Paper.getById(id)

    -

    Returns you element by it’s internal ID. +

     Paper.getById(id)

    +

    Returns you element by its internal ID.

    Parameters

    @@ -672,8 +1127,8 @@ c.animate({hsb: "1 0 id

    Returns: object Raphaël element object

    -

    Paper.getElementByPoint(x, y)

    -

    Returns you topmost element under given point. +

     Paper.getElementByPoint(x, y)

    +

    Returns you topmost element under given point.

    Returns: object Raphaël element object

    Parameters @@ -689,8 +1144,34 @@ c.animate({hsb: "1 0

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

    Paper.image(src, x, y, width, height)

    -

    Embeds an image into the surface. +

     Paper.getFont(family, [weight], [style], [stretch])

    +

    Finds font object in the registered fonts by given parameters. You could specify only one word from the font name, like “Myriad” for “Myriad Pro”. +

    +

    Parameters +

    +
    family
    +
    string
    +
    font family name or any word from it
    +
    weight
    +
    optional
    +
    string
    +
    font weight
    +
    style
    +
    optional
    +
    string
    +
    font style
    +
    stretch
    +
    optional
    +
    string
    +
    font stretch
    +
    +

    Returns: object the font object

    +

    Usage +

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

     Paper.image(src, x, y, width, height)

    +

    Embeds an image into the surface.

    Parameters

    @@ -715,28 +1196,87 @@ c.animate({hsb: "1 0
    var c = paper.image("apple.png", 10, 10, 80, 80);
     
    -

    Paper.path(pathString)

    -

    Creates a path element by given path data string. +

     Paper.path([pathString])

    +

    Creates a path element by given path data string.

    Parameters

    -
    pathString
    +
    pathString
    +
    optional
    string
    -
    path data in SVG path string format.
    +
    path string in SVG format.
    -

    Returns: object Raphaël element object with type “ellipse”

    -Details of a path's data attribute's format are described in the SVG specification. +

    Path string consists of one-letter commands, followed by comma seprarated arguments in numercal form. Example: +

    +
    "M10,20L30,40"
    +
    +

    Here we can see two commands: “M”, with arguments (10, 20) and “L” with arguments (30, 40). Upper case letter mean command is absolute, lower case—relative. +

    +

    +

    Here is short list of commands available, for more details see SVG path string format.

    + + + + + + + + + + + +
    CommandNameParameters
    Mmoveto(x y)+
    Zclosepath(none)
    Llineto(x y)+
    Hhorizontal linetox+
    Vvertical linetoy+
    Ccurveto(x1 y1 x2 y2 x y)+
    Ssmooth curveto(x2 y2 x y)+
    Qquadratic Bézier curveto(x1 y1 x y)+
    Tsmooth quadratic Bézier curveto(x y)+
    Aelliptical arc(rx ry x-axis-rotation large-arc-flag sweep-flag x y)+
    RCatmull-Rom curveto*x1 y1 (x y)+
    +

    * “Catmull-Rom curveto” is a not standard SVG command and added in 2.0 to make life easier. +

    Usage

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

    Paper.raphael

    -

    Points to the Raphael object/function +

     Paper.print(x, y, text, font, [size], [origin], [letter_spacing])

    +

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

    -

    Paper.rect(x, y, width, height, r)

    -

    +

    Parameters +

    +
    x
    +
    number
    +
    x position of the text
    +
    y
    +
    number
    +
    y position of the text
    +
    text
    +
    string
    +
    text to print
    +
    font
    +
    object
    +
    font object, see Paper.getFont
    +
    size
    +
    optional
    +
    number
    +
    size of the font, default is 16
    +
    origin
    +
    optional
    +
    string
    +
    could be "baseline" or "middle", default is "middle"
    +
    letter_spacing
    +
    optional
    +
    number
    +
    number in range -1..1, default is 0
    +
    +

    Returns: object resulting set of letters

    +

    Usage +

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

     Paper.raphael

    +

    Points to the Raphael object/function +

    +

     Paper.rect(x, y, width, height, [r])

    +

    Draws a rectangle.

    Parameters @@ -753,9 +1293,10 @@ Details of a path's data attribute's format are described in the height

    number
    height
    -
    r
    +
    r
    +
    optional
    number
    -
    optional radius for rounded corners, default is 0
    +
    radius for rounded corners, default is 0

    Returns: object Raphaël element object with type “rect”

    Usage @@ -765,33 +1306,23 @@ Details of a path's data attribute's format are described in the // rectangle with rounded corners var c = paper.rect(40, 40, 50, 50, 10); -

    Paper.remove()

    -

    Removes the paper from the DOM. +

     Paper.remove()

    +

    Removes the paper from the DOM.

    -

    Paper.safari(f_in, f_out, [icontext], [ocontext])

    -

    Adds event handlers for hover for the element. +

     Paper.renderfix()

    +

    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.

    -

    Parameters +

     Paper.safari()

    +

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

    -
    f_in
    -
    function
    -
    handler for hover in
    -
    f_out
    -
    function
    -
    handler for hover out
    -
    icontext
    -
    optional
    -
    object
    -
    context for hover in handler
    -
    ocontext
    -
    optional
    -
    object
    -
    context for hover out handler
    -
    -

    Returns: object Element

    -

    Paper.set()

    -

    Creates array-like object to keep and operate couple of elements at once. -Warning: it doesn’t create any elements for itself in the page. +

     Paper.set()

    +

    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.

    Returns: object array-like object that represents set of elements

    Usage @@ -801,10 +1332,14 @@ st.push( paper.circle(10, 10, 5), paper.circle(30, 10, 5) ); -st.attr({fill: "red"}); +st.attr({fill: "red"}); // changes the fill of both circles -

    Paper.setSize(width, height)

    -

    If you need to change dimensions of the canvas call this method +

     Paper.setFinish()

    +

    See Paper.setStart. This method finishes catching and returns resulting set. +

    +

    Returns: object set

    +

     Paper.setSize(width, height)

    +

    If you need to change dimensions of the canvas call this method

    Parameters

    @@ -824,8 +1359,20 @@ st.push( ); st.attr({fill: "red"}); -

    Paper.setViewBox(x, y, w, h, fit)

    -

    Sets the view box of the paper. Practically it gives you ability to zoom and pan whole paper surface by +

     Paper.setStart()

    +

    Creates Paper.set. All elements that will be created after calling this method and before calling +Paper.setFinish will be added to the set. +

    +

    Usage +

    +
    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
    +
    +

     Paper.setViewBox(x, y, w, h, fit)

    +

    Sets the view box of the paper. Practically it gives you ability to zoom and pan whole paper surface by specifying new boundaries.

    Parameters @@ -846,8 +1393,8 @@ specifying new boundaries.

    boolean
    true if you want graphics to fit into new boundary box
    -

    Paper.text(x, y, text)

    -

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

     Paper.text(x, y, text)

    +

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

    Parameters

    @@ -866,11 +1413,11 @@ specifying new boundaries.

    var t = paper.text(50, 50, "Raphaël\nkicks\nbutt!");
     
    -

    Paper.top

    -

    Points to the topmost element on the paper +

     Paper.top

    +

    Points to the topmost element on the paper

    -

    Raphael(…)

    -

    Creates a canvas object on which to draw. +

     Raphael(…)

    +

    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.

    @@ -878,13 +1425,17 @@ from this instance will be bound to this canvas.

    container
    HTMLElement string
    -
    DOM element or it’s id which is going to be a parent for drawing surface
    +
    DOM element or its ID which is going to be a parent for drawing surface
    width
    number
     
    height
    number
     
    +
    callback
    +
    optional
    +
    function
    +
    callback function which is going to be executed in the context of newly created paper

    or

    @@ -900,12 +1451,20 @@ from this instance will be bound to this canvas.
    height
    number
     
    +
    callback
    +
    optional
    +
    function
    +
    callback function which is going to be executed in the context of newly created paper

    or

    all
    array
    -
    (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>})
    +
    (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>}). See Paper.add.
    +
    callback
    +
    optional
    +
    function
    +
    callback function which is going to be executed in the context of newly created paper

    or

    @@ -916,8 +1475,9 @@ from this instance will be bound to this canvas.

    Returns: object Paper

    Usage

    -
    // Each of the following examples create a canvas that is 320px wide by 200px high
    -// Canvas is created at the viewport’s 10,50 coordinate
    +
    // Each of the following examples create a canvas
    +// that is 320px wide by 200px high.
    +// Canvas is created at the viewport’s 10,50 coordinate.
     var paper = Raphael(10, 50, 320, 200);
     // Canvas is created at the top left corner of the #notepad element
     // (or its top right corner in dir="rtl" elements)
    @@ -939,8 +1499,8 @@ from this instance will be bound to this canvas.
         text: "Dump"
     }]);
     
    -

    Raphael.angle(x1, y1, x2, y2, [x3], [y3])

    -

    Returns angle between two or three points +

     Raphael.angle(x1, y1, x2, y2, [x3], [y3])

    +

    Returns angle between two or three points

    Parameters

    @@ -966,8 +1526,8 @@ from this instance will be bound to this canvas.
    y coord of third point

    Returns: number angle in degrees.

    -

    Raphael.animation(params, ms, [easing], [callback])

    -

    Creates animation object. That later could be used for Element.animate or Element.animateWith methods. +

     Raphael.animation(params, ms, [easing], [callback])

    +

    Creates an animation object that can be passed to the Element.animate or Element.animateWith methods. See also Animation.delay and Animation.repeat methods.

    Parameters @@ -988,8 +1548,31 @@ See also Animation.delay and callback function. Will be called at the end of animation.

    Returns: object Animation

    -

    Raphael.deg(deg)

    -

    Transform angle to degrees +

     Raphael.color(clr)

    +

    Parses the color string and returns object with all values for the given color. +

    +

    Parameters +

    +
    clr
    +
    string
    +
    color string in one of the supported formats (see Raphael.getRGB)
    +
    +

    Returns: object Combined RGB & HSB object in format:

    +
    1. {
      1. rnumberred, +
      2. gnumbergreen, +
      3. bnumberblue, +
      4. hexstringcolor in HTML/CSS format: #••••••, +
      5. errorbooleantrue if string can’t be parsed, +
      6. hnumberhue, +
      7. snumbersaturation, +
      8. vnumbervalue (brightness), +
      9. lnumberlightness +
    2. }
    +

     Raphael.createUUID()

    +

    Returns RFC4122, version 4 ID +

    +

     Raphael.deg(deg)

    +

    Transform angle to degrees

    Parameters

    @@ -998,8 +1581,8 @@ See also Animation.delay and angle in radians

    Returns: number angle in degrees.

    -

    Raphael.easing_formulas

    -

    Object that contains easing formulas for animation. You could extend it with your owns. By default it has following list of easing: +

     Raphael.easing_formulas

    +

    Object that contains easing formulas for animation. You could extend it with your own. By default it has following list of easing:

    See also Easing demo.

    -

    Raphael.el

    -
    object

    You can add your own method to elements. This is usefull when you want to hack default functionality or +

     Raphael.el

    +
    object

    You can add your own method to elements. This is usefull when you want to hack default functionality or want to wrap some common transformation or attributes in one method. In difference to canvas methods, -you can redefine element method at any time. Expending element methods wouldn’t affect set +you can redefine element method at any time. Expending element methods wouldn’t affect set.

    Usage

    @@ -1025,8 +1608,8 @@ you can redefine element method at any time. Expending element methods wouldn’ // then use it paper.circle(100, 100, 20).red();
    -

    Raphael.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)

    -

    Utility method +

     Raphael.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t)

    +

    Utility method Find dot coordinates on the given cubic bezier curve at the given t.

    Parameters @@ -1072,12 +1655,13 @@ Find dot coordinates on the given cubic bezier curve at the given t.

  • y:numbery coordinate of the end of the curve
  • }
  • alpha:numberangle of the curve derivative at the point
  • }
  • -

    Raphael.fn

    -
    object

    You can add your own method to the canvas. For example if you want to draw pie chart, +

     Raphael.fn

    +
    object

    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 Raphael.fn object. Please note that you can create your own namespaces -inside fn object. Methods will be run in context of canvas anyway. You should alter fn -object before Raphaël instance was created, otherwise it will take no effect. +you need to extend the Raphael.fn object. You should modify the fn object before a +Raphaël instance is created, otherwise it will take no effect. Please note that the +ability for namespaced plugins was removed in Raphael 2.0. It is up to the plugin to +ensure any namespacing ensures proper context.

    Usage

    @@ -1096,8 +1680,56 @@ paper.arrow(10, 10, Raphael.getColor([value]) -

    On each call returns next colour in the spectrum. To reset it back to red call Raphael.getColor.reset +

     Raphael.format(token, …)

    +

    Simple format function. Replaces construction of type “{<number>}” to the corresponding argument. +

    +

    Parameters +

    +
    token
    +
    string
    +
    string to format
    +
    …
    +
    string
    +
    rest of arguments will be treated as parameters for replacement
    +
    +

    Returns: string formated string

    +

    Usage +

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

     Raphael.fullfill(token, json)

    +

    A little bit more advanced format function than Raphael.format. Replaces construction of type “{<name>}” to the corresponding argument. +

    +

    Parameters +

    +
    token
    +
    string
    +
    string to format
    +
    json
    +
    object
    +
    object which properties will be used as a replacement
    +
    +

    Returns: string formated string

    +

    Usage +

    +
    // 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
    +    }
    +}));
    +
    +

     Raphael.getColor([value])

    +

    On each call returns next colour in the spectrum. To reset it back to red call Raphael.getColor.reset

    Parameters

    @@ -1107,11 +1739,11 @@ paper.mystuff.star();
    brightness, default is 0.75

    Returns: string hex representation of the colour.

    -

    Raphael.getColor.reset()

    -

    Resets spectrum position for Raphael.getColor back to red. +

     Raphael.getColor.reset()

    +

    Resets spectrum position for Raphael.getColor back to red.

    -

    Raphael.getPointAtLength(path, length)

    -

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

     Raphael.getPointAtLength(path, length)

    +

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

    Parameters

    @@ -1127,8 +1759,8 @@ paper.mystuff.star();
  • y:numbery coordinate
  • alpha:numberangle of derivative
  • }
  • -

    Raphael.getRGB(colour)

    -

    Parses colour string as RGB object +

     Raphael.getRGB(colour)

    +

    Parses colour string as RGB object

    Parameters

    @@ -1136,6 +1768,17 @@ paper.mystuff.star();
    string
    colour string in one of formats:
    +
      +
    • Colour name (“red”, “green”, “cornflowerblue”, etc)
    • +
    • #••• — shortened HTML colour: (“#000”, “#fc0”, etc)
    • +
    • #•••••• — full length HTML colour: (“#000000”, “#bd2300”)
    • +
    • rgb(•••, •••, •••) — red, green and blue channels’ values: (“rgb(200, 100, 0)”)
    • +
    • rgb(•••%, •••%, •••%) — same as above, but in %: (“rgb(100%, 175%, 0%)”)
    • +
    • hsb(•••, •••, •••) — hue, saturation and brightness values: (“hsb(0.5, 0.25, 1)”)
    • +
    • hsb(•••%, •••%, •••%) — same as above, but in %
    • +
    • hsl(•••, •••, •••) — same as hsb
    • +
    • hsl(•••%, •••%, •••%) — same as hsb
    • +

    Returns: object RGB object in format:

    1. {
      1. rnumberred,
      2. gnumbergreen, @@ -1143,8 +1786,8 @@ paper.mystuff.star();
      3. hexstringcolor in HTML/CSS format: #••••••,
      4. errorbooleantrue if string can’t be parsed
    2. }
    -

    Raphael.getSubpath(path, from, to)

    -

    Return subpath of a given path from given length to given length. +

     Raphael.getSubpath(path, from, to)

    +

    Return subpath of a given path from given length to given length.

    Parameters

    @@ -1159,8 +1802,8 @@ paper.mystuff.star();
    position of the end of the segment

    Returns: string pathstring for the segment

    -

    Raphael.getTotalLength(path)

    -

    Returns length of the given path in pixels. +

     Raphael.getTotalLength(path)

    +

    Returns length of the given path in pixels.

    Parameters

    @@ -1169,8 +1812,8 @@ paper.mystuff.star();
    SVG path string.

    Returns: number length.

    -

    Raphael.hsb(h, s, b)

    -

    Converts HSB values to hex representation of the colour. +

     Raphael.hsb(h, s, b)

    +

    Converts HSB values to hex representation of the colour.

    Parameters

    @@ -1185,8 +1828,8 @@ paper.mystuff.star();
    value or brightness

    Returns: string hex representation of the colour.

    -

    Raphael.hsb2rgb(h, s, v)

    -

    Converts HSB values to RGB object. +

     Raphael.hsb2rgb(h, s, v)

    +

    Converts HSB values to RGB object.

    Parameters

    @@ -1206,8 +1849,8 @@ paper.mystuff.star();
  • bnumberblue,
  • hexstringcolor in HTML/CSS format: #••••••
  • }
  • -

    Raphael.hsl(h, s, l)

    -

    Converts HSL values to hex representation of the colour. +

     Raphael.hsl(h, s, l)

    +

    Converts HSL values to hex representation of the colour.

    Parameters

    @@ -1222,8 +1865,8 @@ paper.mystuff.star();
    luminosity

    Returns: string hex representation of the colour.

    -

    Raphael.hsl2rgb(h, s, l)

    -

    Converts HSL values to RGB object. +

     Raphael.hsl2rgb(h, s, l)

    +

    Converts HSL values to RGB object.

    Parameters

    @@ -1243,8 +1886,8 @@ paper.mystuff.star();
  • bnumberblue,
  • hexstringcolor in HTML/CSS format: #••••••
  • }
  • -

    Raphael.is(o, type)

    -

    Handfull replacement for typeof operator. +

     Raphael.is(o, type)

    +

    Handfull replacement for typeof operator.

    Parameters

    @@ -1256,31 +1899,69 @@ paper.mystuff.star();
    name of the type, i.e. “string”, “function”, “number”, etc.

    Returns: boolean is given value is of given type

    -

    Raphael.parsePathString(pathString)

    -

    Utility method +

     Raphael.matrix(a, b, c, d, e, f)

    +

    Utility method +Returns matrix based on given parameters. +

    +

    Parameters +

    +
    a
    +
    number
    +
     
    +
    b
    +
    number
    +
     
    +
    c
    +
    number
    +
     
    +
    d
    +
    number
    +
     
    +
    e
    +
    number
    +
     
    +
    f
    +
    number
    +
     
    +
    +

    Returns: object Matrix

    +

     Raphael.ninja()

    +

    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 global variable existance. +

    +

    Returns: object Raphael object

    +

    Usage +

    +
    (function (local_raphael) {
    +    var paper = local_raphael(10, 10, 320, 200);
    +    …
    +})(Raphael.ninja());
    +
    +

     Raphael.parsePathString(pathString)

    +

    Utility method Parses given path string into an array of arrays of path segments.

    Parameters

    pathString
    string array
    -
    path string or array of segments (in the last case it will be returned stright away)
    +
    path string or array of segments (in the last case it will be returned straight away)

    Returns: array array of segments.

    -

    Raphael.parseTransformString(TString)

    -

    Utility method +

     Raphael.parseTransformString(TString)

    +

    Utility method Parses given path string into an array of transformations.

    Parameters

    TString
    string array
    -
    transform string or array of transformations (in the last case it will be returned stright away)
    +
    transform string or array of transformations (in the last case it will be returned straight away)

    Returns: array array of transformations.

    -

    Raphael.path2curve(pathString)

    -

    Utility method -Converts path to path where all segments are cubic bezier curves. +

     Raphael.path2curve(pathString)

    +

    Utility method +Converts path to a new path where all segments are cubic bezier curves.

    Parameters

    @@ -1289,8 +1970,8 @@ Converts path to path where all segments are cubic bezier curves.
    path string or array of segments

    Returns: array array of segments.

    -

    Raphael.pathToRelative(pathString)

    -

    Utility method +

     Raphael.pathToRelative(pathString)

    +

    Utility method Converts path to relative form

    Parameters @@ -1300,8 +1981,8 @@ Converts path to relative form

    path string or array of segments

    Returns: array array of segments.

    -

    Raphael.rad(deg)

    -

    Transform angle to radians +

     Raphael.rad(deg)

    +

    Transform angle to radians

    Parameters

    @@ -1310,8 +1991,24 @@ Converts path to relative form
    angle in degrees

    Returns: number angle in radians.

    -

    Raphael.rgb(r, g, b)

    -

    Converts RGB values to hex representation of the colour. +

     Raphael.registerFont(font)

    +

    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. +

    +More about Cufón and how to convert your font form TTF, OTF, etc to JavaScript file. +

    Parameters +

    +
    font
    +
    object
    +
    the font to register
    +
    +

    Returns: object the font you passed in

    +

    Usage +

    +
    Cufon.registerFont(Raphael.registerFont({…}));
    +
    +

     Raphael.rgb(r, g, b)

    +

    Converts RGB values to hex representation of the colour.

    Parameters

    @@ -1326,8 +2023,8 @@ Converts path to relative form
    blue

    Returns: string hex representation of the colour.

    -

    Raphael.rgb2hsb(r, g, b)

    -

    Converts RGB values to HSB object. +

     Raphael.rgb2hsb(r, g, b)

    +

    Converts RGB values to HSB object.

    Parameters

    @@ -1346,8 +2043,8 @@ Converts path to relative form
  • snumbersaturation
  • bnumberbrightness
  • }
  • -

    Raphael.rgb2hsl(r, g, b)

    -

    Converts RGB values to HSL object. +

     Raphael.rgb2hsl(r, g, b)

    +

    Converts RGB values to HSL object.

    Parameters

    @@ -1366,8 +2063,8 @@ Converts path to relative form
  • snumbersaturation
  • lnumberluminosity
  • }
  • -

    Raphael.setWindow(newwin)

    -

    Used when you need to draw in <iframe>. Switched window to the iframe one. +

     Raphael.setWindow(newwin)

    +

    Used when you need to draw in <iframe>. Switched window to the iframe one.

    Parameters

    @@ -1375,8 +2072,8 @@ Converts path to relative form
    window
    new window object
    -

    Raphael.snapTo(values, value, [tolerance])

    -

    Snaps given value to given grid. +

     Raphael.snapTo(values, value, [tolerance])

    +

    Snaps given value to given grid.

    Parameters

    @@ -1392,18 +2089,49 @@ Converts path to relative form
    tolerance for snapping. Default is 10.

    Returns: number adjusted value.

    -

    Raphael.svg

    -
    boolean

    true if browser supports SVG. +

     Raphael.st

    +
    object

    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 Raphael.el.

    -

    Raphael.type

    -
    string

    Can be “SVG”, “VML” or empty, depending on browser support. +

    Usage

    -

    Raphael.vml

    -
    boolean

    true if browser supports VML. +

    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();
    +
    +

     Raphael.svg

    +
    boolean

    true if browser supports SVG. +

    +

     Raphael.type

    +
    string

    Can be “SVG”, “VML” or empty, depending on browser support. +

    +

     Raphael.vml

    +
    boolean

    true if browser supports VML.

    -

    Set

    -

    Set.forEach(callback, thisArg)

    -

    Executes given function for each element in the set. +

     Set

    +

     Set.clear()

    +

    Removeds all elements from the set +

    +

     Set.exclude(element)

    +

    Removes given element from the set +

    +

    Parameters +

    +
    element
    +
    object
    +
    element to remove
    +
    +

    Returns: boolean true if object was found & removed from the set

    +

     Set.forEach(callback, thisArg)

    +

    Executes given function for each element in the set.

    If function returns false it will stop loop running.

    @@ -1417,12 +2145,137 @@ Converts path to relative form
    context object for the callback

    Returns: object Set object

    -

    Set.pop()

    -

    Removes last element and returns it. +

     Set.pop()

    +

    Removes last element and returns it.

    Returns: object element

    -

    Set.push()

    -

    Adds each argument to the current set. +

     Set.push()

    +

    Adds each argument to the current set.

    Returns: object original element

    -
    \ No newline at end of file +

     Set.splice(index, count, [insertion…])

    +

    Removes given element from the set +

    +

    Parameters +

    +
    index
    +
    number
    +
    position of the deletion
    +
    count
    +
    number
    +
    number of element to remove
    +
    insertion…
    +
    optional
    +
    object
    +
    elements to insert
    +
    +

    Returns: object set elements that were deleted

    +

     eve(name, scope, varargs)

    +

    Fires event with given name, given scope and other parameters. +

    +

    Arguments +

    +
    name
    +
    string
    +
    name of the event, dot (.) or slash (/) separated
    +
    scope
    +
    object
    +
    context for the event handlers
    +
    varargs
    +
    ...
    +
    the rest of arguments will be sent to event handlers
    +
    +

    Returns: object array of returned values from the listeners

    +

     eve.listeners(name)

    +

    Internal method which gives you array of all event handlers that will be triggered by the given name. +

    +

    Arguments +

    +
    name
    +
    string
    +
    name of the event, dot (.) or slash (/) separated
    +
    +

    Returns: array array of event handlers

    +

     eve.nt([subname])

    +

    Could be used inside event handler to figure out actual name of the event. +

    +

    Arguments +

    +
    subname
    +
    optional
    +
    string
    +
    subname of the event
    +
    +

    Returns: string name of the event, if subname is not specified

    +

    or +

    +

    Returns: boolean true, if current event’s name contains subname

    +

     eve.on(name, f)

    +

    Binds given event handler with a given name. You can use wildcards “*” for the names: +

    +
    eve.on("*.under.*", f);
    +eve("mouse.under.floor"); // triggers f
    +
    +

    Use eve to trigger the listener. +

    +

    Arguments +

    +
    name
    +
    string
    +
    name of the event, dot (.) or slash (/) separated, with optional wildcards
    +
    f
    +
    function
    +
    event handler function
    +
    +

    Returns: function returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment.

    +

    Example: +

    +
    eve.on("mouse", eat)(2);
    +eve.on("mouse", scream);
    +eve.on("mouse", catch)(1);
    +
    +

    This will ensure that catch function will be called before eat. +If you want to put your handler before non-indexed handlers, specify a negative value. +Note: I assume most of the time you don’t need to worry about z-index, but it’s nice to have this feature “just in case”. +

    +

     eve.once(name, f)

    +

    Binds given event handler with a given name to only run once then unbind itself. +

    +
    eve.once("login", f);
    +eve("login"); // triggers f
    +eve("login"); // no listeners
    +
    +

    Use eve to trigger the listener. +

    +

    Arguments +

    +
    name
    +
    string
    +
    name of the event, dot (.) or slash (/) separated, with optional wildcards
    +
    f
    +
    function
    +
    event handler function
    +
    +

    Returns: function same return function as eve.on

    +

     eve.stop()

    +

    Is used inside an event handler to stop the event, preventing any subsequent listeners from firing. +

    +

     eve.unbind(name, f)

    +

    Removes given function from the list of event listeners assigned to given name. +

    +

    Arguments +

    +
    name
    +
    string
    +
    name of the event, dot (.) or slash (/) separated, with optional wildcards
    +
    f
    +
    function
    +
    event handler function
    +
    +

     eve.version

    +
    string

    Current version of the library. +

    +
    + + + \ No newline at end of file