lib-present-graphic-svg-animation-files-helper-functions.js / js
@fileoverview ECMAScript <a href="http://www.carto.net/papers/svg/resources/helper_functions.html">helper functions</a>, main purpose is to serve in SVG mapping or other SVG based web applications This ECMA script library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library (http://www.carto.net/papers/svg/resources/lesser_gpl.txt); if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Please report bugs and send improvements to neumann@karto.baug.ethz.ch If you use these scripts, please link to the original (http://www.carto.net/papers/svg/resources/helper_functions.html) somewhere in the source-code-comment or the "about" of your project and give credits, thanks! See <a href="js_docs_out/overview-summary-helper_functions.js.html">documentation</a>.
author: Andreas Neumann a.neumann@carto.net @copyright LGPL 2.1 <a href="http://www.gnu.org/copyleft/lesser.txt">Gnu LGPL 2.1</a> @credits Bruce Rindahl, numerous people on svgdevelopers@yahoogroups.com
This variable is a shortcut to the full URL of the SVG namespace @final @type String
This variable is a shortcut to the full URL of the XLink namespace @final @type String
This variable is a shortcut to the full URL of the attrib namespace @final @type String
This variable is a alias to the full URL of the attrib namespace @final @type String
This variable is a alias to the full URL of the Batik extension namespace @final @type String
Returns the polar direction from a given vector
parameter: {Number} xdiff the x-part of the vector
parameter: {Number} ydiff the y-part of the vector
returns: direction the direction in radians @type Number
version: 1.0 (2007-04-30)
see: #toPolarDist
see: #toRectX
see: #toRectY
Returns the polar distance from a given vector
parameter: {Number} xdiff the x-part of the vector
parameter: {Number} ydiff the y-part of the vector
returns: distance the distance @type Number
version: 1.0 (2007-04-30)
see: #toPolarDir
see: #toRectX
see: #toRectY
Returns the x-part of a vector from a given direction and distance
parameter: {Number} direction the direction (in radians)
parameter: {Number} distance the distance
returns: x the x-part of the vector @type Number
version: 1.0 (2007-04-30)
see: #toPolarDist
see: #toPolarDir
see: #toRectY
Returns the y-part of the vector from a given direction and distance
parameter: {Number} direction the direction (in radians)
parameter: {Number} distance the distance
returns: y the y-part of the vector @type Number
version: 1.0 (2007-04-30)
see: #toPolarDist
see: #toPolarDir
see: #toRectX
Converts degrees to radians
parameter: {Number} deg the degree value
returns: rad the radians value @type Number
version: 1.0 (2007-04-30)
see: #RadToDeg
Converts radians to degrees
parameter: {Number} rad the radians value
returns: deg the degree value @type Number
version: 1.0 (2007-04-30)
see: #DegToRad
Converts decimal degrees to degrees, minutes, seconds
parameter: {Number} dd the decimal degree value
returns: degrees the degree values in the following notation: {deg:degrees,min:minutes,sec:seconds} @type literal
version: 1.0 (2007-04-30)
see: #dms2dd
Converts degrees, minutes and seconds to decimal degrees
parameter: {Number} deg the degree value
parameter: {Number} min the minute value
parameter: {Number} sec the second value
returns: deg the decimal degree values @type Number
version: 1.0 (2007-04-30)
see: #dd2dms
log function, missing in the standard Math object
parameter: {Number} x the value where the log function should be applied to
parameter: {Number} b the base value for the log function
returns: logResult the result of the log function @type Number
version: 1.0 (2007-04-30)
interpolates a value (e.g. elevation) bilinearly based on the position within a cell with 4 corner values
parameter: {Number} za the value at the upper left corner of the cell
parameter: {Number} zb the value at the upper right corner of the cell
parameter: {Number} zc the value at the lower right corner of the cell
parameter: {Number} zd the value at the lower left corner of the cell
parameter: {Number} xpos the x position of the point where a new value should be interpolated
parameter: {Number} ypos the y position of the point where a new value should be interpolated
parameter: {Number} ax the x position of the lower left corner of the cell
parameter: {Number} ay the y position of the lower left corner of the cell
parameter: {Number} cellsize the size of the cell
returns: interpol_value the result of the bilinear interpolation function @type Number
version: 1.0 (2007-04-30)
tests if a given point is left or right of a given line
parameter: {Number} pointx the x position of the given point
parameter: {Number} pointy the y position of the given point
parameter: {Number} linex1 the x position of line's start point
parameter: {Number} liney1 the y position of line's start point
parameter: {Number} linex2 the x position of line's end point
parameter: {Number} liney2 the y position of line's end point
returns: leftof the result of the leftOfTest, 1 means leftOf, 0 means rightOf @type Number (integer, 0|1)
version: 1.0 (2007-04-30)
calculates the distance between a given point and a given line
parameter: {Number} pointx the x position of the given point
parameter: {Number} pointy the y position of the given point
parameter: {Number} linex1 the x position of line's start point
parameter: {Number} liney1 the y position of line's start point
parameter: {Number} linex2 the x position of line's end point
parameter: {Number} liney2 the y position of line's end point
returns: distance the result of the leftOfTest, 1 means leftOf, 0 means rightOf @type Number
version: 1.0 (2007-04-30)
calculates the angle between two vectors (lines)
parameter: {Number} ax the x part of vector a
parameter: {Number} ay the y part of vector a
parameter: {Number} bx the x part of vector b
parameter: {Number} by the y part of vector b
returns: angle the angle in radians @type Number
version: 1.0 (2007-04-30) @credits <a href="http://www.mathe-online.at/mathint/vect2/i.html#Winkel">Mathe Online (Winkel)</a>
calculates the bisector vector for two given vectors
parameter: {Number} ax the x part of vector a
parameter: {Number} ay the y part of vector a
parameter: {Number} bx the x part of vector b
parameter: {Number} by the y part of vector b
returns: c the resulting vector as an Array, c[0] is the x part of the vector, c[1] is the y part @type Array
version: 1.0 (2007-04-30) @credits <a href="http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale">Mathe Online (Winkelsymmetrale)</a> see #calcBisectorAngle
calculates the bisector angle for two given vectors
parameter: {Number} ax the x part of vector a
parameter: {Number} ay the y part of vector a
parameter: {Number} bx the x part of vector b
parameter: {Number} by the y part of vector b
returns: angle the bisector angle in radians @type Number
version: 1.0 (2007-04-30) @credits <a href="http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale">Mathe Online (Winkelsymmetrale)</a> see #calcBisectorVector
calculates the intersection point of two given lines
parameter: {Number} line1x1 the x the start point of line 1
parameter: {Number} line1y1 the y the start point of line 1
parameter: {Number} line1x2 the x the end point of line 1
parameter: {Number} line1y2 the y the end point of line 1
returns: interSectPoint the intersection point, interSectPoint.x contains x-part, interSectPoint.y the y-part of the resulting coordinate @type Object
version: 1.0 (2007-04-30) @credits <a href="http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/">P. Bourke</a>
reformats a given number to a string by adding separators at every third digit
parameter: {String|Number} inputNumber the input number, can be of type number or string
parameter: {String} separator the separator, e.g. ' or ,
returns: newString the intersection point, interSectPoint.x contains x-part, interSectPoint.y the y-part of the resulting coordinate @type String
version: 1.0 (2007-04-30)
writes a status text message out to a SVG text element's first child
parameter: {String} statusText the text message to be displayed
version: 1.0 (2007-04-30)
scales an SVG element, requires that the element has an x and y attribute (e.g. circle, ellipse, use element, etc.)
parameter: {dom::Event} evt the evt object that triggered the scaling
parameter: {Number} factor the scaling factor
version: 1.0 (2007-04-30)
returns the transformation matrix (ctm) for the given node up to the root element the basic use case is to provide a wrapper function for the missing SVGLocatable.getTransformToElement method (missing in ASV3)
parameter: {svg::SVGTransformable} node the node reference for the SVGElement the ctm is queried
returns: CTM the current transformation matrix from the given node to the root element @type svg::SVGMatrix
version: 1.0 (2007-05-01) @credits <a href="http://www.kevlindev.com/tutorials/basics/transformations/toUserSpace/index.htm">Kevin Lindsey (toUserSpace)</a>
see: #getTransformToElement
returns the transformation matrix (ctm) for the given dom::Node up to a different dom::Node the basic use case is to provide a wrapper function for the missing SVGLocatable.getTransformToElement method (missing in ASV3)
parameter: {svg::SVGTransformable} node the node reference for the element the where the ctm should be calculated from
parameter: {svg::SVGTransformable} targetNode the target node reference for the element the ctm should be calculated to
returns: CTM the current transformation matrix from the given node to the target element @type svg::SVGMatrix
version: 1.0 (2007-05-01) @credits <a href="http://www.kevlindev.com/tutorials/basics/transformations/toUserSpace/index.htm">Kevin Lindsey (toUserSpace)</a>
see: #getTransformToRootElement
converts HSV to RGB values
parameter: {Number} hue the hue value (between 0 and 360)
parameter: {Number} sat the saturation value (between 0 and 1)
parameter: {Number} val the value value (between 0 and 1)
returns: rgbArr the rgb values (associative array or object, the keys are: red,green,blue), all values are scaled between 0 and 255 @type Object
version: 1.0 (2007-05-01)
see: #rgb2hsv
converts RGB to HSV values
parameter: {Number} red the hue value (between 0 and 255)
parameter: {Number} green the saturation value (between 0 and 255)
parameter: {Number} blue the value value (between 0 and 255)
returns: hsvArr the hsv values (associative array or object, the keys are: hue (0-360),sat (0-1),val (0-1)) @type Object
version: 1.0 (2007-05-01)
see: #hsv2rgb
populates an array such that it can be addressed by both a key or an index nr, note that both Arrays need to be of the same length
parameter: {Array} arrayKeys the array containing the keys
parameter: {Array} arrayValues the array containing the values
returns: returnArray the resulting array containing both associative values and also a regular indexed array @type Array
version: 1.0 (2007-05-01)
Wrapper object for network requests, uses getURL or XMLHttpRequest depending on availability The callBackFunction receives a XML or text node representing the rootElement of the fragment received or the return text, depending on the returnFormat. See also the following <a href="http://www.carto.net/papers/svg/network_requests/">documentation</a>. @class this is a wrapper object to provide network request functionality (get|post)
parameter: {String} url the URL/IRI of the network resource to be called
parameter: {Function|Object} callBackFunction the callBack function or object that is called after the data was received, in case of an object, the method 'receiveData' is called; both the function and the object's 'receiveData' method get 2 return parameters: 'node.firstChild'|text (the root element of the XML or text resource), this.additionalParams (if defined)
parameter: {String} returnFormat the return format, either 'xml' or 'json' (or text)
parameter: {String} method the method of the network request, either 'get' or 'post'
parameter: {String|Undefined} postText the String containing the post text (optional) or Undefined (if not a 'post' request)
parameter: {Object|Array|String|Number|Undefined} additionalParams additional parameters that will be passed to the callBackFunction or object (optional) or Undefined
returns: a new getData instance @type getData @constructor
version: 1.0 (2007-02-23)
triggers the network request defined in the constructor
this is the callback method for the getURL() or postURL() case @private
this is the callback method for the XMLHttpRequest case @private
Serializes an XML node and returns a string representation. Wrapper function to hide implementation differences. This can be used for debugging purposes or to post data to a server or network resource.
parameter: {dom::Node} node the DOM node reference
returns: textRepresentation the String representation of the XML node @type String
version: 1.0 (2007-05-01)
see: getData
Starts a SMIL animation element with the given id by triggering the '.beginElement()' method. This is a convenience (shortcut) function.
parameter: {String} id a valid id of a valid SMIL animation element
version: 1.0 (2007-05-01)
(C) Æliens 04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.