diff --git a/doc/reference.html b/doc/reference.html index bee3dcd..048ef24 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -1,447 +1,4710 @@ - - - - Snap.svg API Reference - - - - - - - -
-
-
-
- -
- -
-
-
-
-
-
-

Snap.svg

-

API Reference

-
-
+ + + + + Snap.svg API Reference + + + + + + + + + + + + + -

Element.add()

-

See Element.append + + + +

+
+
+
+ +
+ +
+
+
+
+ +
+
+

Snap(…)

+
+
+
+
+ + + + +

Creates a drawing surface or wraps existing SVG element.

-

Element.after(el)

-

Inserts given element after the current one + + + + + + + + + + +

+

Parameters

+
    +
  1. width + number string + width of surface
  2. +
  3. height + number string + height of surface
  4. + +
+
+ + + + + + + + +

or

-

Parameters

  1. el -Element -element to insert
  2. -
-

Returns: Element the parent element

-

Element.animate(attrs, duration, [easing], [callback])

-

Animates the given attributes of the element + + + + + + + + + + +

+

Parameters

+
    +
  1. DOM + SVGElement + element to be wrapped into Snap structure
  2. + +
+
+ + + + + + + + +

or

-

Parameters

  1. attrs -object -key-value pairs of destination attributes
  2. -
  3. duration -number -duration of the animation in milliseconds
  4. -
  5. easing -optional -function -easing function from mina or custom
  6. -
  7. callback -optional -function -callback function that executes when the animation ends
  8. -
-

Returns: Element the current element

-

Element.append(el)

-

Appends the given element to current one + + + + + + + + + + +

+

Parameters

+
    +
  1. query + string + CSS query selector
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + Element +

+ + + + +
+
+
+ +
+
+

Snap.format(token, json)

+
+
+
+
+ + + + +

Replaces construction of type {<name>} to the corresponding argument

-

Parameters

  1. el -Element Set -element to append
  2. -
-

Returns: Element the parent element

-

Element.asPX(attr, [value])

-

Returns given attribute of the element as a px value (not %, em, etc.) + + + + + + + + + + +

+

Parameters

+
    +
  1. token + string + string to format
  2. +
  3. json + object + object which properties are used as a replacement
  4. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + string + + formatted string +

+ + + + + + + + +

Usage

+ + + + + + + + + + + +
// this draws a rectangular shape equivalent to "M10,20h40v50h-40z"
+paper.path(Snap.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
+    }
+}));
+ + + + + +
+
+
+ +
+
+

Snap.rad(deg)

+
+
+
+
+ + + + +

Transform angle to radians

-

Parameters

  1. attr -string -attribute name
  2. -
  3. value -optional -string -attribute value
  4. -
-

Returns: Element result of query selection

-

Element.attr(…)

-

Gets or sets given attributes of the element + + + + + + + + + + +

+

Parameters

+
    +
  1. deg + number + angle in degrees
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + number + + angle in radians +

+ + + + +
+
+
+ +
+
+

Snap.deg(rad)

+
+
+
+
+ + + + +

Transform angle to degrees

-

Parameters

  1. params -object -contains key-value pairs of attributes you want to set
  2. -
-

or + + + + + + + + + + +

+

Parameters

+
    +
  1. rad + number + angle in radians
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + number + + angle in degrees +

+ + + + +
+
+
+ +
+
+

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

+
+
+
+
+ + + + +

Returns an angle between two or three points

-

Parameters

  1. param -string -name of the attribute
  2. -
-

Returns: Element the current element

-

or + + + + + + + + + + + + +

Parameters

+ + + + + + + + +
+

Parameters

+
    +
  1. x1 + number + x coord of first point
  2. +
  3. y1 + number + y coord of first point
  4. +
  5. x2 + number + x coord of second point
  6. +
  7. y2 + number + y coord of second point
  8. +
  9. x3 + number + x coord of third point
  10. +
  11. y3 + number + y coord of third point
  12. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + number + + angle in degrees +

+ + + + +
+
+
+ +
+
+

Snap.is(o, type)

+
+
+
+
+ + + + +

Handy replacement for the typeof operator

-

Returns: string value of attribute

-

Usage

el.attr({
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+

Parameters

+
    +
  1. o + + any object or primitive
  2. +
  3. type + string + name of the type, e.g., string, function, number, etc.
  4. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + boolean + + true if given value is of given type +

+ + + + +
+
+
+ +
+
+

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

+
+
+
+
+ + + + +

Snaps given value to given grid +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. values + array number + given array of values or step of the grid
  2. +
  3. value + number + value to adjust
  4. +
  5. tolerance + number + maximum distance to the target value that would trigger the snap. Default is 10.
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + number + + adjusted value +

+ + + + +
+
+
+ +
+
+

Matrix.add(…)

+
+
+
+
+ + + + +

Adds the given matrix to existing one +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. a + number +
  2. +
  3. b + number +
  4. +
  5. c + number +
  6. +
  7. d + number +
  8. +
  9. e + number +
  10. +
  11. f + number +
  12. + +
+
+ + + + + + + + +

or +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. matrix + object + Matrix
  2. + +
+
+ + + + + + + +
+
+
+ +
+
+

Matrix.invert()

+
+
+
+
+ + + + +

Returns an inverted version of the matrix +

+ + + + + + + + + + + + + + +

+ Returns: + + object + + Matrix +

+ + + + +
+
+
+ +
+
+

Matrix.clone()

+
+
+
+
+ + + + +

Returns a copy of the matrix +

+ + + + + + + + + + + + + + +

+ Returns: + + object + + Matrix +

+ + + + +
+
+
+ +
+
+

Matrix.translate(x, y)

+
+
+
+
+ + + + +

Translate the matrix +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. x + number + horizontal offset distance
  2. +
  3. y + number + vertical offset distance
  4. + +
+
+ + + + + + + +
+
+
+ +
+
+

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

+
+
+
+
+ + + + +

Scales the matrix +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. x + number + amount to be scaled, with 1 resulting in no change
  2. +
  3. y + number + amount to scale along the vertical axis. (Otherwise x applies to both axes.)
  4. +
  5. cx + number + horizontal origin point from which to scale
  6. +
  7. cy + number + vertical origin point from which to scale
  8. + +
+
+ + + + + + + + +

Default cx, cy is the middle point of the element. +

+ + + + + + + + +
+
+
+ +
+
+

Matrix.rotate(a, x, y)

+
+
+
+
+ + + + +

Rotates the matrix +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. a + number + angle of rotation, in degrees
  2. +
  3. x + number + horizontal origin point from which to rotate
  4. +
  5. y + number + vertical origin point from which to rotate
  6. + +
+
+ + + + + + + +
+
+
+ +
+
+

Matrix.x(x, y)

+
+
+
+
+ + + + +

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

+ + + + + + + + + + +
+

Parameters

+
    +
  1. x + number +
  2. +
  3. y + number +
  4. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + number + + x +

+ + + + +
+
+
+ +
+
+

Matrix.y(x, y)

+
+
+
+
+ + + + +

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

+ + + + + + + + + + +
+

Parameters

+
    +
  1. x + number +
  2. +
  3. y + number +
  4. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + number + + y +

+ + + + +
+
+
+ +
+
+

Matrix.split()

+
+
+
+
+ + + + +

Splits matrix into primitive transformations +

+ + + + + + + + + + + + + + +

+ Returns: + + object + + in format: +

+ + + + + + + + + + + +
    + + +
  1. + dx + number + translation by x +
  2. + + + +
  3. + dy + number + translation by y +
  4. + + + +
  5. + scalex + number + scale by x +
  6. + + + +
  7. + scaley + number + scale by y +
  8. + + + +
  9. + shear + number + shear +
  10. + + + +
  11. + rotate + number + rotation in deg +
  12. + + + +
  13. + isSimple + boolean + could it be represented via simple transformations +
  14. + + +
+ + +
+
+
+ +
+
+

Matrix.toTransformString()

+
+
+
+
+ + + + +

Returns transform string that represents given matrix +

+ + + + + + + + + + + + + + +

+ Returns: + + string + + transform string +

+ + + + +
+
+
+ +
+
+

Snap.Matrix(…)

+
+
+
+
+ + + + +

Utility method +Returns a matrix based on the given parameters +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. a + number +
  2. +
  3. b + number +
  4. +
  5. c + number +
  6. +
  7. d + number +
  8. +
  9. e + number +
  10. +
  11. f + number +
  12. + +
+
+ + + + + + + + +

or +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. svgMatrix + SVGMatrix +
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + Matrix +

+ + + + +
+
+
+ +
+
+

Snap.getRGB(color)

+
+
+
+
+ + + + +

Parses color string as RGB object +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. color + string + color string in one of the following formats:
  2. + +
+
+ + + + + + + + + + +
    + + + + + + + + + + + +
  • Color name (red, green, cornflowerblue, etc)
  • + + + + + + + + + + + +
  • #••• — shortened HTML color: (#000, #fc0, etc.)
  • + + + + + + + + + + + +
  • #•••••• — full length HTML color: (#000000, #bd2300)
  • + + + + + + + + + + + +
  • rgb(•••, •••, •••) — red, green and blue channels values: (rgb(200, 100, 0))
  • + + + + + + + + + + + +
  • rgba(•••, •••, •••, •••) — also with opacity
  • + + + + + + + + + + + +
  • rgb(•••%, •••%, •••%) — same as above, but in %: (rgb(100%, 175%, 0%))
  • + + + + + + + + + + + +
  • rgba(•••%, •••%, •••%, •••%) — also with opacity
  • + + + + + + + + + + + +
  • hsb(•••, •••, •••) — hue, saturation and brightness values: (hsb(0.5, 0.25, 1))
  • + + + + + + + + + + + +
  • hsba(•••, •••, •••, •••) — also with opacity
  • + + + + + + + + + + + +
  • hsb(•••%, •••%, •••%) — same as above, but in %
  • + + + + + + + + + + + +
  • hsba(•••%, •••%, •••%, •••%) — also with opacity
  • + + + + + + + + + + + +
  • hsl(•••, •••, •••) — hue, saturation and luminosity values: (hsb(0.5, 0.25, 0.5))
  • + + + + + + + + + + + +
  • hsla(•••, •••, •••, •••) — also with opacity
  • + + + + + + + + + + + +
  • hsl(•••%, •••%, •••%) — same as above, but in %
  • + + + + + + + + + + + +
  • hsla(•••%, •••%, •••%, •••%) — also with opacity
  • + + + + + + + + + + + +
+ + + + + + + + + +

Note that % can be used any time: rgb(20%, 255, 50%). +

+ + + + + + + + + + + + + + +

+ Returns: + + object + + RGB object in the following format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + r + number + red, +
    2. + + + +
    3. + g + number + green, +
    4. + + + +
    5. + b + number + blue, +
    6. + + + +
    7. + hex + string + color in HTML/CSS format: #••••••, +
    8. + + + +
    9. + error + boolean + true if string can't be parsed +
    10. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.hsb(h, s, b)

+
+
+
+
+ + + + +

Converts HSB values to a hex representation of the color +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. h + number + hue
  2. +
  3. s + number + saturation
  4. +
  5. b + number + value or brightness
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + string + + hex representation of the color +

+ + + + +
+
+
+ +
+
+

Snap.hsl(h, s, l)

+
+
+
+
+ + + + +

Converts HSL values to a hex representation of the color +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. h + number + hue
  2. +
  3. s + number + saturation
  4. +
  5. l + number + luminosity
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + string + + hex representation of the color +

+ + + + +
+
+
+ +
+
+

Snap.rgb(r, g, b)

+
+
+
+
+ + + + +

Converts RGB values to a hex representation of the color +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. r + number + red
  2. +
  3. g + number + green
  4. +
  5. b + number + blue
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + string + + hex representation of the color +

+ + + + +
+
+
+ +
+
+

Snap.color(clr)

+
+
+
+
+ + + + +

Parses the color string and returns an object featuring the color's component values +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. clr + string + color string in one of the supported formats (see Snap.getRGB)
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + Combined RGB/HSB object in the following format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + r + number + red, +
    2. + + + +
    3. + g + number + green, +
    4. + + + +
    5. + b + number + blue, +
    6. + + + +
    7. + hex + string + color in HTML/CSS format: #••••••, +
    8. + + + +
    9. + error + boolean + true if string can't be parsed, +
    10. + + + +
    11. + h + number + hue, +
    12. + + + +
    13. + s + number + saturation, +
    14. + + + +
    15. + v + number + value (brightness), +
    16. + + + +
    17. + l + number + lightness +
    18. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.hsb2rgb(h, s, v)

+
+
+
+
+ + + + +

Converts HSB values to an RGB object +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. h + number + hue
  2. +
  3. s + number + saturation
  4. +
  5. v + number + value or brightness
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + RGB object in the following format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + r + number + red, +
    2. + + + +
    3. + g + number + green, +
    4. + + + +
    5. + b + number + blue, +
    6. + + + +
    7. + hex + string + color in HTML/CSS format: #•••••• +
    8. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.hsl2rgb(h, s, l)

+
+
+
+
+ + + + +

Converts HSL values to an RGB object +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. h + number + hue
  2. +
  3. s + number + saturation
  4. +
  5. l + number + luminosity
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + RGB object in the following format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + r + number + red, +
    2. + + + +
    3. + g + number + green, +
    4. + + + +
    5. + b + number + blue, +
    6. + + + +
    7. + hex + string + color in HTML/CSS format: #•••••• +
    8. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.rgb2hsb(r, g, b)

+
+
+
+
+ + + + +

Converts RGB values to an HSB object +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. r + number + red
  2. +
  3. g + number + green
  4. +
  5. b + number + blue
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + HSB object in the following format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + h + number + hue, +
    2. + + + +
    3. + s + number + saturation, +
    4. + + + +
    5. + b + number + brightness +
    6. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.rgb2hsl(r, g, b)

+
+
+
+
+ + + + +

Converts RGB values to an HSL object +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. r + number + red
  2. +
  3. g + number + green
  4. +
  5. b + number + blue
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + HSL object in the following format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + h + number + hue, +
    2. + + + +
    3. + s + number + saturation, +
    4. + + + +
    5. + l + number + luminosity +
    6. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.parsePathString(pathString)

+
+
+
+
+ + + + +

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

+ + + + + + + + + + +
+

Parameters

+
    +
  1. pathString + string array + path string or array of segments (in the last case it is returned straight away)
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + array + + array of segments +

+ + + + +
+
+
+ +
+
+

Snap.parseTransformString(TString)

+
+
+
+
+ + + + +

Utility method +Parses given transform string into an array of transformations +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. TString + string array + transform string or array of transformations (in the last case it is returned straight away)
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + array + + array of transformations +

+ + + + +
+
+
+ +
+
+

Snap.select(query)

+
+
+
+
+ + + + +

Wraps a DOM element specified by CSS selector as Element +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. query + string + CSS selector of the element
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + +
+
+
+ +
+
+

Snap.selectAll(query)

+
+
+
+
+ + + + +

Wraps DOM elements specified by CSS selector as set or array of Element +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. query + string + CSS selector of the element
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + +
+
+
+ +
+
+

Element.attr(…)

+
+
+
+
+ + + + +

Gets or sets given attributes of the element +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. params + object + contains key-value pairs of attributes you want to set
  2. + +
+
+ + + + + + + + +

or +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. param + string + name of the attribute
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + + +

or +

+ + + + + + + + + + + + + + +

+ Returns: + + string + + value of attribute +

+ + + + + + + + +

Usage

+ + + + + + + + + + + +
el.attr({
     fill: "#fc0",
     stroke: "#000",
     strokeWidth: 2, // CamelCase...
     "fill-opacity": 0.5 // or dash-separated names
 });
-console.log(el.attr("fill")); // #fc0
-
-

Element.before(el)

-

Inserts given element before the current one +console.log(el.attr("fill")); // #fc0

+ + + + + +
+
+
+ +
+
+

Element.getBBox()

+
+
+
+
+ + + + +

Returns the bounding box descriptor for the given element

-

Parameters

  1. el -Element -element to insert
  2. -
-

Returns: Element the parent element

-

Element.click(handler)

-

Adds a click event handler to the element + + + + + + + + + + + + + + +

+ Returns: + + object + + bounding box descriptor: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + cx: + number + x of the center, +
    2. + + + +
    3. + cy: + number + x of the center, +
    4. + + + +
    5. + h: + number + height, +
    6. + + + +
    7. + height: + number + height, +
    8. + + + +
    9. + path: + string + path command for the box, +
    10. + + + +
    11. + r0: + number + radius of a circle that fully encloses the box, +
    12. + + + +
    13. + r1: + number + radius of the smallest circle that can be enclosed, +
    14. + + + +
    15. + r2: + number + radius of the largest circle that can be enclosed, +
    16. + + + +
    17. + vb: + string + box as a viewbox command, +
    18. + + + +
    19. + w: + number + width, +
    20. + + + +
    21. + width: + number + width, +
    22. + + + +
    23. + x2: + number + x of the right side, +
    24. + + + +
    25. + x: + number + x of the left side, +
    26. + + + +
    27. + y2: + number + y of the bottom edge, +
    28. + + + +
    29. + y: + number + y of the top edge +
    30. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Element.transform(tstr)

+
+
+
+
+ + + + +

Gets or sets transformation of the element

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.clone()

-

Creates a clone of the element and inserts it after the element + + + + + + + + + + +

+

Parameters

+
    +
  1. tstr + string + transform string in Snap or SVG format
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + + +

or

-

Returns: Element the clone

-

Element.data(key, [value])

-

Adds or retrieves given value associated with given key. (Don’t confuse -with data- attributes) + + + + + + + + + + + + + + +

+ Returns: + + object + + transformation descriptor: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + string + string + transform string, +
    2. + + + +
    3. + globalMatrix + Matrix + matrix of all transformations applied to element or its parents, +
    4. + + + +
    5. + localMatrix + Matrix + matrix of transformations applied only to the element, +
    6. + + + +
    7. + diffMatrix + Matrix + matrix of difference between global and local transformations, +
    8. + + + +
    9. + global + string + global transformation as string, +
    10. + + + +
    11. + local + string + local transformation as string, +
    12. + + + +
    13. + toString + function + returns string property +
    14. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Element.parent()

+
+
+
+
+ + + + +

Returns the element's parent

-

See also Element.removeData + + + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.append(el)

+
+
+
+
+ + + + +

Appends the given element to current one

-

Parameters

  1. key -string -key to store data
  2. -
  3. value -optional -any -value to store
  4. -
-

Returns: object Element

-

or, if value is not specified: + + + + + + + + + + +

+

Parameters

+
    +
  1. el + Element Set + element to append
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.add()

+
+
+
+
+ + + + +

See Element.append

-

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 a double click event handler to the element + + + + + + + + +

+
+
+ +
+
+

Element.prepend(el)

+
+
+
+
+ + + + +

Prepends the given element to the current one

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

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

-

Adds event handlers for an element's drag gesture + + + + + + + + + + +

+

Parameters

+
    +
  1. el + Element + element to prepend
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.before(el)

+
+
+
+
+ + + + +

Inserts given element before the current one

-

Parameters

  1. onmove -function -handler for moving
  2. -
  3. onstart -function -handler for drag start
  4. -
  5. onend -function -handler for drag end
  6. -
  7. mcontext -optional -object -context for moving handler
  8. -
  9. scontext -optional -object -context for drag start handler
  10. -
  11. econtext -optional -object -context for drag end handler
  12. -
-

Additionaly following drag events are triggered: drag.start.<id> on start, -drag.end.<id> on end and drag.move.<id> on every move. When element is dragged over another element -drag.over.<id> fires as well. + + + + + + + + + + +

+

Parameters

+
    +
  1. el + Element + element to insert
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.after(el)

+
+
+
+
+ + + + +

Inserts given element after the current one

-

Start event and start handler are called in specified context or in context of the element with following parameters: + + + + + + + + + + +

+

Parameters

+
    +
  1. el + Element + element to insert
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.insertBefore(el)

+
+
+
+
+ + + + +

Inserts the element after the given one

-
  1. xnumberx position of the mouse -
  2. ynumbery position of the mouse -
  3. eventobjectDOM event object -
-

Move event and move handler are called in specified context or in context of the element with following parameters: + + + + + + + + + + +

+

Parameters

+
    +
  1. el + Element + element next to whom insert to
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.insertAfter(el)

+
+
+
+
+ + + + +

Inserts the element after the given one

-
  1. dxnumbershift by x from the start point -
  2. dynumbershift by y from the start point -
  3. xnumberx position of the mouse -
  4. ynumbery position of the mouse -
  5. eventobjectDOM event object -
-

End event and end handler are called in specified context or in context of the element with following parameters: + + + + + + + + + + +

+

Parameters

+
    +
  1. el + Element + element next to whom insert to
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the parent element +

+ + + + +
+
+
+ +
+
+

Element.remove()

+
+
+
+
+ + + + +

Removes element from the DOM

-
  1. eventobjectDOM event object -
-

Returns: object Element

-

Adds event handlers for an element's drag gesture + + + + + + + + + + + + + + +

+ Returns: + + Element + + the detached element +

+ + + + +
+
+
+ +
+
+

Element.select(query)

+
+
+
+
+ + + + +

Gathers the nested Element matching the given set of CSS selectors

-

Parameters

  1. onmove -function -handler for moving
  2. -
  3. onstart -function -handler for drag start
  4. -
  5. onend -function -handler for drag end
  6. -
  7. mcontext -optional -object -context for moving handler
  8. -
  9. scontext -optional -object -context for drag start handler
  10. -
  11. econtext -optional -object -context for drag end handler
  12. -
-

Additionaly following drag events are triggered: drag.start.<id> on start, -drag.end.<id> on end and drag.move.<id> on every move. When element is dragged over another element -drag.over.<id> fires as well. + + + + + + + + + + +

+

Parameters

+
    +
  1. query + string + CSS selector
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + result of query selection +

+ + + + +
+
+
+ +
+
+

Element.selectAll(query)

+
+
+
+
+ + + + +

Gathers nested Element objects matching the given set of CSS selectors

-

Start event and start handler are called in specified context or in context of the element with following parameters: + + + + + + + + + + +

+

Parameters

+
    +
  1. query + string + CSS selector
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Set + + array + + result of query selection +

+ + + + +
+
+
+ +
+
+

Element.asPX(attr, [value])

+
+
+
+
+ + + + +

Returns given attribute of the element as a px value (not %, em, etc.)

-
  1. xnumberx position of the mouse -
  2. ynumbery position of the mouse -
  3. eventobjectDOM event object -
-

Move event and move handler are called in specified context or in context of the element with following parameters: + + + + + + + + + + +

+

Parameters

+
    +
  1. attr + string + attribute name
  2. +
  3. value + string + attribute value
  4. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + result of query selection +

+ + + + +
+
+
+ +
+
+

Element.use()

+
+
+
+
+ + + + +

Creates a <use> element linked to the current element

-
  1. dxnumbershift by x from the start point -
  2. dynumbershift by y from the start point -
  3. xnumberx position of the mouse -
  4. ynumbery position of the mouse -
  5. eventobjectDOM event object -
-

End event and end handler are called in specified context or in context of the element with following parameters: + + + + + + + + + + + + + + +

+ Returns: + + Element + + the <use> element +

+ + + + +
+
+
+ +
+
+

Element.clone()

+
+
+
+
+ + + + +

Creates a clone of the element and inserts it after the element

-
  1. eventobjectDOM event object -
-

Returns: object Element

-

Element.getBBox()

-

Returns the bounding box descriptor for the given element + + + + + + + + + + + + + + +

+ Returns: + + Element + + the clone +

+ + + + +
+
+
+ +
+
+

Element.toDefs()

+
+
+
+
+ + + + +

Moves element to the shared <defs> area

-

Returns: object bounding box descriptor:

-
  1. {
    1. cx:numberx of the center, -
    2. cy:numberx of the center, -
    3. h:numberheight, -
    4. height:numberheight, -
    5. path:stringpath command for the box, -
    6. r0:numberradius of a circle that fully encloses the box, -
    7. r1:numberradius of the smallest circle that can be enclosed, -
    8. r2:numberradius of the largest circle that can be enclosed, -
    9. vb:stringbox as a viewbox command, -
    10. w:numberwidth, -
    11. width:numberwidth, -
    12. x2:numberx of the right side, -
    13. x:numberx of the left side, -
    14. y2:numbery of the bottom edge, -
    15. y:numbery of the top edge -
  2. }
-

Element.getPointAtLength(length)

-

Returns coordinates of the point located at the given length on the given path (only works for path elements) -

-

Parameters

  1. length -number -length, in pixels, from the start of the path, excluding non-rendering jumps
  2. -
-

Returns: object representation of the point:

-
  1. {
    1. x:numberx coordinate, -
    2. y:numbery coordinate, -
    3. alpha:numberangle of derivative -
  2. }
-

Element.getSubpath(from, to)

-

Returns subpath of a given element from given start and end lengths (only works for path elements) -

-

Parameters

  1. from -number -length, in pixels, from the start of the path to the start of the segment
  2. -
  3. to -number -length, in pixels, from the start of the path to the end of the segment
  4. -
-

Returns: string path string definition for the segment

-

Element.getTotalLength()

-

Returns the length of the path in pixels (only works for path elements) -

-

Returns: number length

-

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

-

Adds hover event handlers to the element -

-

Parameters

  1. f_in -function -handler for hover in
  2. -
  3. f_out -function -handler for hover out
  4. -
  5. icontext -optional -object -context for hover in handler
  6. -
  7. ocontext -optional -object -context for hover out handler
  8. -
-

Returns: object Element

-

Element.inAnim()

-

Returns a set of animations that may be able to manipulate the current element -

-

Returns: object in format:

-
  1. {
    1. animobjectanimation object, -
    2. curStatusnumber0..1 — status of the animation: 0 — just started, 1 — just finished, -
    3. statusfunctiongets or sets the status of the animation, -
    4. stopfunctionstops the animation -
  2. }
-

Element.innerSVG()

-

Returns SVG code for the element's contents, equivalent to HTML's innerHTML -

-

Returns: string SVG code for the element

-

Element.insertAfter(el)

-

Inserts the element after the given one -

-

Parameters

  1. el -Element -element next to whom insert to
  2. -
-

Returns: Element the parent element

-

Element.insertBefore(el)

-

Inserts the element after the given one -

-

Parameters

  1. el -Element -element next to whom insert to
  2. -
-

Returns: Element the parent element

-

Element.marker(x, y, width, height, refX, refY)

-

Creates a <marker> element from the current element -To create a marker you have to specify the bounding rect and reference point: -

-

Parameters

  1. x -number - 
  2. -
  3. y -number - 
  4. -
  5. width -number - 
  6. -
  7. height -number - 
  8. -
  9. refX -number - 
  10. -
  11. refY -number - 
  12. -
-

Returns: Element the <marker> element

-

You can specify the marker later as an argument for marker-start, marker-end, marker-mid, and marker attributes. The marker attribute places the marker at every point along the path, and marker-mid places them at every point except the start and end. -

-

Element.mousedown(handler)

-

Adds a mousedown event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.mousemove(handler)

-

Adds a mousemove event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.mouseout(handler)

-

Adds a mouseout event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.mouseover(handler)

-

Adds a mouseover event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.mouseup(handler)

-

Adds a mouseup event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.parent()

-

Returns the element's parent -

-

Returns: Element the parent element

-

Element.pattern(x, y, width, height)

-

Creates a <pattern> element from the current element + + + + + + + + + + + + + + +

+ Returns: + + Element + + the clone +

+ + + + +
+
+
+ +
+
+

Element.pattern(x, y, width, height)

+
+
+
+
+ + + + +

Creates a <pattern> element from the current element To create a pattern you have to specify the pattern rect:

-

Parameters

  1. x -string number - 
  2. -
  3. y -string number - 
  4. -
  5. width -string number - 
  6. -
  7. height -string number - 
  8. -
-

Returns: Element the <pattern> element

-

You can use pattern later on as an argument for fill attribute: + + + + + + + + + + +

+

Parameters

+
    +
  1. x + string number +
  2. +
  3. y + string number +
  4. +
  5. width + string number +
  6. +
  7. height + string number +
  8. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the <pattern> element +

+ + + + + +

You can use pattern later on as an argument for fill attribute:

-
var p = paper.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
var p = paper.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({
         fill: "none",
         stroke: "#bada55",
         strokeWidth: 5
@@ -449,444 +4712,2237 @@ To create a pattern you have to specify the pattern rect:
     c = paper.circle(200, 200, 100);
 c.attr({
     fill: p
-});
-
-

Element.prepend(el)

-

Prepends the given element to the current one +});

+ + + + + +
+ + + +
+
+

Element.marker(x, y, width, height, refX, refY)

+
+
+
+
+ + + + +

Creates a <marker> element from the current element +To create a marker you have to specify the bounding rect and reference point:

-

Parameters

  1. el -Element -element to prepend
  2. -
-

Returns: Element the parent element

-

Element.remove()

-

Removes element from the DOM + + + + + + + + + + +

+

Parameters

+
    +
  1. x + number +
  2. +
  3. y + number +
  4. +
  5. width + number +
  6. +
  7. height + number +
  8. +
  9. refX + number +
  10. +
  11. refY + number +
  12. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the <marker> element +

+ + + + + +

You can specify the marker later as an argument for marker-start, marker-end, marker-mid, and marker attributes. The marker attribute places the marker at every point along the path, and marker-mid places them at every point except the start and end.

-

Returns: Element the detached element

-

Element.removeData([key])

-

Removes value associated with an element by given key. + + + + + + + + +

+
+
+ +
+
+

Snap.animation(attr, duration, [easing], [callback])

+
+
+
+
+ + + + +

Creates an animation object +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. attr + object + attributes of final destination
  2. +
  3. duration + number + duration of the animation, in milliseconds
  4. +
  5. easing + function + one of easing functions of mina or custom one
  6. +
  7. callback + function + callback function that fires when animation ends
  8. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + animation object +

+ + + + +
+
+
+ +
+
+

Element.inAnim()

+
+
+
+
+ + + + +

Returns a set of animations that may be able to manipulate the current element +

+ + + + + + + + + + + + + + +

+ Returns: + + object + + in format: +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + anim + object + animation object, +
    2. + + + +
    3. + curStatus + number + 0..1 — status of the animation: 0 — just started, 1 — just finished, +
    4. + + + +
    5. + status + function + gets or sets the status of the animation, +
    6. + + + +
    7. + stop + function + stops the animation +
    8. + + + +
  2. }
  3. + + +
+ + +
+
+
+ +
+
+

Snap.animate(from, to, setter, duration, [easing], [callback])

+
+
+
+
+ + + + +

Runs generic animation of one number into another with a caring function +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. from + number array + number or array of numbers
  2. +
  3. to + number array + number or array of numbers
  4. +
  5. setter + function + caring function that accepts one number argument
  6. +
  7. duration + number + duration, in milliseconds
  8. +
  9. easing + function + easing function from mina or custom
  10. +
  11. callback + function + callback function to execute when animation ends
  12. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + animation object in mina format +

+ + + + + + + + + + + +
    + + +
  1. {
      + + + +
    1. + id + string + animation id, consider it read-only, +
    2. + + + +
    3. + duration + function + gets or sets the duration of the animation, +
    4. + + + +
    5. + easing + function + easing, +
    6. + + + +
    7. + speed + function + gets or sets the speed of the animation, +
    8. + + + +
    9. + status + function + gets or sets the status of the animation, +
    10. + + + +
    11. + stop + function + stops the animation +
    12. + + + +
  2. }
  3. + + +
+ + + + + + + +
var rect = Snap().rect(0, 0, 10, 10);
+Snap.animate(0, 10, function (val) {
+    rect.attr({
+        x: val
+    });
+}, 1000);
+// in given context is equivalent to
+rect.animate({x: 10}, 1000);
+ + + + + +
+
+
+ +
+
+

Element.stop()

+
+
+
+
+ + + + +

Stops all the animations for the current element +

+ + + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + +
+
+
+ +
+
+

Element.animate(attrs, duration, [easing], [callback])

+
+
+
+
+ + + + +

Animates the given attributes of the element +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. attrs + object + key-value pairs of destination attributes
  2. +
  3. duration + number + duration of the animation in milliseconds
  4. +
  5. easing + function + easing function from mina or custom
  6. +
  7. callback + function + callback function that executes when the animation ends
  8. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + +
+
+
+ +
+
+

Element.data(key, [value])

+
+
+
+
+ + + + +

Adds or retrieves given value associated with given key. (Don’t confuse +with data- attributes) +

See also Element.removeData +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. key + string + key to store data
  2. +
  3. value + any + value to store
  4. + +
+
+ + + + + + + + + + + + + +

+ 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.removeData([key])

+
+
+
+
+ + + + +

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

-

Parameters

  1. key -optional -string -key
  2. -
-

Returns: object Element

-

Element.select(query)

-

Gathers the nested Element matching the given set of CSS selectors + + + + + + + + + + +

+

Parameters

+
    +
  1. key + string + key
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + Element +

+ + + + +
+
+
+ +
+
+

undefined

+
+
+
+
+ + + + +

Returns SVG code for the element, equivalent to HTML's outerHTML

-

Parameters

  1. query -string -CSS selector
  2. -
-

Returns: Element result of query selection

-

Element.selectAll(query)

-

Gathers nested Element objects matching the given set of CSS selectors + + + + + + + + + + + + + + +

+ Returns: + + string + + SVG code for the element +

+ + + + +
+
+
+ +
+
+

Element.innerSVG()

+
+
+
+
+ + + + +

Returns SVG code for the element's contents, equivalent to HTML's innerHTML

-

Parameters

  1. query -string -CSS selector
  2. -
-

Returns: Set array result of query selection

-

Element.stop()

-

Stops all the animations for the current element + + + + + + + + + + + + + + +

+ Returns: + + string + + SVG code for the element +

+ + + + +
+
+
+ +
+
+

Snap.parse(svg)

+
+
+
+
+ + + + +

Parses SVG fragment and converts it into a Fragment

-

Returns: Element the current element

-

Element.toDefs()

-

Moves element to the shared <defs> area + + + + + + + + + + +

+

Parameters

+
    +
  1. svg + string + SVG string
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Fragment + + the Fragment +

+ + + + +
+
+
+ +

Element.toString()

-

Returns SVG code for the element, equivalent to HTML's outerHTML + + + + + + + + +

+
+
+ +
+
+

Fragment.selectAll()

+
+
+
+
+ + + + +

See Element.selectAll

-

Returns: string SVG code for the element

-

Returns SVG code for the Paper + + + + + + + + +

+
+
+ +
+
+

Snap.fragment(varargs)

+
+
+
+
+ + + + +

Creates a DOM fragment from a given list of elements or strings

-

Returns: string SVG code for the Paper

-

Element.touchcancel(handler)

-

Adds a touchcancel event handler to the element + + + + + + + + + + +

+

Parameters

+
    +
  1. varargs + + SVG string
  2. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Fragment + + the Fragment +

+ + + + +
+
+
+ +
+
+

Paper.el(name, attr)

+
+
+
+
+ + + + +

Creates an element on paper with a given name and no attributes

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.touchend(handler)

-

Adds a touchend event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.touchmove(handler)

-

Adds a touchmove event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.touchstart(handler)

-

Adds a touchstart event handler to the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.transform(tstr)

-

Gets or sets transformation of the element -

-

Parameters

  1. tstr -string -transform string in Snap or SVG format
  2. -
-

Returns: Element the current element

-

or -

-

Returns: object transformation descriptor:

-
  1. {
    1. stringstringtransform string, -
    2. globalMatrixMatrixmatrix of all transformations applied to element or its parents, -
    3. localMatrixMatrixmatrix of transformations applied only to the element, -
    4. diffMatrixMatrixmatrix of difference between global and local transformations, -
    5. globalstringglobal transformation as string, -
    6. localstringlocal transformation as string, -
    7. toStringfunctionreturns string property -
  2. }
-

Element.unclick(handler)

-

Removes a click event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.undblclick(handler)

-

Removes a double click event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.undrag()

-

Removes all drag event handlers from the given element -

-

Element.unhover(f_in, f_out)

-

Removes hover event handlers from the element -

-

Parameters

  1. f_in -function -handler for hover in
  2. -
  3. f_out -function -handler for hover out
  4. -
-

Returns: object Element

-

Element.unmousedown(handler)

-

Removes a mousedown event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.unmousemove(handler)

-

Removes a mousemove event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.unmouseout(handler)

-

Removes a mouseout event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.unmouseover(handler)

-

Removes a mouseover event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.unmouseup(handler)

-

Removes a mouseup event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.untouchcancel(handler)

-

Removes a touchcancel event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.untouchend(handler)

-

Removes a touchend event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.untouchmove(handler)

-

Removes a touchmove event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.untouchstart(handler)

-

Removes a touchstart event handler from the element -

-

Parameters

  1. handler -function -handler for the event
  2. -
-

Returns: object Element

-

Element.use()

-

Creates a <use> element linked to the current element -

-

Returns: Element the <use> element

-

Matrix.add(…)

-

Adds the given matrix to existing one -

-

Parameters

  1. a -number - 
  2. -
  3. b -number - 
  4. -
  5. c -number - 
  6. -
  7. d -number - 
  8. -
  9. e -number - 
  10. -
  11. f -number - 
  12. -
-

or -

-

Parameters

  1. matrix -object -Matrix
  2. -
-

Matrix.clone()

-

Returns a copy of the matrix -

-

Returns: object Matrix

-

Matrix.invert()

-

Returns an inverted version of the matrix -

-

Returns: object Matrix

-

Matrix.rotate(a, x, y)

-

Rotates the matrix -

-

Parameters

  1. a -number -angle of rotation, in degrees
  2. -
  3. x -number -horizontal origin point from which to rotate
  4. -
  5. y -number -vertical origin point from which to rotate
  6. -
-

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

-

Scales the matrix -

-

Parameters

  1. x -number -amount to be scaled, with 1 resulting in no change
  2. -
  3. y -optional -number -amount to scale along the vertical axis. (Otherwise x applies to both axes.)
  4. -
  5. cx -optional -number -horizontal origin point from which to scale
  6. -
  7. cy -optional -number -vertical origin point from which to scale
  8. -
-

Default cx, cy is the middle point of the element. -

-

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

-

Returns transform string that represents given matrix -

-

Returns: string transform string

-

Matrix.translate(x, y)

-

Translate the matrix -

-

Parameters

  1. x -number -horizontal offset distance
  2. -
  3. y -number -vertical offset distance
  4. -
-

Matrix.x(x, y)

-

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

-

Parameters

  1. x -number - 
  2. -
  3. y -number - 
  4. -
-

Returns: number x

-

Matrix.y(x, y)

-

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

-

Parameters

  1. x -number - 
  2. -
  3. y -number - 
  4. -
-

Returns: number y

-

Paper.circle(x, y, r)

-

Draws a circle -

-

Parameters

  1. x -number -x coordinate of the centre
  2. -
  3. y -number -y coordinate of the centre
  4. -
  5. r -number -radius
  6. -
-

Returns: object the circle element

-

Usage

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

Paper.clear()

-

Removes all child nodes of the paper, except <defs>. -

-

Paper.el(name, attr)

-

Creates an element on paper with a given name and no attributes -

-

Parameters

  1. name -string -tag name
  2. -
  3. attr -object -attributes
  4. -
-

Returns: Element the current element

-

Usage

var c = paper.circle(10, 10, 10); // is the same as...
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+

Parameters

+
    +
  1. name + string + tag name
  2. +
  3. attr + object + attributes
  4. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + Element + + the current element +

+ + + + + + + + +

Usage

+ + + + + + + + + + + +
var c = paper.circle(10, 10, 10); // is the same as...
 var c = paper.el("circle").attr({
     cx: 10,
     cy: 10,
     r: 10
-});
-
-

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

-

Draws an ellipse +});

+ + + + + +
+ + + +
+
+

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

+
+
+
+
+ + + + +

Draws a rectangle

-

Parameters

  1. x -number -x coordinate of the centre
  2. -
  3. y -number -y coordinate of the centre
  4. -
  5. rx -number -horizontal radius
  6. -
  7. ry -number -vertical radius
  8. -
-

Returns: object the ellipse element

-

Usage

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

Paper.filter(filstr)

-

Creates a <filter> element + + + + + + + + + + +

+

Parameters

+
    +
  1. x + number + x coordinate of the top left corner
  2. +
  3. y + number + y coordinate of the top left corner
  4. +
  5. width + number + width
  6. +
  7. height + number + height
  8. +
  9. rx + number + horizontal radius for rounded corners, default is 0
  10. +
  11. ry + number + vertical radius for rounded corners, default is rx or 0
  12. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + the rect element +

+ + + + + + + + +

Usage

+ + + + + + + + + + + +
// regular rectangle
+var c = paper.rect(10, 10, 50, 50);
+// rectangle with rounded corners
+var c = paper.rect(40, 40, 50, 50, 10);
+ + + + + +
+
+
+ +
+
+

Paper.circle(x, y, r)

+
+
+
+
+ + + + +

Draws a circle

-

Parameters

  1. filstr -string -SVG fragment of filter provided as a string
  2. -
-

Returns: object Element

-

Note: It is recommended to use filters embedded into the page inside an empty SVG element. + + + + + + + + + + +

+

Parameters

+
    +
  1. x + number + x coordinate of the centre
  2. +
  3. y + number + y coordinate of the centre
  4. +
  5. r + number + radius
  6. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + the circle element +

+ + + + + + + + +

Usage

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

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

+
+
+
+
+ + + + +

Places an image on the surface

-

Usage

var f = paper.filter('<feGaussianBlur stdDeviation="2"/>'),
-    c = paper.circle(10, 10, 10).attr({
-        filter: f
-    });
-
-

Paper.g([varargs])

-

Creates a group element + + + + + + + + + + +

+

Parameters

+
    +
  1. src + string + URI of the source image
  2. +
  3. x + number + x offset position
  4. +
  5. y + number + y offset position
  6. +
  7. width + number + width of the image
  8. +
  9. height + number + height of the image
  10. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + the image element +

+ + + + + +

or

-

Parameters

  1. varargs -optional - -elements to nest within the group
  2. -
-

Returns: object the g element

-

Usage

var c1 = paper.circle(),
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  
+                                  

+ Returns: + + object + + Raphaël element object with type image +

+ + + + + + + + +

Usage

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

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

+
+
+
+
+ + + + +

Draws an ellipse +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. x + number + x coordinate of the centre
  2. +
  3. y + number + y coordinate of the centre
  4. +
  5. rx + number + horizontal radius
  6. +
  7. ry + number + vertical radius
  8. + +
+
+ + + + + + + + + + + + + +

+ Returns: + + object + + the ellipse element +

+ + + + + + + + +

Usage

+ + + + + + + + + + + +
var c = paper.ellipse(50, 50, 40, 20);
+ + + + + +
+
+
+ +
+
+

Paper.path([pathString])

+
+
+
+
+ + + + +

Creates a <path> element using the given string as the path's definition +

+ + + + + + + + + + +
+

Parameters

+
    +
  1. pathString + string + path string in SVG format
  2. + +
+
+ + + + + + + + +

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

+ + + + + + + + + + + + + +
"M10,20L30,40"
+ + + + + + +

This example features two commands: M, with arguments (10, 20) and L with arguments (30, 40). Uppercase letter commands express coordinates in absolute terms, while lowercase commands express them in relative terms from the most recently declared coordinates. +

+ + + + + + + + + + + +

Here is short list of commands available, for more details see SVG path string format or article about path strings at MDN.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 to make life easier.
  • +Note: there is a special case when a path consists of only three commands: M10,10R…z. In this case the path connects back to its starting point. +

    + + + + + + + + + + + + +

    Usage

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

    Paper.g([varargs])

    +
    +
    +
    +
    + + + + +

    Creates a group element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. varargs + + elements to nest within the group
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + the g element +

    + + + + + + + + +

    Usage

    + + + + + + + + + + + +
    var c1 = paper.circle(),
         c2 = paper.rect(),
    -    g = paper.g(c2, c1); // note that the order of elements is different
    -
    -

    or + g = paper.g(c2, c1); // note that the order of elements is different

    + + + + + + +

    or

    -
    var c1 = paper.circle(),
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    var c1 = paper.circle(),
         c2 = paper.rect(),
         g = paper.g();
    -g.add(c2, c1);
    -
    -

    Paper.gradient(gradient)

    -

    Creates a gradient element +g.add(c2, c1);

    + + + + + + + +
    + +
    +
    +

    Paper.group()

    +
    +
    +
    +
    + + + + +

    See Paper.g

    -

    Parameters

    1. gradient -string -gradient descriptor
    2. -
    -

    Gradient Descriptor

    The gradient descriptor is an expression formatted as + + + + + + + + +

    +
    +
    + +
    +
    +

    Paper.text(x, y, text)

    +
    +
    +
    +
    + + + + +

    Draws a text string +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. x + number + x coordinate position
    2. +
    3. y + number + y coordinate position
    4. +
    5. text + string array + The text string to draw or array of strings to nest within separate <tspan> elements
    6. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + the text element +

    + + + + + + + + +

    Usage

    + + + + + + + + + + + +
    var t1 = paper.text(50, 50, "Snap");
    +var t2 = paper.text(50, 50, ["S","n","a","p"]);
    + + + + + +
    +
    +
    + +
    +
    +

    Paper.line(x1, y1, x2, y2)

    +
    +
    +
    +
    + + + + +

    Draws a line +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. x1 + number + x coordinate position of the start
    2. +
    3. y1 + number + y coordinate position of the start
    4. +
    5. x2 + number + x coordinate position of the end
    6. +
    7. y2 + number + y coordinate position of the end
    8. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + the line element +

    + + + + + + + + +

    Usage

    + + + + + + + + + + + +
    var t1 = paper.line(50, 50, 100, 100);
    + + + + + +
    +
    +
    + +
    +
    +

    Paper.polyline(…)

    +
    +
    +
    +
    + + + + +

    Draws a polyline +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. points + array + array of points
    2. + +
    +
    + + + + + + + + +

    or +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. varargs + + points
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + the polyline element +

    + + + + + + + + +

    Usage

    + + + + + + + + + + + +
    var p1 = paper.polyline([10, 10, 100, 100]);
    +var p2 = paper.polyline(10, 10, 100, 100);
    + + + + + +
    +
    +
    + +
    +
    +

    Paper.polygon()

    +
    +
    +
    +
    + + + + +

    Draws a polygon. See Paper.polyline +

    + + + + + + + + +
    +
    +
    + +
    +
    +

    Paper.gradient(gradient)

    +
    +
    +
    +
    + + + + +

    Creates a gradient element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. gradient + string + gradient descriptor
    2. + +
    +
    + + + + + + + + + + + +

    Gradient Descriptor

    + + + + + + + +

    The gradient descriptor is an expression formatted as follows: <type>(<coords>)<colors>. The <type> can be either linear or radial. The uppercase L or R letters indicate absolute coordinates offset from the SVG surface. @@ -900,1169 +6956,5422 @@ of dash-separated CSS color values. Each color may be followed by a custom offset value, separated with a colon character.

    -

    Examples

    Linear gradient, relative from top-left corner to bottom-right + + + + + + + + + + + + +

    Examples

    + + + + + + + +

    Linear gradient, relative from top-left corner to bottom-right corner, from black through red to white:

    -
    var g = paper.gradient("l(0, 0, 1, 1)#000-#f00-#fff");
    -
    -

    Linear gradient, absolute from (0, 0) to (100, 100), from black + + + + + + + + + + + + + +

    var g = paper.gradient("l(0, 0, 1, 1)#000-#f00-#fff");
    + + + + + + +

    Linear gradient, absolute from (0, 0) to (100, 100), from black through red at 25% to white:

    -
    var g = paper.gradient("L(0, 0, 100, 100)#000-#f00:25%-#fff");
    -
    -

    Radial gradient, relative from the center of the element with radius + + + + + + + + + + + + + +

    var g = paper.gradient("L(0, 0, 100, 100)#000-#f00:25%-#fff");
    + + + + + + +

    Radial gradient, relative from the center of the element with radius half the width, from black to white:

    -
    var g = paper.gradient("r(0.5, 0.5, 0.5)#000-#fff");
    -
    -

    To apply the gradient: + + + + + + + + + + + + + +

    var g = paper.gradient("r(0.5, 0.5, 0.5)#000-#fff");
    + + + + + + +

    To apply the gradient:

    -
    paper.circle(50, 50, 40).attr({
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    paper.circle(50, 50, 40).attr({
         fill: g
    -});
    -
    -

    Returns: object the gradient element

    -

    Paper.group()

    -

    See Paper.g +});

    + + + + + + + + + + + +

    + Returns: + + object + + the gradient element +

    + + + + + + +
    + +
    +
    +

    Paper.toString()

    +
    +
    +
    +
    + + + + +

    Returns SVG code for the Paper

    -

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

    -

    Places an image on the surface + + + + + + + + + + + + + + +

    + Returns: + + string + + SVG code for the Paper +

    + + + + +
    +
    +
    + +
    +
    +

    Paper.clear()

    +
    +
    +
    +
    + + + + +

    Removes all child nodes of the paper, except <defs>.

    -

    Parameters

    1. src -string -URI of the source image
    2. -
    3. x -number -x offset position
    4. -
    5. y -number -y offset position
    6. -
    7. width -number -width of the image
    8. -
    9. height -number -height of the image
    10. -
    -

    Returns: object the image element

    -

    or + + + + + + + + +

    +
    +
    + +
    +
    +

    Snap.ajax(…)

    +
    +
    +
    +
    + + + + +

    Simple implementation of Ajax

    -

    Returns: object Raphaël element object with type image

    -

    Usage

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

    Paper.line(x1, y1, x2, y2)

    -

    Draws a line + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. url + string + URL
    2. +
    3. postData + object string + data for post request
    4. +
    5. callback + function + callback
    6. +
    7. scope + object + scope of callback
    8. + +
    +
    + + + + + + + + +

    or

    -

    Parameters

    1. x1 -number -x coordinate position of the start
    2. -
    3. y1 -number -y coordinate position of the start
    4. -
    5. x2 -number -x coordinate position of the end
    6. -
    7. y2 -number -y coordinate position of the end
    8. -
    -

    Returns: object the line element

    -

    Usage

    var t1 = paper.line(50, 50, 100, 100);
    -
    -

    Paper.path([pathString])

    -

    Creates a <path> element using the given string as the path's definition + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. url + string + URL
    2. +
    3. callback + function + callback
    4. +
    5. scope + object + scope of callback
    6. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + XMLHttpRequest + + the XMLHttpRequest object, just in case +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.load(url, callback, [scope])

    +
    +
    +
    +
    + + + + +

    Loads external SVG file as a Fragment (see Snap.ajax for more advanced AJAX)

    -

    Parameters

    1. pathString -optional -string -path string in SVG format
    2. -
    -

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

    +

    Parameters

    +
      +
    1. url + string + URL
    2. +
    3. callback + function + callback
    4. +
    5. scope + object + scope of callback
    6. + +
    +
    + + + + + + + +
    +
    +
    + +
    +
    +

    mina(a, A, b, B, get, set, [easing])

    +
    +
    +
    +
    + + + + +

    Generic animation of numbers

    -
    "M10,20L30,40"
    -
    -

    This example features two commands: M, with arguments (10, 20) and L with arguments (30, 40). Uppercase letter commands express coordinates in absolute terms, while lowercase commands express them in relative terms from the most recently declared coordinates. + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. a + number + start slave number
    2. +
    3. A + number + end slave number
    4. +
    5. b + number + start master number (start time in gereal case)
    6. +
    7. B + number + end master number (end time in gereal case)
    8. +
    9. get + function + getter of master number (see mina.time)
    10. +
    11. set + function + setter of slave number
    12. +
    13. easing + function + easing function, default is mina.linear
    14. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + animation descriptor +

    + + + + + + + + + + + +
      + + +
    1. {
        + + + +
      1. + id + string + animation id, +
      2. + + + +
      3. + start + number + start slave number, +
      4. + + + +
      5. + end + number + end slave number, +
      6. + + + +
      7. + b + number + start master number, +
      8. + + + +
      9. + s + number + animation status (0..1), +
      10. + + + +
      11. + dur + number + animation duration, +
      12. + + + +
      13. + spd + number + animation speed, +
      14. + + + +
      15. + get + function + getter of master number (see mina.time), +
      16. + + + +
      17. + set + function + setter of slave number, +
      18. + + + +
      19. + easing + function + easing function, default is mina.linear, +
      20. + + + +
      21. + status + function + status getter/setter, +
      22. + + + +
      23. + speed + function + speed getter/setter, +
      24. + + + +
      25. + duration + function + duration getter/setter, +
      26. + + + +
      27. + stop + function + animation stopper +
      28. + + + +
    2. }
    3. + + +
    + + +
    +
    +
    + +
    +
    +

    mina.time()

    +
    +
    +
    +
    + + + + +

    Returns the current time. Equivalent to:

    -

    -

    Here is short list of commands available, for more details see SVG path string format or article about path strings at MDN.

    - - - - - - - - - - - -
    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 to make life easier.
  • -Note: there is a special case when a path consists of only three commands: M10,10R…z. In this case the path connects back to its starting point. + + + + + + + + + + + + + +
    function () {
    +    return (new Date).getTime();
    +}
    + + + + + +
    +
    +
    + +
    +
    +

    mina.getById(id)

    +
    +
    +
    +
    + + + + +

    Returns an animation by its id

    -

    Usage

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

    Paper.polygon()

    -

    Draws a polygon. See Paper.polyline + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. id + string + animation's id
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + See mina +

    + + + + +
    +
    +
    + +
    +
    +

    mina.linear(n)

    +
    +
    +
    +
    + + + + +

    Default linear easing

    -

    Paper.polyline(…)

    -

    Draws a polyline + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.easeout(n)

    +
    +
    +
    +
    + + + + +

    Easeout easing

    -

    Parameters

    1. points -array -array of points
    2. -
    -

    or + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.easein(n)

    +
    +
    +
    +
    + + + + +

    Easein easing

    -

    Parameters

    1. varargs - -points
    2. -
    -

    Returns: object the polyline element

    -

    Usage

    var p1 = paper.polyline([10, 10, 100, 100]);
    -var p2 = paper.polyline(10, 10, 100, 100);
    -
    -

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

    -

    -

    Draws a rectangle + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.easeinout(n)

    +
    +
    +
    +
    + + + + +

    Easeinout easing

    -

    Parameters

    1. x -number -x coordinate of the top left corner
    2. -
    3. y -number -y coordinate of the top left corner
    4. -
    5. width -number -width
    6. -
    7. height -number -height
    8. -
    9. rx -optional -number -horizontal radius for rounded corners, default is 0
    10. -
    11. ry -optional -number -vertical radius for rounded corners, default is rx or 0
    12. -
    -

    Returns: object the rect element

    -

    Usage

    // regular rectangle
    -var c = paper.rect(10, 10, 50, 50);
    -// rectangle with rounded corners
    -var c = paper.rect(40, 40, 50, 50, 10);
    -
    -

    Paper.text(x, y, text)

    -

    Draws a text string + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.backin(n)

    +
    +
    +
    +
    + + + + +

    Backin easing

    -

    Parameters

    1. x -number -x coordinate position
    2. -
    3. y -number -y coordinate position
    4. -
    5. text -string array -The text string to draw or array of strings to nest within separate <tspan> elements
    6. -
    -

    Returns: object the text element

    -

    Usage

    var t1 = paper.text(50, 50, "Snap");
    -var t2 = paper.text(50, 50, ["S","n","a","p"]);
    -
    -

    Paper.toString()

    -

    Returns SVG code for the element, equivalent to HTML's outerHTML + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.backout(n)

    +
    +
    +
    +
    + + + + +

    Backout easing

    -

    Returns: string SVG code for the element

    -

    Returns SVG code for the Paper + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.elastic(n)

    +
    +
    +
    +
    + + + + +

    Elastic easing

    -

    Returns: string SVG code for the Paper

    -

    Set

    -

    Set.clear()

    -

    Removes all elements from the set + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    mina.bounce(n)

    +
    +
    +
    +
    + + + + +

    Bounce easing

    -

    Set.exclude(element)

    -

    Removes given element from the set + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. n + number + input 0..1
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + output 0..1 +

    + + + + +
    +
    +
    + +
    +
    +

    Paper.filter(filstr)

    +
    +
    +
    +
    + + + + +

    Creates a <filter> element

    -

    Parameters

    1. element -object -element to remove
    2. -
    -

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

    -

    Set.forEach(callback, thisArg)

    -

    Executes given function for each element in the set + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. filstr + string + SVG fragment of filter provided as a string
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + + +

    Note: It is recommended to use filters embedded into the page inside an empty SVG element.

    -

    If the function returns false, the loop stops running. -

    -

    Parameters

    1. callback -function -function to run
    2. -
    3. thisArg -object -context object for the callback
    4. -
    -

    Returns: object Set object

    -

    Set.pop()

    -

    Removes last element and returns it -

    -

    Returns: object element

    -

    Set.push()

    -

    Adds each argument to the current set -

    -

    Returns: object original element

    -

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

    -

    Removes range of elements from the set -

    -

    Parameters

    1. index -number -position of the deletion
    2. -
    3. count -number -number of element to remove
    4. -
    5. insertion… -optional -object -elements to insert
    6. -
    -

    Returns: object set elements that were deleted

    -

    Snap(…)

    -

    Creates a drawing surface or wraps existing SVG element. -

    -

    Parameters

    1. width -number string -width of surface
    2. -
    3. height -number string -height of surface
    4. -
    -

    or -

    -

    Parameters

    1. DOM -SVGElement -element to be wrapped into Snap structure
    2. -
    -

    or -

    -

    Parameters

    1. query -string -CSS query selector
    2. -
    -

    Returns: object Element

    -

    Snap.Matrix(…)

    -

    Utility method -Returns a matrix based on the given parameters -

    -

    Parameters

    1. a -number - 
    2. -
    3. b -number - 
    4. -
    5. c -number - 
    6. -
    7. d -number - 
    8. -
    9. e -number - 
    10. -
    11. f -number - 
    12. -
    -

    or -

    -

    Parameters

    1. svgMatrix -SVGMatrix - 
    2. -
    -

    Returns: object Matrix

    -

    Snap.ajax(…)

    -

    Simple implementation of Ajax -

    -

    Parameters

    1. url -string -URL
    2. -
    3. postData -object string -data for post request
    4. -
    5. callback -function -callback
    6. -
    7. scope -optional -object -scope of callback
    8. -
    -

    or -

    -

    Parameters

    1. url -string -URL
    2. -
    3. callback -function -callback
    4. -
    5. scope -optional -object -scope of callback
    6. -
    -

    Returns: XMLHttpRequest the XMLHttpRequest object, just in case

    -

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

    -

    Returns an angle between two or three points -

    -

    Parameters

    Parameters

    1. x1 -number -x coord of first point
    2. -
    3. y1 -number -y coord of first point
    4. -
    5. x2 -number -x coord of second point
    6. -
    7. y2 -number -y coord of second point
    8. -
    9. x3 -optional -number -x coord of third point
    10. -
    11. y3 -optional -number -y coord of third point
    12. -
    -

    Returns: number angle in degrees

    -

    Snap.animate(from, to, setter, duration, [easing], [callback])

    -

    Runs generic animation of one number into another with a caring function -

    -

    Parameters

    1. from -number array -number or array of numbers
    2. -
    3. to -number array -number or array of numbers
    4. -
    5. setter -function -caring function that accepts one number argument
    6. -
    7. duration -number -duration, in milliseconds
    8. -
    9. easing -optional -function -easing function from mina or custom
    10. -
    11. callback -optional -function -callback function to execute when animation ends
    12. -
    -

    Returns: object animation object in mina format

    -
    1. {
      1. idstringanimation id, consider it read-only, -
      2. durationfunctiongets or sets the duration of the animation, -
      3. easingfunctioneasing, -
      4. speedfunctiongets or sets the speed of the animation, -
      5. statusfunctiongets or sets the status of the animation, -
      6. stopfunctionstops the animation -
    2. }
    -
    var rect = Snap().rect(0, 0, 10, 10);
    -Snap.animate(0, 10, function (val) {
    -    rect.attr({
    -        x: val
    -    });
    -}, 1000);
    -// in given context is equivalent to
    -rect.animate({x: 10}, 1000);
    -
    -

    Snap.animation(attr, duration, [easing], [callback])

    -

    Creates an animation object -

    -

    Parameters

    1. attr -object -attributes of final destination
    2. -
    3. duration -number -duration of the animation, in milliseconds
    4. -
    5. easing -optional -function -one of easing functions of mina or custom one
    6. -
    7. callback -optional -function -callback function that fires when animation ends
    8. -
    -

    Returns: object animation object

    -

    Snap.color(clr)

    -

    Parses the color string and returns an object featuring the color's component values -

    -

    Parameters

    1. clr -string -color string in one of the supported formats (see Snap.getRGB)
    2. -
    -

    Returns: object Combined RGB/HSB object in the following 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. }
    -

    Snap.deg(rad)

    -

    Transform angle to degrees -

    -

    Parameters

    1. rad -number -angle in radians
    2. -
    -

    Returns: number angle in degrees

    -

    Snap.filter

    -

    Snap.filter.blur(x, [y])

    -

    Returns an SVG markup string for the blur filter -

    -

    Parameters

    1. x -number -amount of horizontal blur, in pixels
    2. -
    3. y -optional -number -amount of vertical blur, in pixels
    4. -
    -

    Returns: string filter representation

    -

    Usage

    var f = paper.filter(Snap.filter.blur(5, 10)),
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  

    Usage

    + + + + + + + + + + + +
    var f = paper.filter(''),
         c = paper.circle(10, 10, 10).attr({
             filter: f
    -    });
    -
    -

    Snap.filter.brightness(amount)

    -

    Returns an SVG markup string for the brightness filter + });

    + + + + + + + +
    + +
    +
    +

    Snap.filter.blur(x, [y])

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the blur filter

    -

    Parameters

    1. amount -number -amount of filter (0..1)
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.contrast(amount)

    -

    Returns an SVG markup string for the contrast filter -

    -

    Parameters

    1. amount -number -amount of filter (0..1)
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.grayscale(amount)

    -

    Returns an SVG markup string for the grayscale filter -

    -

    Parameters

    1. amount -number -amount of filter (0..1)
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.hueRotate(angle)

    -

    Returns an SVG markup string for the hue-rotate filter -

    -

    Parameters

    1. angle -number -angle of rotation
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.invert(amount)

    -

    Returns an SVG markup string for the invert filter -

    -

    Parameters

    1. amount -number -amount of filter (0..1)
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.saturate(amount)

    -

    Returns an SVG markup string for the saturate filter -

    -

    Parameters

    1. amount -number -amount of filter (0..1)
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.sepia(amount)

    -

    Returns an SVG markup string for the sepia filter -

    -

    Parameters

    1. amount -number -amount of filter (0..1)
    2. -
    -

    Returns: string filter representation

    -

    Snap.filter.shadow(dx, dy, [blur], [color])

    -

    Returns an SVG markup string for the shadow filter -

    -

    Parameters

    1. dx -number -horizontal shift of the shadow, in pixels
    2. -
    3. dy -number -vertical shift of the shadow, in pixels
    4. -
    5. blur -optional -number -amount of blur
    6. -
    7. color -optional -string -color of the shadow
    8. -
    -

    Returns: string filter representation

    -

    Usage

    var f = paper.filter(Snap.filter.shadow(0, 2, 3)),
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +                                  
    +

    Parameters

    +
      +
    1. x + number + amount of horizontal blur, in pixels
    2. +
    3. y + number + amount of vertical blur, in pixels
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + + + + + +

    Usage

    + + + + + + + + + + + +
    var f = paper.filter(Snap.filter.blur(5, 10)),
         c = paper.circle(10, 10, 10).attr({
             filter: f
    -    });
    -
    -

    Snap.format(token, json)

    -

    Replaces construction of type {<name>} to the corresponding argument + });

    + + + + + + + +
    + +
    +
    +

    Snap.filter.shadow(dx, dy, [blur], [color])

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the shadow filter

    -

    Parameters

    1. token -string -string to format
    2. -
    3. json -object -object which properties are used as a replacement
    4. -
    -

    Returns: string formatted string

    -

    Usage

    // this draws a rectangular shape equivalent to "M10,20h40v50h-40z"
    -paper.path(Snap.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
    -    }
    -}));
    -
    -

    Snap.fragment(varargs)

    -

    Creates a DOM fragment from a given list of elements or strings + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. dx + number + horizontal shift of the shadow, in pixels
    2. +
    3. dy + number + vertical shift of the shadow, in pixels
    4. +
    5. blur + number + amount of blur
    6. +
    7. color + string + color of the shadow
    8. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + + + + + +

    Usage

    + + + + + + + + + + + +
    var f = paper.filter(Snap.filter.shadow(0, 2, 3)),
    +    c = paper.circle(10, 10, 10).attr({
    +        filter: f
    +    });
    + + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.grayscale(amount)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the grayscale filter

    -

    Parameters

    1. varargs - -SVG string
    2. -
    -

    Returns: Fragment the Fragment

    -

    Snap.getRGB(color)

    -

    Parses color string as RGB object + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. amount + number + amount of filter (0..1)
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.sepia(amount)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the sepia filter

    -

    Parameters

    1. color -string -color string in one of the following formats:
    2. -
    -
      -
    • Color name (red, green, cornflowerblue, etc)
    • -
    • #••• — shortened HTML color: (#000, #fc0, etc.)
    • -
    • #•••••• — full length HTML color: (#000000, #bd2300)
    • -
    • rgb(•••, •••, •••) — red, green and blue channels values: (rgb(200, 100, 0))
    • -
    • rgba(•••, •••, •••, •••) — also with opacity
    • -
    • rgb(•••%, •••%, •••%) — same as above, but in %: (rgb(100%, 175%, 0%))
    • -
    • rgba(•••%, •••%, •••%, •••%) — also with opacity
    • -
    • hsb(•••, •••, •••) — hue, saturation and brightness values: (hsb(0.5, 0.25, 1))
    • -
    • hsba(•••, •••, •••, •••) — also with opacity
    • -
    • hsb(•••%, •••%, •••%) — same as above, but in %
    • -
    • hsba(•••%, •••%, •••%, •••%) — also with opacity
    • -
    • hsl(•••, •••, •••) — hue, saturation and luminosity values: (hsb(0.5, 0.25, 0.5))
    • -
    • hsla(•••, •••, •••, •••) — also with opacity
    • -
    • hsl(•••%, •••%, •••%) — same as above, but in %
    • -
    • hsla(•••%, •••%, •••%, •••%) — also with opacity
    • -
    -

    Note that % can be used any time: rgb(20%, 255, 50%). + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. amount + number + amount of filter (0..1)
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.saturate(amount)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the saturate filter

    -

    Returns: object RGB object in the following format:

    -
    1. {
      1. rnumberred, -
      2. gnumbergreen, -
      3. bnumberblue, -
      4. hexstringcolor in HTML/CSS format: #••••••, -
      5. errorbooleantrue if string can't be parsed -
    2. }
    -

    Snap.hsb(h, s, b)

    -

    Converts HSB values to a hex representation of the color + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. amount + number + amount of filter (0..1)
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.hueRotate(angle)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the hue-rotate filter

    -

    Parameters

    1. h -number -hue
    2. -
    3. s -number -saturation
    4. -
    5. b -number -value or brightness
    6. -
    -

    Returns: string hex representation of the color

    -

    Snap.hsb2rgb(h, s, v)

    -

    Converts HSB values to an RGB object + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. angle + number + angle of rotation
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.invert(amount)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the invert filter

    -

    Parameters

    1. h -number -hue
    2. -
    3. s -number -saturation
    4. -
    5. v -number -value or brightness
    6. -
    -

    Returns: object RGB object in the following format:

    -
    1. {
      1. rnumberred, -
      2. gnumbergreen, -
      3. bnumberblue, -
      4. hexstringcolor in HTML/CSS format: #•••••• -
    2. }
    -

    Snap.hsl(h, s, l)

    -

    Converts HSL values to a hex representation of the color + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. amount + number + amount of filter (0..1)
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.brightness(amount)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the brightness filter

    -

    Parameters

    1. h -number -hue
    2. -
    3. s -number -saturation
    4. -
    5. l -number -luminosity
    6. -
    -

    Returns: string hex representation of the color

    -

    Snap.hsl2rgb(h, s, l)

    -

    Converts HSL values to an RGB object + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. amount + number + amount of filter (0..1)
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.filter.contrast(amount)

    +
    +
    +
    +
    + + + + +

    Returns an SVG markup string for the contrast filter

    -

    Parameters

    1. h -number -hue
    2. -
    3. s -number -saturation
    4. -
    5. l -number -luminosity
    6. -
    -

    Returns: object RGB object in the following format:

    -
    1. {
      1. rnumberred, -
      2. gnumbergreen, -
      3. bnumberblue, -
      4. hexstringcolor in HTML/CSS format: #•••••• -
    2. }
    -

    Snap.is(o, type)

    -

    Handy replacement for the typeof operator + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. amount + number + amount of filter (0..1)
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + filter representation +

    + + + + +
    +
    +
    + +
    +
    +

    Element.click(handler)

    +
    +
    +
    +
    + + + + +

    Adds a click event handler to the element

    -

    Parameters

    1. o - -any object or primitive
    2. -
    3. type -string -name of the type, e.g., string, function, number, etc.
    4. -
    -

    Returns: boolean true if given value is of given type

    -

    Snap.load(url, callback, [scope])

    -

    Loads external SVG file as a Fragment (see Snap.ajax for more advanced AJAX) + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unclick(handler)

    +
    +
    +
    +
    + + + + +

    Removes a click event handler from the element

    -

    Parameters

    1. url -string -URL
    2. -
    3. callback -function -callback
    4. -
    5. scope -optional -object -scope of callback
    6. -
    -

    Snap.parse(svg)

    -

    Parses SVG fragment and converts it into a Fragment + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.dblclick(handler)

    +
    +
    +
    +
    + + + + +

    Adds a double click event handler to the element

    -

    Parameters

    1. svg -string -SVG string
    2. -
    -

    Returns: Fragment the Fragment

    -

    Snap.parsePathString(pathString)

    -

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

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.undblclick(handler)

    +
    +
    +
    +
    + + + + +

    Removes a double click event handler from the element

    -

    Parameters

    1. pathString -string array -path string or array of segments (in the last case it is returned straight away)
    2. -
    -

    Returns: array array of segments

    -

    Snap.parseTransformString(TString)

    -

    Utility method -Parses given transform string into an array of transformations + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.mousedown(handler)

    +
    +
    +
    +
    + + + + +

    Adds a mousedown event handler to the element

    -

    Parameters

    1. TString -string array -transform string or array of transformations (in the last case it is returned straight away)
    2. -
    -

    Returns: array array of transformations

    -

    Snap.path

    -

    Snap.path.bezierBBox(…)

    -

    Utility method -Returns the bounding box of a given cubic beziér curve + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unmousedown(handler)

    +
    +
    +
    +
    + + + + +

    Removes a mousedown event handler from the element

    -

    Parameters

    1. p1x -number -x of the first point of the curve
    2. -
    3. p1y -number -y of the first point of the curve
    4. -
    5. c1x -number -x of the first anchor of the curve
    6. -
    7. c1y -number -y of the first anchor of the curve
    8. -
    9. c2x -number -x of the second anchor of the curve
    10. -
    11. c2y -number -y of the second anchor of the curve
    12. -
    13. p2x -number -x of the second point of the curve
    14. -
    15. p2y -number -y of the second point of the curve
    16. -
    -

    or + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.mousemove(handler)

    +
    +
    +
    +
    + + + + +

    Adds a mousemove event handler to the element

    -

    Parameters

    1. bez -array -array of six points for beziér curve
    2. -
    -

    Returns: object bounding box

    -
    1. {
      1. x:numberx coordinate of the left top point of the box, -
      2. y:numbery coordinate of the left top point of the box, -
      3. x2:numberx coordinate of the right bottom point of the box, -
      4. y2:numbery coordinate of the right bottom point of the box, -
      5. width:numberwidth of the box, -
      6. height:numberheight of the box -
    2. }
    -

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

    -

    Utility method + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unmousemove(handler)

    +
    +
    +
    +
    + + + + +

    Removes a mousemove event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.mouseout(handler)

    +
    +
    +
    +
    + + + + +

    Adds a mouseout event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unmouseout(handler)

    +
    +
    +
    +
    + + + + +

    Removes a mouseout event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.mouseover(handler)

    +
    +
    +
    +
    + + + + +

    Adds a mouseover event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unmouseover(handler)

    +
    +
    +
    +
    + + + + +

    Removes a mouseover event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.mouseup(handler)

    +
    +
    +
    +
    + + + + +

    Adds a mouseup event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unmouseup(handler)

    +
    +
    +
    +
    + + + + +

    Removes a mouseup event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.touchstart(handler)

    +
    +
    +
    +
    + + + + +

    Adds a touchstart event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.untouchstart(handler)

    +
    +
    +
    +
    + + + + +

    Removes a touchstart event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.touchmove(handler)

    +
    +
    +
    +
    + + + + +

    Adds a touchmove event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.untouchmove(handler)

    +
    +
    +
    +
    + + + + +

    Removes a touchmove event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.touchend(handler)

    +
    +
    +
    +
    + + + + +

    Adds a touchend event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.untouchend(handler)

    +
    +
    +
    +
    + + + + +

    Removes a touchend event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.touchcancel(handler)

    +
    +
    +
    +
    + + + + +

    Adds a touchcancel event handler to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.untouchcancel(handler)

    +
    +
    +
    +
    + + + + +

    Removes a touchcancel event handler from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. handler + function + handler for the event
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

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

    +
    +
    +
    +
    + + + + +

    Adds hover event handlers to the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. f_in + function + handler for hover in
    2. +
    3. f_out + function + handler for hover out
    4. +
    5. icontext + object + context for hover in handler
    6. +
    7. ocontext + object + context for hover out handler
    8. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.unhover(f_in, f_out)

    +
    +
    +
    +
    + + + + +

    Removes hover event handlers from the element +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. f_in + function + handler for hover in
    2. +
    3. f_out + function + handler for hover out
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

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

    +
    +
    +
    +
    + + + + +

    Adds event handlers for an element's drag gesture +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. onmove + function + handler for moving
    2. +
    3. onstart + function + handler for drag start
    4. +
    5. onend + function + handler for drag end
    6. +
    7. mcontext + object + context for moving handler
    8. +
    9. scontext + object + context for drag start handler
    10. +
    11. econtext + object + context for drag end handler
    12. + +
    +
    + + + + + + + + +

    Additionaly following drag events are triggered: drag.start.<id> on start, +drag.end.<id> on end and drag.move.<id> on every move. When element is dragged over another element +drag.over.<id> fires as well. +

    Start event and start handler are called in specified context or in context of the element with following parameters: +

    + + + + + + + + + + + + + + + +
      + + +
    1. + x + number + x position of the mouse +
    2. + + + +
    3. + y + number + y position of the mouse +
    4. + + + +
    5. + event + object + DOM event object +
    6. + + +
    + + + +

    Move event and move handler are called in specified context or in context of the element with following parameters: +

    + + + + + + + + + + + + + + + +
      + + +
    1. + dx + number + shift by x from the start point +
    2. + + + +
    3. + dy + number + shift by y from the start point +
    4. + + + +
    5. + x + number + x position of the mouse +
    6. + + + +
    7. + y + number + y position of the mouse +
    8. + + + +
    9. + event + object + DOM event object +
    10. + + +
    + + + +

    End event and end handler are called in specified context or in context of the element with following parameters: +

    + + + + + + + + + + + + + + + +
      + + +
    1. + event + object + DOM event object +
    2. + + +
    + + + + + + + + +

    + Returns: + + object + + Element +

    + + + + +
    +
    +
    + +
    +
    +

    Element.undrag()

    +
    +
    +
    +
    + + + + +

    Removes all drag event handlers from the given element +

    + + + + + + + + +
    +
    +
    + +
    +
    +

    Snap.path.getTotalLength(path)

    +
    +
    +
    +
    + + + + +

    Returns the length of the given path in pixels +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. path + string + SVG path string
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + number + + length +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.getPointAtLength(path, length)

    +
    +
    +
    +
    + + + + +

    Returns the coordinates of the point located at the given length along the given path +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. path + string + SVG path string
    2. +
    3. length + number + length, in pixels, from the start of the path, excluding non-rendering jumps
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + representation of the point: +

    + + + + + + + + + + + +
      + + +
    1. {
        + + + +
      1. + x: + number + x coordinate, +
      2. + + + +
      3. + y: + number + y coordinate, +
      4. + + + +
      5. + alpha: + number + angle of derivative +
      6. + + + +
    2. }
    3. + + +
    + + +
    +
    +
    + +
    +
    +

    Snap.path.getSubpath(path, from, to)

    +
    +
    +
    +
    + + + + +

    Returns the subpath of a given path between given start and end lengths +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. path + string + SVG path string
    2. +
    3. from + number + length, in pixels, from the start of the path to the start of the segment
    4. +
    5. to + number + length, in pixels, from the start of the path to the end of the segment
    6. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + path string definition for the segment +

    + + + + +
    +
    +
    + +
    +
    +

    Element.getTotalLength()

    +
    +
    +
    +
    + + + + +

    Returns the length of the path in pixels (only works for path elements) +

    + + + + + + + + + + + + + + +

    + Returns: + + number + + length +

    + + + + +
    +
    +
    + +
    +
    +

    Element.getPointAtLength(length)

    +
    +
    +
    +
    + + + + +

    Returns coordinates of the point located at the given length on the given path (only works for path elements) +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. length + number + length, in pixels, from the start of the path, excluding non-rendering jumps
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + representation of the point: +

    + + + + + + + + + + + +
      + + +
    1. {
        + + + +
      1. + x: + number + x coordinate, +
      2. + + + +
      3. + y: + number + y coordinate, +
      4. + + + +
      5. + alpha: + number + angle of derivative +
      6. + + + +
    2. }
    3. + + +
    + + +
    +
    +
    + +
    +
    +

    Element.getSubpath(from, to)

    +
    +
    +
    +
    + + + + +

    Returns subpath of a given element from given start and end lengths (only works for path elements) +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. from + number + length, in pixels, from the start of the path to the start of the segment
    2. +
    3. to + number + length, in pixels, from the start of the path to the end of the segment
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + path string definition for the segment +

    + + + + +
    +
    +
    + +
    +
    +

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

    +
    +
    +
    +
    + + + + +

    Utility method Finds dot coordinates on the given cubic beziér curve at the given t

    -

    Parameters

    1. p1x -number -x of the first point of the curve
    2. -
    3. p1y -number -y of the first point of the curve
    4. -
    5. c1x -number -x of the first anchor of the curve
    6. -
    7. c1y -number -y of the first anchor of the curve
    8. -
    9. c2x -number -x of the second anchor of the curve
    10. -
    11. c2y -number -y of the second anchor of the curve
    12. -
    13. p2x -number -x of the second point of the curve
    14. -
    15. p2y -number -y of the second point of the curve
    16. -
    17. t -number -position on the curve (0..1)
    18. -
    -

    Returns: object point information in format:

    -
    1. {
      1. x:numberx coordinate of the point, -
      2. y:numbery coordinate of the point, -
      3. m: {
        1. x:numberx coordinate of the left anchor, -
        2. y:numbery coordinate of the left anchor -
      4. },
      5. n: {
        1. x:numberx coordinate of the right anchor, -
        2. y:numbery coordinate of the right anchor -
      6. },
      7. start: {
        1. x:numberx coordinate of the start of the curve, -
        2. y:numbery coordinate of the start of the curve -
      8. },
      9. end: {
        1. x:numberx coordinate of the end of the curve, -
        2. y:numbery coordinate of the end of the curve -
      10. },
      11. alpha:numberangle of the curve derivative at the point -
    2. }
    -

    Snap.path.getBBox(path)

    -

    Utility method -Returns the bounding box of a given path + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. p1x + number + x of the first point of the curve
    2. +
    3. p1y + number + y of the first point of the curve
    4. +
    5. c1x + number + x of the first anchor of the curve
    6. +
    7. c1y + number + y of the first anchor of the curve
    8. +
    9. c2x + number + x of the second anchor of the curve
    10. +
    11. c2y + number + y of the second anchor of the curve
    12. +
    13. p2x + number + x of the second point of the curve
    14. +
    15. p2y + number + y of the second point of the curve
    16. +
    17. t + number + position on the curve (0..1)
    18. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + point information in format: +

    + + + + + + + + + + + +
      + + +
    1. {
        + + + +
      1. + x: + number + x coordinate of the point, +
      2. + + + +
      3. + y: + number + y coordinate of the point, +
      4. + + + +
      5. m: {
          + + + +
        1. + x: + number + x coordinate of the left anchor, +
        2. + + + +
        3. + y: + number + y coordinate of the left anchor +
        4. + + + +
      6. },
      7. + + + +
      8. n: {
          + + + +
        1. + x: + number + x coordinate of the right anchor, +
        2. + + + +
        3. + y: + number + y coordinate of the right anchor +
        4. + + + +
      9. },
      10. + + + +
      11. start: {
          + + + +
        1. + x: + number + x coordinate of the start of the curve, +
        2. + + + +
        3. + y: + number + y coordinate of the start of the curve +
        4. + + + +
      12. },
      13. + + + +
      14. end: {
          + + + +
        1. + x: + number + x coordinate of the end of the curve, +
        2. + + + +
        3. + y: + number + y coordinate of the end of the curve +
        4. + + + +
      15. },
      16. + + + +
      17. + alpha: + number + angle of the curve derivative at the point +
      18. + + + +
    2. }
    3. + + +
    + + +
    +
    +
    + +
    +
    +

    Snap.path.bezierBBox(…)

    +
    +
    +
    +
    + + + + +

    Utility method +Returns the bounding box of a given cubic beziér curve

    -

    Parameters

    1. path -string -path string
    2. -
    -

    Returns: object bounding box

    -
    1. {
      1. x:numberx coordinate of the left top point of the box, -
      2. y:numbery coordinate of the left top point of the box, -
      3. x2:numberx coordinate of the right bottom point of the box, -
      4. y2:numbery coordinate of the right bottom point of the box, -
      5. width:numberwidth of the box, -
      6. height:numberheight of the box -
    2. }
    -

    Snap.path.getPointAtLength(path, length)

    -

    Returns the coordinates of the point located at the given length along the given path + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. p1x + number + x of the first point of the curve
    2. +
    3. p1y + number + y of the first point of the curve
    4. +
    5. c1x + number + x of the first anchor of the curve
    6. +
    7. c1y + number + y of the first anchor of the curve
    8. +
    9. c2x + number + x of the second anchor of the curve
    10. +
    11. c2y + number + y of the second anchor of the curve
    12. +
    13. p2x + number + x of the second point of the curve
    14. +
    15. p2y + number + y of the second point of the curve
    16. + +
    +
    + + + + + + + + +

    or

    -

    Parameters

    1. path -string -SVG path string
    2. -
    3. length -number -length, in pixels, from the start of the path, excluding non-rendering jumps
    4. -
    -

    Returns: object representation of the point:

    -
    1. {
      1. x:numberx coordinate, -
      2. y:numbery coordinate, -
      3. alpha:numberangle of derivative -
    2. }
    -

    Snap.path.getSubpath(path, from, to)

    -

    Returns the subpath of a given path between given start and end lengths -

    -

    Parameters

    1. path -string -SVG path string
    2. -
    3. from -number -length, in pixels, from the start of the path to the start of the segment
    4. -
    5. to -number -length, in pixels, from the start of the path to the end of the segment
    6. -
    -

    Returns: string path string definition for the segment

    -

    Snap.path.getTotalLength(path)

    -

    Returns the length of the given path in pixels -

    -

    Parameters

    1. path -string -SVG path string
    2. -
    -

    Returns: number length

    -

    Snap.path.intersection(path1, path2)

    -

    Utility method -Finds intersections of two paths -

    -

    Parameters

    1. path1 -string -path string
    2. -
    3. path2 -string -path string
    4. -
    -

    Returns: array dots of intersection

    -
    1. [
    2. {
      1. x:numberx coordinate of the point, -
      2. y:numbery coordinate of the point, -
      3. t1:numbert value for segment of path1, -
      4. t2:numbert value for segment of path2, -
      5. segment1:numberorder number for segment of path1, -
      6. segment2:numberorder number for segment of path2, -
      7. bez1:arrayeight coordinates representing beziér curve for the segment of path1, -
      8. bez2:arrayeight coordinates representing beziér curve for the segment of path2 -
    3. }
    4. ]
    -

    Snap.path.isBBoxIntersect(bbox1, bbox2)

    -

    Utility method -Returns true if two bounding boxes intersect -

    -

    Parameters

    1. bbox1 -string -first bounding box
    2. -
    3. bbox2 -string -second bounding box
    4. -
    -

    Returns: boolean true if bounding boxes intersect

    -

    Snap.path.isPointInside(path, x, y)

    -

    Utility method -Returns true if given point is inside a given closed path. -

    -

    Note: fill mode doesn’t affect the result of this method. -

    -

    Parameters

    1. path -string -path string
    2. -
    3. x -number -x of the point
    4. -
    5. y -number -y of the point
    6. -
    -

    Returns: boolean true if point is inside the path

    -

    Snap.path.isPointInsideBBox(bbox, x, y)

    -

    Utility method + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. bez + array + array of six points for beziér curve
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + bounding box +

    + + + + + + + + + + + +
      + + +
    1. {
        + + + +
      1. + x: + number + x coordinate of the left top point of the box, +
      2. + + + +
      3. + y: + number + y coordinate of the left top point of the box, +
      4. + + + +
      5. + x2: + number + x coordinate of the right bottom point of the box, +
      6. + + + +
      7. + y2: + number + y coordinate of the right bottom point of the box, +
      8. + + + +
      9. + width: + number + width of the box, +
      10. + + + +
      11. + height: + number + height of the box +
      12. + + + +
    2. }
    3. + + +
    + + +
    +
    +
    + +
    +
    +

    Snap.path.isPointInsideBBox(bbox, x, y)

    +
    +
    +
    +
    + + + + +

    Utility method Returns true if given point is inside bounding box

    -

    Parameters

    1. bbox -string -bounding box
    2. -
    3. x -string -x coordinate of the point
    4. -
    5. y -string -y coordinate of the point
    6. -
    -

    Returns: boolean true if point is inside

    -

    Snap.path.map(path, matrix)

    -

    Transform the path string with the given matrix + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. bbox + string + bounding box
    2. +
    3. x + string + x coordinate of the point
    4. +
    5. y + string + y coordinate of the point
    6. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + boolean + + true if point is inside +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.isBBoxIntersect(bbox1, bbox2)

    +
    +
    +
    +
    + + + + +

    Utility method +Returns true if two bounding boxes intersect

    -

    Parameters

    1. path -string -path string
    2. -
    3. matrix -object -see Matrix
    4. -
    -

    Returns: string transformed path string

    -

    Snap.path.toAbsolute(path)

    -

    Utility method -Converts path coordinates into absolute values + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. bbox1 + string + first bounding box
    2. +
    3. bbox2 + string + second bounding box
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + boolean + + true if bounding boxes intersect +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.intersection(path1, path2)

    +
    +
    +
    +
    + + + + +

    Utility method +Finds intersections of two paths

    -

    Parameters

    1. path -string -path string
    2. -
    -

    Returns: array path string

    -

    Snap.path.toCubic(pathString)

    -

    Utility method -Converts path to a new path where all segments are cubic beziér curves + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. path1 + string + path string
    2. +
    3. path2 + string + path string
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + array + + dots of intersection +

    + + + + + + + + + + + +
      + + +
    1. [
    2. + + + +
    3. {
        + + + +
      1. + x: + number + x coordinate of the point, +
      2. + + + +
      3. + y: + number + y coordinate of the point, +
      4. + + + +
      5. + t1: + number + t value for segment of path1, +
      6. + + + +
      7. + t2: + number + t value for segment of path2, +
      8. + + + +
      9. + segment1: + number + order number for segment of path1, +
      10. + + + +
      11. + segment2: + number + order number for segment of path2, +
      12. + + + +
      13. + bez1: + array + eight coordinates representing beziér curve for the segment of path1, +
      14. + + + +
      15. + bez2: + array + eight coordinates representing beziér curve for the segment of path2 +
      16. + + + +
    4. }
    5. + + + +
    6. ]
    7. + + +
    + + +
    +
    +
    + +
    +
    +

    Snap.path.isPointInside(path, x, y)

    +
    +
    +
    +
    + + + + +

    Utility method +Returns true if given point is inside a given closed path. +

    Note: fill mode doesn’t affect the result of this method.

    -

    Parameters

    1. pathString -string array -path string or array of segments
    2. -
    -

    Returns: array array of segments

    -

    Snap.path.toRelative(path)

    -

    Utility method + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. path + string + path string
    2. +
    3. x + number + x of the point
    4. +
    5. y + number + y of the point
    6. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + boolean + + true if point is inside the path +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.getBBox(path)

    +
    +
    +
    +
    + + + + +

    Utility method +Returns the bounding box of a given path +

    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. path + string + path string
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + bounding box +

    + + + + + + + + + + + +
      + + +
    1. {
        + + + +
      1. + x: + number + x coordinate of the left top point of the box, +
      2. + + + +
      3. + y: + number + y coordinate of the left top point of the box, +
      4. + + + +
      5. + x2: + number + x coordinate of the right bottom point of the box, +
      6. + + + +
      7. + y2: + number + y coordinate of the right bottom point of the box, +
      8. + + + +
      9. + width: + number + width of the box, +
      10. + + + +
      11. + height: + number + height of the box +
      12. + + + +
    2. }
    3. + + +
    + + +
    +
    +
    + +
    +
    +

    Snap.path.toRelative(path)

    +
    +
    +
    +
    + + + + +

    Utility method Converts path coordinates into relative values

    -

    Parameters

    1. path -string -path string
    2. -
    -

    Returns: array path string

    -

    Snap.rad(deg)

    -

    Transform angle to radians + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. path + string + path string
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + array + + path string +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.toAbsolute(path)

    +
    +
    +
    +
    + + + + +

    Utility method +Converts path coordinates into absolute values

    -

    Parameters

    1. deg -number -angle in degrees
    2. -
    -

    Returns: number angle in radians

    -

    Snap.rgb(r, g, b)

    -

    Converts RGB values to a hex representation of the color + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. path + string + path string
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + array + + path string +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.toCubic(pathString)

    +
    +
    +
    +
    + + + + +

    Utility method +Converts path to a new path where all segments are cubic beziér curves

    -

    Parameters

    1. r -number -red
    2. -
    3. g -number -green
    4. -
    5. b -number -blue
    6. -
    -

    Returns: string hex representation of the color

    -

    Snap.rgb2hsb(r, g, b)

    -

    Converts RGB values to an HSB object + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. pathString + string array + path string or array of segments
    2. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + array + + array of segments +

    + + + + +
    +
    +
    + +
    +
    +

    Snap.path.map(path, matrix)

    +
    +
    +
    +
    + + + + +

    Transform the path string with the given matrix

    -

    Parameters

    1. r -number -red
    2. -
    3. g -number -green
    4. -
    5. b -number -blue
    6. -
    -

    Returns: object HSB object in the following format:

    -
    1. {
      1. hnumberhue, -
      2. snumbersaturation, -
      3. bnumberbrightness -
    2. }
    -

    Snap.rgb2hsl(r, g, b)

    -

    Converts RGB values to an HSL object + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. path + string + path string
    2. +
    3. matrix + object + see Matrix
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + string + + transformed path string +

    + + + + +
    +
    +
    + +
    +
    +

    Set.push()

    +
    +
    +
    +
    + + + + +

    Adds each argument to the current set

    -

    Parameters

    1. r -number -red
    2. -
    3. g -number -green
    4. -
    5. b -number -blue
    6. -
    -

    Returns: object HSL object in the following format:

    -
    1. {
      1. hnumberhue, -
      2. snumbersaturation, -
      3. lnumberluminosity -
    2. }
    -

    Snap.select(query)

    -

    Wraps a DOM element specified by CSS selector as Element + + + + + + + + + + + + + + +

    + Returns: + + object + + original element +

    + + + + +
    +
    +
    + +
    +
    +

    Set.pop()

    +
    +
    +
    +
    + + + + +

    Removes last element and returns it

    -

    Parameters

    1. query -string -CSS selector of the element
    2. -
    -

    Returns: Element the current element

    -

    Snap.selectAll(query)

    -

    Wraps DOM elements specified by CSS selector as set or array of Element + + + + + + + + + + + + + + +

    + Returns: + + object + + element +

    + + + + +
    +
    +
    + +
    +
    +

    Set.forEach(callback, thisArg)

    +
    +
    +
    +
    + + + + +

    Executes given function for each element in the set +

    If the function returns false, the loop stops running.

    -

    Parameters

    1. query -string -CSS selector of the element
    2. -
    -

    Returns: Element the current element

    -

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

    -

    Snaps given value to given grid + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. callback + function + function to run
    2. +
    3. thisArg + object + context object for the callback
    4. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + Set object +

    + + + + +
    +
    +
    + +
    +
    +

    Set.clear()

    +
    +
    +
    +
    + + + + +

    Removes all elements from the set

    -

    Parameters

    1. values -array number -given array of values or step of the grid
    2. -
    3. value -number -value to adjust
    4. -
    5. tolerance -optional -number -maximum distance to the target value that would trigger the snap. Default is 10.
    6. -
    -

    Returns: number adjusted value

    -

    mina(a, A, b, B, get, set, [easing])

    -

    Generic animation of numbers + + + + + + + + +

    +
    +
    + +
    +
    +

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

    +
    +
    +
    +
    + + + + +

    Removes range of elements from the set

    -

    Parameters

    1. a -number -start slave number
    2. -
    3. A -number -end slave number
    4. -
    5. b -number -start master number (start time in gereal case)
    6. -
    7. B -number -end master number (end time in gereal case)
    8. -
    9. get -function -getter of master number (see mina.time)
    10. -
    11. set -function -setter of slave number
    12. -
    13. easing -optional -function -easing function, default is mina.linear
    14. -
    -

    Returns: object animation descriptor

    -
    1. {
      1. idstringanimation id, -
      2. startnumberstart slave number, -
      3. endnumberend slave number, -
      4. bnumberstart master number, -
      5. snumberanimation status (0..1), -
      6. durnumberanimation duration, -
      7. spdnumberanimation speed, -
      8. getfunctiongetter of master number (see mina.time), -
      9. setfunctionsetter of slave number, -
      10. easingfunctioneasing function, default is mina.linear, -
      11. statusfunctionstatus getter/setter, -
      12. speedfunctionspeed getter/setter, -
      13. durationfunctionduration getter/setter, -
      14. stopfunctionanimation stopper -
    2. }
    -

    mina.backin(n)

    -

    Backin easing + + + + + + + + + + +

    +

    Parameters

    +
      +
    1. index + number + position of the deletion
    2. +
    3. count + number + number of element to remove
    4. +
    5. insertion… + object + elements to insert
    6. + +
    +
    + + + + + + + + + + + + + +

    + Returns: + + object + + set elements that were deleted +

    + + + + +
    +
    +
    + +
    +
    +

    Set.exclude(element)

    +
    +
    +
    +
    + + + + +

    Removes given element from the set

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.backout(n)

    -

    Backout easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.bounce(n)

    -

    Bounce easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.easein(n)

    -

    Easein easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.easeinout(n)

    -

    Easeinout easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.easeout(n)

    -

    Easeout easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.elastic(n)

    -

    Elastic easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.getById(id)

    -

    Returns an animation by its id -

    -

    Parameters

    1. id -string -animation's id
    2. -
    -

    Returns: object See mina

    -

    mina.linear(n)

    -

    Default linear easing -

    -

    Parameters

    1. n -number -input 0..1
    2. -
    -

    Returns: number output 0..1

    -

    mina.time()

    -

    Returns the current time. Equivalent to: -

    -
    function () {
    -    return (new Date).getTime();
    -}
    -
    -
    + + + + + + + + + + +
    +

    Parameters

    +
      +
    1. element + object + element to remove
    2. + +
    +
    + + + + + + + + + + + + + +

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

    + + + + + + + + + - - - - + + + + + + + + + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + {{~it.out :item:index}} +
    +
    +

    {{=item[0].name}}

    +
    +
    +
    +
    + {{~item :line:i}} + {{ if (i > 0) { }} + {{ if (line.text) { }}

    {{=line.text.join("

    ")}}

    {{ } }} + {{ if (line.attr) { }}
    +

    Parameters

    +
      + {{~line.attr :attr:j}}
    1. {{=attr.name}} + {{~attr.type :type:k}}{{=type}} {{~}} + {{=attr.desc}}
    2. + {{~}} +
    +
    {{ } }} + {{ if (line.html) { }}{{=line.html}} + {{ } }} + {{ if (line.head) { }}

    {{=line.head}}

    + {{ } }} + {{ if (line.code) { }}
    {{=line.code.join("\n")}}
    + {{ } }} + {{ if (line.rtrn) { }}

    + Returns: + {{~line.rtrn.type :type:k}} + {{=type}} + {{~}} + {{=line.rtrn.desc}} +

    + {{ } }} + {{ if (line.json) { }}
      + {{~line.json :a:j}} + {{ if (a.key) { }} +
    1. + {{=a.key}} + {{~a.type :type:k}}{{=type}} {{~}} + {{=a.desc}} +
    2. + {{ } else if (a.start) { }} +
    3. {{=a.start}}
        + {{ } else if (a.end) { }} +
    4. {{=a.end}}
    5. + {{ } else { }} +
    6. {{=a}}
    7. + {{ } }} + {{~}} +
    {{ } }} + {{ } }} + {{~}} +
    +
    +
    + {{~}} +
    + +
    +
    + + + + \ No newline at end of file