Raphael.js

68

Click here to load reader

Transcript of Raphael.js

Page 1: Raphael.js

Page:1/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1: // JavaScript Document2: /*!3: * Raphael 1.5.2 - JavaScript Vector Library4: *5: * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)6: * Licensed under the MIT (http://raphaeljs.com/license.html) license.7: */8: (function () { // This bracket matches to the last line9: function R() { // R start - end: 2110: if (R.is(arguments[0], array)) {11: var a = arguments[0],12: cnv = create[apply](R, a.splice(0, 3 + R.is(a[0], nu))),13: res = cnv.set();14: for (var i = 0, ii = a[length]; i < ii; i++) {15: var j = a[i] || {};16: elements[has](j.type) && res[push](cnv[j.type]().attr(j));17: }18: return res;19: }20: return create[apply](R, arguments);21: } // R end - start: 922: 23: R.version = "1.5.2"; // How to use the version ??24: var separator = /[, ]+/, // Variable Definitions start - end: 9225: elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1},26: formatrg = /\{(\d+)\}/g,27: proto = "prototype",28: has = "hasOwnProperty",29: doc = document,30: win = window,31: oldRaphael = {32: was: Object[proto][has].call(win, "Raphael"),33: is: win.Raphael34: },35: Paper = function () {36: this.customAttributes = {};37: },38: paperproto,39: appendChild = "appendChild",40: apply = "apply",41: concat = "concat",42: supportsTouch = "createTouch" in doc,43: E = "",44: S = " ",45: Str = String,46: split = "split",47: events = "click dblclick mousedown mousemove mouseout mouseover mouseup

touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[split](S),

48: touchMap = {49: mousedown: "touchstart",50: mousemove: "touchmove",51: mouseup: "touchend"52: },53: join = "join",54: length = "length",55: lowerCase = Str[proto].toLowerCase,56: math = Math,

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Text Box
// later on - associative with has, key, attr
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Typewriter
create([superclass][, methods...]) -> Class Class.create returns a function that, when called, will fire its own initialize method.
Page 2: Raphael.js

Page:2/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

57: mmax = math.max,58: mmin = math.min,59: abs = math.abs,60: pow = math.pow,61: PI = math.PI,62: nu = "number",63: string = "string",64: array = "array",65: toString = "toString",66: fillString = "fill",67: objectToString = Object[proto][toString],68: paper = {},69: push = "push",70: ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,71: colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,

\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,

72: isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},73: bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,74: round = math.round,75: setAttribute = "setAttribute",76: toFloat = parseFloat,77: toInt = parseInt,78: ms = " progid:DXImageTransform.Microsoft",79: upperCase = Str[proto].toUpperCase,80: availableAttrs = {blur: 0, "clip-rect": "0 0 1e9 1e9", cursor: "default",

cx: 0, cy: 0, fill: "#fff", "fill-opacity": 1, font: '10px "Arial"', "font-family": '"Arial"', "font-size": "10", "font-style": "normal", "font-weight": 400, gradient: 0, height: 0, href: "http://raphaeljs.com/", opacity: 1, path: "M0,0", r: 0, rotation: 0, rx: 0, ry: 0, scale: "1 1", src: "", stroke: "#000", dasharray": "", "stroke-linecap": "butt", "stroke-linejoin": "butt", miterlimit": 0, "stroke-opacity": 1, "stroke-width": 1, target: "_blank", anchor": "middle", title: "Raphael", translation: "0 0", width: 0, x: 0, y: 0},

81: availableAnimAttrs = {along: "along", blur: nu, "clip-rect": "csv", cx: nu, cy: nu, fill: "colour", "fill-opacity": nu, "font-size": nu, height: nu, opacity: nu, path: "path", r: nu, rotation: "csv", rx: nu, ry: nu, scale: "csv", stroke: "colour", "stroke-opacity": nu, "stroke-width": nu, translation: "csv", width: nu, x: nu, y: nu},

82: rp = "replace",83: animKeyFrames= /^(from|to|\d+%?)$/,84: commaSpaces = /\s*,\s*/,85: hsrg = {hs: 1, rg: 1},86: p2s = /,?([achlmqrstvxz]),?/gi,87: pathCommand = /([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,

?\s*)+)/ig,88: pathValues = /(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,89: radial_gradient = /^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,90: sortByKey = function (a, b) {91: return a.key - b.key;92: }; // Variable Definitions end - start: 2493: 94: R.type = (win.SVGAngle ||

doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); // testing type for SVG or Microsoft VML

95: if (R.type == "VML") { // preparations for VML96: var d = doc.createElement("div"),

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
nilray
Highlight
Page 3: Raphael.js

Page:3/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

97: b;98: d.innerHTML = '<v:shape adj="1"/>';99: b = d.firstChild;100: b.style.behavior = "url(#default#VML)";101: if (!(b && typeof b.adj == "object")) {102: return R.type = null;103: }104: d = null;105: } // preparations for VML106: R.svg = !(R.vml = R.type == "VML"); // if R.type == "VML" then R.vml is 1 or

else R.svg is 1107: Paper[proto] = R[proto];108: paperproto = Paper[proto];109: R._id = 0;110: R._oid = 0;111: R.fn = {};112: R.is = function (o, type) {113: type = lowerCase.call(type);114: if (type == "finite") {115: return !isnan[has](+o);116: }117: return (type == "null" && o === null) ||118: (type == typeof o) ||119: (type == "object" && o === Object(o)) ||120: (type == "array" && Array.isArray && Array.isArray(o)) ||121: objectToString.call(o).slice(8, -1).toLowerCase() == type;122: };123: R.angle = function (x1, y1, x2, y2, x3, y3) {124: if (x3 == null) {125: var x = x1 - x2,126: y = y1 - y2;127: if (!x && !y) {128: return 0;129: }130: return ((x < 0) * 180 + math.atan(-y / -x) * 180 / PI + 360) % 360;131: } else {132: return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3);133: }134: };135: R.rad = function (deg) {136: return deg % 360 * PI / 180;137: };138: R.deg = function (rad) {139: return rad * 180 / PI % 360;140: };141: R.snapTo = function (values, value, tolerance) {142: tolerance = R.is(tolerance, "finite") ? tolerance : 10;143: if (R.is(values, array)) {144: var i = values.length;145: while (i--) if (abs(values[i] - value) <= tolerance) {146: return values[i];147: }148: } else {149: values = +values;150: var rem = value % values;151: if (rem < tolerance) {152: return value - rem;153: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
Page 4: Raphael.js

Page:4/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

154: if (rem > values - tolerance) {155: return value - rem + values;156: }157: }158: return value;159: };160: function createUUID() {161: // http://www.ietf.org/rfc/rfc4122.txt162: var s = [],163: i = 0;164: for (; i < 32; i++) {165: s[i] = (~~(math.random() * 16))[toString](16);166: }167: s[12] = 4; // bits 12-15 of the time_hi_and_version field to 0010168: s[16] = ((s[16] & 3) | 8)[toString](16); // bits 6-7 of the

clock_seq_hi_and_reserved to 01169: return "r-" + s[join]("");170: }171: 172: R.setWindow = function (newwin) {173: win = newwin;174: doc = win.document;175: };176: // colour utilities start - end: 468177: var toHex = function (color) {178: if (R.vml) {179: // http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-

hex-in-msie/180: var trim = /^\s+|\s+$/g;181: var bod;182: try {183: var docum = new ActiveXObject("htmlfile");184: docum.write("<body>");185: docum.close();186: bod = docum.body;187: } catch(e) {188: bod = createPopup().document.body;189: }190: var range = bod.createTextRange();191: toHex = cacher(function (color) {192: try {193: bod.style.color = Str(color)[rp](trim, E);194: var value = range.queryCommandValue("ForeColor");195: value = ((value & 255) << 16) | (value & 65280) | ((value &

16711680) >>> 16);196: return "#" + ("000000" + value[toString](16)).slice(-6);197: } catch(e) {198: return "none";199: }200: });201: } else {202: var i = doc.createElement("i");203: i.title = "Rapha\xebl Colour Picker";204: i.style.display = "none";205: doc.body[appendChild](i);206: toHex = cacher(function (color) {207: i.style.color = color;208: return doc.defaultView.getComputedStyle(i,

E).getPropertyValue("color");

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
Page 5: Raphael.js

Page:5/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

209: });210: }211: return toHex(color);212: },213: hsbtoString = function () {214: return "hsb(" + [this.h, this.s, this.b] + ")";215: },216: hsltoString = function () {217: return "hsl(" + [this.h, this.s, this.l] + ")";218: },219: rgbtoString = function () {220: return this.hex;221: };222: R.hsb2rgb = function (h, s, b, o) {223: if (R.is(h, "object") && "h" in h && "s" in h && "b" in h) {224: b = h.b;225: s = h.s;226: h = h.h;227: o = h.o;228: }229: return R.hsl2rgb(h, s, b / 2, o);230: };231: R.hsl2rgb = function (h, s, l, o) {232: if (R.is(h, "object") && "h" in h && "s" in h && "l" in h) {233: l = h.l;234: s = h.s;235: h = h.h;236: }237: if (h > 1 || s > 1 || l > 1) {238: h /= 360;239: s /= 100;240: l /= 100;241: }242: var rgb = {},243: channels = ["r", "g", "b"],244: t2, t1, t3, r, g, b;245: if (!s) {246: rgb = {247: r: l,248: g: l,249: b: l250: };251: } else {252: if (l < .5) {253: t2 = l * (1 + s);254: } else {255: t2 = l + s - l * s;256: }257: t1 = 2 * l - t2;258: for (var i = 0; i < 3; i++) {259: t3 = h + 1 / 3 * -(i - 1);260: t3 < 0 && t3++;261: t3 > 1 && t3--;262: if (t3 * 6 < 1) {263: rgb[channels[i]] = t1 + (t2 - t1) * 6 * t3;264: } else if (t3 * 2 < 1) {265: rgb[channels[i]] = t2;266: } else if (t3 * 3 < 2) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 6: Raphael.js

Page:6/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

267: rgb[channels[i]] = t1 + (t2 - t1) * (2 / 3 - t3) * 6;268: } else {269: rgb[channels[i]] = t1;270: }271: }272: }273: rgb.r *= 255;274: rgb.g *= 255;275: rgb.b *= 255;276: rgb.hex = "#" + (16777216 | rgb.b | (rgb.g << 8) | (rgb.r <<

16)).toString(16).slice(1);277: R.is(o, "finite") && (rgb.opacity = o);278: rgb.toString = rgbtoString;279: return rgb;280: };281: R.rgb2hsb = function (red, green, blue) {282: if (green == null && R.is(red, "object") && "r" in red && "g" in red && "b"

in red) {283: blue = red.b;284: green = red.g;285: red = red.r;286: }287: if (green == null && R.is(red, string)) {288: var clr = R.getRGB(red);289: red = clr.r;290: green = clr.g;291: blue = clr.b;292: }293: if (red > 1 || green > 1 || blue > 1) {294: red /= 255;295: green /= 255;296: blue /= 255;297: }298: var max = mmax(red, green, blue),299: min = mmin(red, green, blue),300: hue,301: saturation,302: brightness = max;303: if (min == max) {304: return {h: 0, s: 0, b: max, toString: hsbtoString};305: } else {306: var delta = (max - min);307: saturation = delta / max;308: if (red == max) {309: hue = (green - blue) / delta;310: } else if (green == max) {311: hue = 2 + ((blue - red) / delta);312: } else {313: hue = 4 + ((red - green) / delta);314: }315: hue /= 6;316: hue < 0 && hue++;317: hue > 1 && hue--;318: }319: return {h: hue, s: saturation, b: brightness, toString: hsbtoString};320: };321: R.rgb2hsl = function (red, green, blue) {322: if (green == null && R.is(red, "object") && "r" in red && "g" in red && "b"

in red) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 7: Raphael.js

Page:7/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

323: blue = red.b;324: green = red.g;325: red = red.r;326: }327: if (green == null && R.is(red, string)) {328: var clr = R.getRGB(red);329: red = clr.r;330: green = clr.g;331: blue = clr.b;332: }333: if (red > 1 || green > 1 || blue > 1) {334: red /= 255;335: green /= 255;336: blue /= 255;337: }338: var max = mmax(red, green, blue),339: min = mmin(red, green, blue),340: h,341: s,342: l = (max + min) / 2,343: hsl;344: if (min == max) {345: hsl = {h: 0, s: 0, l: l};346: } else {347: var delta = max - min;348: s = l < .5 ? delta / (max + min) : delta / (2 - max - min);349: if (red == max) {350: h = (green - blue) / delta;351: } else if (green == max) {352: h = 2 + (blue - red) / delta;353: } else {354: h = 4 + (red - green) / delta;355: }356: h /= 6;357: h < 0 && h++;358: h > 1 && h--;359: hsl = {h: h, s: s, l: l};360: }361: hsl.toString = hsltoString;362: return hsl;363: };364: R._path2string = function () {365: return this.join(",")[rp](p2s, "$1");366: };367: function cacher(f, scope, postprocessor) {368: function newf() {369: var arg = Array[proto].slice.call(arguments, 0),370: args = arg[join]("\u25ba"),371: cache = newf.cache = newf.cache || {},372: count = newf.count = newf.count || [];373: if (cache[has](args)) {374: return postprocessor ? postprocessor(cache[args]) : cache[args];375: }376: count[length] >= 1e3 && delete cache[count.shift()];377: count[push](args);378: cache[args] = f[apply](scope, arg);379: return postprocessor ? postprocessor(cache[args]) : cache[args];380: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 8: Raphael.js

Page:8/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

381: return newf;382: }383: 384: R.getRGB = cacher(function (colour) {385: if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {386: return {r: -1, g: -1, b: -1, hex: "none", error: 1};387: }388: if (colour == "none") {389: return {r: -1, g: -1, b: -1, hex: "none"};390: }391: !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() ==

"#") && (colour = toHex(colour));392: var res,393: red,394: green,395: blue,396: opacity,397: t,398: values,399: rgb = colour.match(colourRegExp);400: if (rgb) {401: if (rgb[2]) {402: blue = toInt(rgb[2].substring(5), 16);403: green = toInt(rgb[2].substring(3, 5), 16);404: red = toInt(rgb[2].substring(1, 3), 16);405: }406: if (rgb[3]) {407: blue = toInt((t = rgb[3].charAt(3)) + t, 16);408: green = toInt((t = rgb[3].charAt(2)) + t, 16);409: red = toInt((t = rgb[3].charAt(1)) + t, 16);410: }411: if (rgb[4]) {412: values = rgb[4][split](commaSpaces);413: red = toFloat(values[0]);414: values[0].slice(-1) == "%" && (red *= 2.55);415: green = toFloat(values[1]);416: values[1].slice(-1) == "%" && (green *= 2.55);417: blue = toFloat(values[2]);418: values[2].slice(-1) == "%" && (blue *= 2.55);419: rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity =

toFloat(values[3]));420: values[3] && values[3].slice(-1) == "%" && (opacity /= 100);421: }422: if (rgb[5]) {423: values = rgb[5][split](commaSpaces);424: red = toFloat(values[0]);425: values[0].slice(-1) == "%" && (red *= 2.55);426: green = toFloat(values[1]);427: values[1].slice(-1) == "%" && (green *= 2.55);428: blue = toFloat(values[2]);429: values[2].slice(-1) == "%" && (blue *= 2.55);430: (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") &&

(red /= 360);431: rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity =

toFloat(values[3]));432: values[3] && values[3].slice(-1) == "%" && (opacity /= 100);433: return R.hsb2rgb(red, green, blue, opacity);434: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 9: Raphael.js

Page:9/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

435: if (rgb[6]) {436: values = rgb[6][split](commaSpaces);437: red = toFloat(values[0]);438: values[0].slice(-1) == "%" && (red *= 2.55);439: green = toFloat(values[1]);440: values[1].slice(-1) == "%" && (green *= 2.55);441: blue = toFloat(values[2]);442: values[2].slice(-1) == "%" && (blue *= 2.55);443: (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") &&

(red /= 360);444: rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity =

toFloat(values[3]));445: values[3] && values[3].slice(-1) == "%" && (opacity /= 100);446: return R.hsl2rgb(red, green, blue, opacity);447: }448: rgb = {r: red, g: green, b: blue};449: rgb.hex = "#" + (16777216 | blue | (green << 8) | (red <<

16)).toString(16).slice(1);450: R.is(opacity, "finite") && (rgb.opacity = opacity);451: return rgb;452: }453: return {r: -1, g: -1, b: -1, hex: "none", error: 1};454: }, R);455: R.getColor = function (value) {456: var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b:

value || .75},457: rgb = this.hsb2rgb(start.h, start.s, start.b);458: start.h += .075;459: if (start.h > 1) {460: start.h = 0;461: start.s -= .2;462: start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b});463: }464: return rgb.hex;465: };466: R.getColor.reset = function () {467: delete this.start;468: }; // colour utilities end - start: 176469: // path utilities start - end: 1084470: R.parsePathString = cacher(function (pathString) {471: if (!pathString) {472: return null;473: }474: var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z:

0},475: data = [];476: if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough

assumption477: data = pathClone(pathString);478: }479: if (!data[length]) {480: Str(pathString)[rp](pathCommand, function (a, b, c) {481: var params = [],482: name = lowerCase.call(b);483: c[rp](pathValues, function (a, b) {484: b && params[push](+b);485: });486: if (name == "m" && params[length] > 2) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
Page 10: Raphael.js

Page:10/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

487: data[push]([b][concat](params.splice(0, 2)));488: name = "l";489: b = b == "m" ? "l" : "L";490: }491: while (params[length] >= paramCounts[name]) {492: data[push]([b][concat](params.splice(0, paramCounts[name])));493: if (!paramCounts[name]) {494: break;495: }496: }497: });498: }499: data[toString] = R._path2string;500: return data;501: });502: R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {503: var t1 = 1 - t,504: x = pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x

+ pow(t, 3) * p2x,505: y = pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y

+ pow(t, 3) * p2y,506: mx = p1x + 2 * t * (c1x - p1x) + t * t * (c2x - 2 * c1x + p1x),507: my = p1y + 2 * t * (c1y - p1y) + t * t * (c2y - 2 * c1y + p1y),508: nx = c1x + 2 * t * (c2x - c1x) + t * t * (p2x - 2 * c2x + c1x),509: ny = c1y + 2 * t * (c2y - c1y) + t * t * (p2y - 2 * c2y + c1y),510: ax = (1 - t) * p1x + t * c1x,511: ay = (1 - t) * p1y + t * c1y,512: cx = (1 - t) * c2x + t * p2x,513: cy = (1 - t) * c2y + t * p2y,514: alpha = (90 - math.atan((mx - nx) / (my - ny)) * 180 / PI);515: (mx > nx || my < ny) && (alpha += 180);516: return {x: x, y: y, m: {x: mx, y: my}, n: {x: nx, y: ny}, start: {x: ax, y:

ay}, end: {x: cx, y: cy}, alpha: alpha};517: };518: var pathDimensions = cacher(function (path) {519: if (!path) {520: return {x: 0, y: 0, width: 0, height: 0};521: }522: path = path2curve(path);523: var x = 0, 524: y = 0,525: X = [],526: Y = [],527: p;528: for (var i = 0, ii = path[length]; i < ii; i++) {529: p = path[i];530: if (p[0] == "M") {531: x = p[1];532: y = p[2];533: X[push](x);534: Y[push](y);535: } else {536: var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);537: X = X[concat](dim.min.x, dim.max.x);538: Y = Y[concat](dim.min.y, dim.max.y);539: x = p[5];540: y = p[6];541: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 11: Raphael.js

Page:11/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

542: }543: var xmin = mmin[apply](0, X),544: ymin = mmin[apply](0, Y);545: return {546: x: xmin,547: y: ymin,548: width: mmax[apply](0, X) - xmin,549: height: mmax[apply](0, Y) - ymin550: };551: }),552: pathClone = function (pathArray) {553: var res = [];554: if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array))

{ // rough assumption555: pathArray = R.parsePathString(pathArray);556: }557: for (var i = 0, ii = pathArray[length]; i < ii; i++) {558: res[i] = [];559: for (var j = 0, jj = pathArray[i][length]; j < jj; j++) {560: res[i][j] = pathArray[i][j];561: }562: }563: res[toString] = R._path2string;564: return res;565: },566: pathToRelative = cacher(function (pathArray) {567: if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array))

{ // rough assumption568: pathArray = R.parsePathString(pathArray);569: }570: var res = [],571: x = 0,572: y = 0,573: mx = 0,574: my = 0,575: start = 0;576: if (pathArray[0][0] == "M") {577: x = pathArray[0][1];578: y = pathArray[0][2];579: mx = x;580: my = y;581: start++;582: res[push](["M", x, y]);583: }584: for (var i = start, ii = pathArray[length]; i < ii; i++) {585: var r = res[i] = [],586: pa = pathArray[i];587: if (pa[0] != lowerCase.call(pa[0])) {588: r[0] = lowerCase.call(pa[0]);589: switch (r[0]) {590: case "a":591: r[1] = pa[1];592: r[2] = pa[2];593: r[3] = pa[3];594: r[4] = pa[4];595: r[5] = pa[5];596: r[6] = +(pa[6] - x).toFixed(3);597: r[7] = +(pa[7] - y).toFixed(3);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 12: Raphael.js

Page:12/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

598: break;599: case "v":600: r[1] = +(pa[1] - y).toFixed(3);601: break;602: case "m":603: mx = pa[1];604: my = pa[2];605: default:606: for (var j = 1, jj = pa[length]; j < jj; j++) {607: r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);608: }609: }610: } else {611: r = res[i] = [];612: if (pa[0] == "m") {613: mx = pa[1] + x;614: my = pa[2] + y;615: }616: for (var k = 0, kk = pa[length]; k < kk; k++) {617: res[i][k] = pa[k];618: }619: }620: var len = res[i][length];621: switch (res[i][0]) {622: case "z":623: x = mx;624: y = my;625: break;626: case "h":627: x += +res[i][len - 1];628: break;629: case "v":630: y += +res[i][len - 1];631: break;632: default:633: x += +res[i][len - 2];634: y += +res[i][len - 1];635: }636: }637: res[toString] = R._path2string;638: return res;639: }, 0, pathClone),640: pathToAbsolute = cacher(function (pathArray) {641: if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array))

{ // rough assumption642: pathArray = R.parsePathString(pathArray);643: }644: var res = [],645: x = 0,646: y = 0,647: mx = 0,648: my = 0,649: start = 0;650: if (pathArray[0][0] == "M") {651: x = +pathArray[0][1];652: y = +pathArray[0][2];653: mx = x;654: my = y;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 13: Raphael.js

Page:13/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

655: start++;656: res[0] = ["M", x, y];657: }658: for (var i = start, ii = pathArray[length]; i < ii; i++) {659: var r = res[i] = [],660: pa = pathArray[i];661: if (pa[0] != upperCase.call(pa[0])) {662: r[0] = upperCase.call(pa[0]);663: switch (r[0]) {664: case "A":665: r[1] = pa[1];666: r[2] = pa[2];667: r[3] = pa[3];668: r[4] = pa[4];669: r[5] = pa[5];670: r[6] = +(pa[6] + x);671: r[7] = +(pa[7] + y);672: break;673: case "V":674: r[1] = +pa[1] + y;675: break;676: case "H":677: r[1] = +pa[1] + x;678: break;679: case "M":680: mx = +pa[1] + x;681: my = +pa[2] + y;682: default:683: for (var j = 1, jj = pa[length]; j < jj; j++) {684: r[j] = +pa[j] + ((j % 2) ? x : y);685: }686: }687: } else {688: for (var k = 0, kk = pa[length]; k < kk; k++) {689: res[i][k] = pa[k];690: }691: }692: switch (r[0]) {693: case "Z":694: x = mx;695: y = my;696: break;697: case "H":698: x = r[1];699: break;700: case "V":701: y = r[1];702: break;703: case "M":704: mx = res[i][res[i][length] - 2];705: my = res[i][res[i][length] - 1];706: default:707: x = res[i][res[i][length] - 2];708: y = res[i][res[i][length] - 1];709: }710: }711: res[toString] = R._path2string;712: return res;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 14: Raphael.js

Page:14/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

713: }, null, pathClone),714: l2c = function (x1, y1, x2, y2) {715: return [x1, y1, x2, y2, x2, y2];716: },717: q2c = function (x1, y1, ax, ay, x2, y2) {718: var _13 = 1 / 3,719: _23 = 2 / 3;720: return [721: _13 * x1 + _23 * ax,722: _13 * y1 + _23 * ay,723: _13 * x2 + _23 * ax,724: _13 * y2 + _23 * ay,725: x2,726: y2727: ];728: },729: a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2,

recursive) {730: // for more information of where this math came from visit:731: // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes732: var _120 = PI * 120 / 180,733: rad = PI / 180 * (+angle || 0),734: res = [],735: xy,736: rotate = cacher(function (x, y, rad) {737: var X = x * math.cos(rad) - y * math.sin(rad),738: Y = x * math.sin(rad) + y * math.cos(rad);739: return {x: X, y: Y};740: });741: if (!recursive) {742: xy = rotate(x1, y1, -rad);743: x1 = xy.x;744: y1 = xy.y;745: xy = rotate(x2, y2, -rad);746: x2 = xy.x;747: y2 = xy.y;748: var cos = math.cos(PI / 180 * angle),749: sin = math.sin(PI / 180 * angle),750: x = (x1 - x2) / 2,751: y = (y1 - y2) / 2;752: var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);753: if (h > 1) {754: h = math.sqrt(h);755: rx = h * rx;756: ry = h * ry;757: }758: var rx2 = rx * rx,759: ry2 = ry * ry,760: k = (large_arc_flag == sweep_flag ? -1 : 1) *761: math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) /

(rx2 * y * y + ry2 * x * x))),762: cx = k * rx * y / ry + (x1 + x2) / 2,763: cy = k * -ry * x / rx + (y1 + y2) / 2,764: f1 = math.asin(((y1 - cy) / ry).toFixed(9)),765: f2 = math.asin(((y2 - cy) / ry).toFixed(9));766: 767: f1 = x1 < cx ? PI - f1 : f1;768: f2 = x2 < cx ? PI - f2 : f2;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 15: Raphael.js

Page:15/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

769: f1 < 0 && (f1 = PI * 2 + f1);770: f2 < 0 && (f2 = PI * 2 + f2);771: if (sweep_flag && f1 > f2) {772: f1 = f1 - PI * 2;773: }774: if (!sweep_flag && f2 > f1) {775: f2 = f2 - PI * 2;776: }777: } else {778: f1 = recursive[0];779: f2 = recursive[1];780: cx = recursive[2];781: cy = recursive[3];782: }783: var df = f2 - f1;784: if (abs(df) > _120) {785: var f2old = f2,786: x2old = x2,787: y2old = y2;788: f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);789: x2 = cx + rx * math.cos(f2);790: y2 = cy + ry * math.sin(f2);791: res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2,

f2old, cx, cy]);792: }793: df = f2 - f1;794: var c1 = math.cos(f1),795: s1 = math.sin(f1),796: c2 = math.cos(f2),797: s2 = math.sin(f2),798: t = math.tan(df / 4),799: hx = 4 / 3 * rx * t,800: hy = 4 / 3 * ry * t,801: m1 = [x1, y1],802: m2 = [x1 + hx * s1, y1 - hy * c1],803: m3 = [x2 + hx * s2, y2 - hy * c2],804: m4 = [x2, y2];805: m2[0] = 2 * m1[0] - m2[0];806: m2[1] = 2 * m1[1] - m2[1];807: if (recursive) {808: return [m2, m3, m4][concat](res);809: } else {810: res = [m2, m3, m4][concat](res)[join]()[split](",");811: var newres = [];812: for (var i = 0, ii = res[length]; i < ii; i++) {813: newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y :

rotate(res[i], res[i + 1], rad).x;814: }815: return newres;816: }817: },818: findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {819: var t1 = 1 - t;820: return {821: x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t *

c2x + pow(t, 3) * p2x,822: y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t *

c2y + pow(t, 3) * p2y

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 16: Raphael.js

Page:16/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

823: };824: },825: curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {826: var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),827: b = 2 * (c1x - p1x) - 2 * (c2x - c1x),828: c = p1x - c1x,829: t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a,830: t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a,831: y = [p1y, p2y],832: x = [p1x, p2x],833: dot;834: abs(t1) > "1e12" && (t1 = .5);835: abs(t2) > "1e12" && (t2 = .5);836: if (t1 > 0 && t1 < 1) {837: dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);838: x[push](dot.x);839: y[push](dot.y);840: }841: if (t2 > 0 && t2 < 1) {842: dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);843: x[push](dot.x);844: y[push](dot.y);845: }846: a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);847: b = 2 * (c1y - p1y) - 2 * (c2y - c1y);848: c = p1y - c1y;849: t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a;850: t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a;851: abs(t1) > "1e12" && (t1 = .5);852: abs(t2) > "1e12" && (t2 = .5);853: if (t1 > 0 && t1 < 1) {854: dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);855: x[push](dot.x);856: y[push](dot.y);857: }858: if (t2 > 0 && t2 < 1) {859: dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);860: x[push](dot.x);861: y[push](dot.y);862: }863: return {864: min: {x: mmin[apply](0, x), y: mmin[apply](0, y)},865: max: {x: mmax[apply](0, x), y: mmax[apply](0, y)}866: };867: }),868: path2curve = cacher(function (path, path2) {869: var p = pathToAbsolute(path),870: p2 = path2 && pathToAbsolute(path2),871: attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},872: attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},873: processPath = function (path, d) {874: var nx, ny;875: if (!path) {876: return ["C", d.x, d.y, d.x, d.y, d.x, d.y];877: }878: !(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null);879: switch (path[0]) {880: case "M":

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 17: Raphael.js

Page:17/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

881: d.X = path[1];882: d.Y = path[2];883: break;884: case "A":885: path = ["C"][concat](a2c[apply](0, [d.x,

d.y][concat](path.slice(1))));886: break;887: case "S":888: nx = d.x + (d.x - (d.bx || d.x));889: ny = d.y + (d.y - (d.by || d.y));890: path = ["C", nx, ny][concat](path.slice(1));891: break;892: case "T":893: d.qx = d.x + (d.x - (d.qx || d.x));894: d.qy = d.y + (d.y - (d.qy || d.y));895: path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1],

path[2]));896: break;897: case "Q":898: d.qx = path[1];899: d.qy = path[2];900: path = ["C"][concat](q2c(d.x, d.y, path[1], path[2],

path[3], path[4]));901: break;902: case "L":903: path = ["C"][concat](l2c(d.x, d.y, path[1], path[2]));904: break;905: case "H":906: path = ["C"][concat](l2c(d.x, d.y, path[1], d.y));907: break;908: case "V":909: path = ["C"][concat](l2c(d.x, d.y, d.x, path[1]));910: break;911: case "Z":912: path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y));913: break;914: }915: return path;916: },917: fixArc = function (pp, i) {918: if (pp[i][length] > 7) {919: pp[i].shift();920: var pi = pp[i];921: while (pi[length]) {922: pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6)));923: }924: pp.splice(i, 1);925: ii = mmax(p[length], p2 && p2[length] || 0);926: }927: },928: fixM = function (path1, path2, a1, a2, i) {929: if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M")

{930: path2.splice(i, 0, ["M", a2.x, a2.y]);931: a1.bx = 0;932: a1.by = 0;933: a1.x = path1[i][1];934: a1.y = path1[i][2];

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 18: Raphael.js

Page:18/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

935: ii = mmax(p[length], p2 && p2[length] || 0);936: }937: };938: for (var i = 0, ii = mmax(p[length], p2 && p2[length] || 0); i < ii;

i++) {939: p[i] = processPath(p[i], attrs);940: fixArc(p, i);941: p2 && (p2[i] = processPath(p2[i], attrs2));942: p2 && fixArc(p2, i);943: fixM(p, p2, attrs, attrs2, i);944: fixM(p2, p, attrs2, attrs, i);945: var seg = p[i],946: seg2 = p2 && p2[i],947: seglen = seg[length],948: seg2len = p2 && seg2[length];949: attrs.x = seg[seglen - 2];950: attrs.y = seg[seglen - 1];951: attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;952: attrs.by = toFloat(seg[seglen - 3]) || attrs.y;953: attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);954: attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);955: attrs2.x = p2 && seg2[seg2len - 2];956: attrs2.y = p2 && seg2[seg2len - 1];957: }958: return p2 ? [p, p2] : p;959: }, null, pathClone),960: parseDots = cacher(function (gradient) {961: var dots = [];962: for (var i = 0, ii = gradient[length]; i < ii; i++) {963: var dot = {},964: par = gradient[i].match(/^([^:]*):?([\d\.]*)/);965: dot.color = R.getRGB(par[1]);966: if (dot.color.error) {967: return null;968: }969: dot.color = dot.color.hex;970: par[2] && (dot.offset = par[2] + "%");971: dots[push](dot);972: }973: for (i = 1, ii = dots[length] - 1; i < ii; i++) {974: if (!dots[i].offset) {975: var start = toFloat(dots[i - 1].offset || 0),976: end = 0;977: for (var j = i + 1; j < ii; j++) {978: if (dots[j].offset) {979: end = dots[j].offset;980: break;981: }982: }983: if (!end) {984: end = 100;985: j = ii;986: }987: end = toFloat(end);988: var d = (end - start) / (j - i + 1);989: for (; i < j; i++) {990: start += d;991: dots[i].offset = start + "%";

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 19: Raphael.js

Page:19/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

992: }993: }994: }995: return dots;996: }),997: getContainer = function (x, y, w, h) {998: var container;999: if (R.is(x, string) || R.is(x, "object")) {1000: container = R.is(x, string) ? doc.getElementById(x) : x;1001: if (container.tagName) {1002: if (y == null) {1003: return {1004: container: container,1005: width: container.style.pixelWidth ||

container.offsetWidth,1006: height: container.style.pixelHeight ||

container.offsetHeight1007: };1008: } else {1009: return {container: container, width: y, height: w};1010: }1011: }1012: } else {1013: return {container: 1, x: x, y: y, width: w, height: h};1014: }1015: },1016: plugins = function (con, add) {1017: var that = this;1018: for (var prop in add) {1019: if (add[has](prop) && !(prop in con)) {1020: switch (typeof add[prop]) {1021: case "function":1022: (function (f) {1023: con[prop] = con === that ? f : function () { return

f[apply](that, arguments); };1024: })(add[prop]);1025: break;1026: case "object":1027: con[prop] = con[prop] || {};1028: plugins.call(this, con[prop], add[prop]);1029: break;1030: default:1031: con[prop] = add[prop];1032: break;1033: }1034: }1035: }1036: },1037: tear = function (el, paper) {1038: el == paper.top && (paper.top = el.prev);1039: el == paper.bottom && (paper.bottom = el.next);1040: el.next && (el.next.prev = el.prev);1041: el.prev && (el.prev.next = el.next);1042: },1043: tofront = function (el, paper) {1044: if (paper.top === el) {1045: return;1046: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 20: Raphael.js

Page:20/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1047: tear(el, paper);1048: el.next = null;1049: el.prev = paper.top;1050: paper.top.next = el;1051: paper.top = el;1052: },1053: toback = function (el, paper) {1054: if (paper.bottom === el) {1055: return;1056: }1057: tear(el, paper);1058: el.next = paper.bottom;1059: el.prev = null;1060: paper.bottom.prev = el;1061: paper.bottom = el;1062: },1063: insertafter = function (el, el2, paper) {1064: tear(el, paper);1065: el2 == paper.top && (paper.top = el);1066: el2.next && (el2.next.prev = el);1067: el.next = el2.next;1068: el.prev = el2;1069: el2.next = el;1070: },1071: insertbefore = function (el, el2, paper) {1072: tear(el, paper);1073: el2 == paper.bottom && (paper.bottom = el);1074: el2.prev && (el2.prev.next = el);1075: el.prev = el2.prev;1076: el2.prev = el;1077: el.next = el2;1078: },1079: removed = function (methodname) {1080: return function () {1081: throw new Error("Rapha\xebl: you are calling to method \u201c" +

methodname + "\u201d of removed object");1082: };1083: };1084: R.pathToRelative = pathToRelative; // path utilities end - start:

4691085: // SVG start - end: 18231086: if (R.svg) {1087: paperproto.svgns = "http://www.w3.org/2000/svg";1088: paperproto.xlink = "http://www.w3.org/1999/xlink";1089: round = function (num) {1090: return +num + (~~num === num) * .5;1091: };1092: var $ = function (el, attr) {1093: if (attr) {1094: for (var key in attr) {1095: if (attr[has](key)) {1096: el[setAttribute](key, Str(attr[key]));1097: }1098: }1099: } else {1100: el = doc.createElementNS(paperproto.svgns, el);1101: el.style.webkitTapHighlightColor = "rgba(0,0,0,0)";1102: return el;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
Page 21: Raphael.js

Page:21/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1103: }1104: };1105: R[toString] = function () {1106: return "Your browser supports SVG.\nYou are running Rapha\xebl " +

this.version;1107: };1108: var thePath = function (pathString, SVG) {1109: var el = $("path");1110: SVG.canvas && SVG.canvas[appendChild](el);1111: var p = new Element(el, SVG);1112: p.type = "path";1113: setFillAndStroke(p, {fill: "none", stroke: "#000", path: pathString});1114: return p;1115: };1116: var addGradientFill = function (o, gradient, SVG) {1117: var type = "linear",1118: fx = .5, fy = .5,1119: s = o.style;1120: gradient = Str(gradient)[rp](radial_gradient, function (all, _fx, _fy) {1121: type = "radial";1122: if (_fx && _fy) {1123: fx = toFloat(_fx);1124: fy = toFloat(_fy);1125: var dir = ((fy > .5) * 2 - 1);1126: pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&1127: (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&1128: fy != .5 &&1129: (fy = fy.toFixed(5) - 1e-5 * dir);1130: }1131: return E;1132: });1133: gradient = gradient[split](/\s*\-\s*/);1134: if (type == "linear") {1135: var angle = gradient.shift();1136: angle = -toFloat(angle);1137: if (isNaN(angle)) {1138: return null;1139: }1140: var vector = [0, 0, math.cos(angle * PI / 180), math.sin(angle * PI

/ 180)],1141: max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);1142: vector[2] *= max;1143: vector[3] *= max;1144: if (vector[2] < 0) {1145: vector[0] = -vector[2];1146: vector[2] = 0;1147: }1148: if (vector[3] < 0) {1149: vector[1] = -vector[3];1150: vector[3] = 0;1151: }1152: }1153: var dots = parseDots(gradient);1154: if (!dots) {1155: return null;1156: }1157: var id = o.getAttribute(fillString);1158: id = id.match(/^url\(#(.*)\)$/);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 22: Raphael.js

Page:22/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1159: id && SVG.defs.removeChild(doc.getElementById(id[1]));1160: 1161: var el = $(type + "Gradient");1162: el.id = createUUID();1163: $(el, type == "radial" ? {fx: fx, fy: fy} : {x1: vector[0], y1:

vector[1], x2: vector[2], y2: vector[3]});1164: SVG.defs[appendChild](el);1165: for (var i = 0, ii = dots[length]; i < ii; i++) {1166: var stop = $("stop");1167: $(stop, {1168: offset: dots[i].offset ? dots[i].offset : !i ? "0%" : "100%",1169: "stop-color": dots[i].color || "#fff"1170: });1171: el[appendChild](stop);1172: }1173: $(o, {1174: fill: "url(#" + el.id + ")",1175: opacity: 1,1176: "fill-opacity": 11177: });1178: s.fill = E;1179: s.opacity = 1;1180: s.fillOpacity = 1;1181: return 1;1182: };1183: var updatePosition = function (o) {1184: var bbox = o.getBBox();1185: $(o.pattern, {patternTransform: R.format("translate({0},{1})", bbox.x,

bbox.y)});1186: };1187: var setFillAndStroke = function (o, params) {1188: var dasharray = {1189: "": [0],1190: "none": [0],1191: "-": [3, 1],1192: ".": [1, 1],1193: "-.": [3, 1, 1, 1],1194: "-..": [3, 1, 1, 1, 1, 1],1195: ". ": [1, 3],1196: "- ": [4, 3],1197: "--": [8, 3],1198: "- .": [4, 3, 1, 3],1199: "--.": [8, 3, 1, 3],1200: "--..": [8, 3, 1, 3, 1, 3]1201: },1202: node = o.node,1203: attrs = o.attrs,1204: rot = o.rotate(),1205: addDashes = function (o, value) {1206: value = dasharray[lowerCase.call(value)];1207: if (value) {1208: var width = o.attrs["stroke-width"] || "1",1209: butt = {round: width, square: width, butt:

0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,1210: dashes = [];1211: var i = value[length];1212: while (i--) {1213: dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) *

butt;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 23: Raphael.js

Page:23/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1214: }1215: $(node, {"stroke-dasharray": dashes[join](",")});1216: }1217: };1218: params[has]("rotation") && (rot = params.rotation);1219: var rotxy = Str(rot)[split](separator);1220: if (!(rotxy.length - 1)) {1221: rotxy = null;1222: } else {1223: rotxy[1] = +rotxy[1];1224: rotxy[2] = +rotxy[2];1225: }1226: toFloat(rot) && o.rotate(0, true);1227: for (var att in params) {1228: if (params[has](att)) {1229: if (!availableAttrs[has](att)) {1230: continue;1231: }1232: var value = params[att];1233: attrs[att] = value;1234: switch (att) {1235: case "blur":1236: o.blur(value);1237: break;1238: case "rotation":1239: o.rotate(value, true);1240: break;1241: case "href":1242: case "title":1243: case "target":1244: var pn = node.parentNode;1245: if (lowerCase.call(pn.tagName) != "a") {1246: var hl = $("a");1247: pn.insertBefore(hl, node);1248: hl[appendChild](node);1249: pn = hl;1250: }1251: if (att == "target" && value == "blank") {1252: pn.setAttributeNS(o.paper.xlink, "show", "new");1253: } else {1254: pn.setAttributeNS(o.paper.xlink, att, value);1255: }1256: break;1257: case "cursor":1258: node.style.cursor = value;1259: break;1260: case "clip-rect":1261: var rect = Str(value)[split](separator);1262: if (rect[length] == 4) {1263: o.clip &&

o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);1264: var el = $("clipPath"),1265: rc = $("rect");1266: el.id = createUUID();1267: $(rc, {1268: x: rect[0],1269: y: rect[1],1270: width: rect[2],

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 24: Raphael.js

Page:24/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1271: height: rect[3]1272: });1273: el[appendChild](rc);1274: o.paper.defs[appendChild](el);1275: $(node, {"clip-path": "url(#" + el.id + ")"});1276: o.clip = rc;1277: }1278: if (!value) {1279: var clip =

doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g, E));1280: clip && clip.parentNode.removeChild(clip);1281: $(node, {"clip-path": E});1282: delete o.clip;1283: }1284: break;1285: case "path":1286: if (o.type == "path") {1287: $(node, {d: value ? attrs.path =

pathToAbsolute(value) : "M0,0"});1288: }1289: break;1290: case "width":1291: node[setAttribute](att, value);1292: if (attrs.fx) {1293: att = "x";1294: value = attrs.x;1295: } else {1296: break;1297: }1298: case "x":1299: if (attrs.fx) {1300: value = -attrs.x - (attrs.width || 0);1301: }1302: case "rx":1303: if (att == "rx" && o.type == "rect") {1304: break;1305: }1306: case "cx":1307: rotxy && (att == "x" || att == "cx") && (rotxy[1] +=

value - attrs[att]);1308: node[setAttribute](att, value);1309: o.pattern && updatePosition(o);1310: break;1311: case "height":1312: node[setAttribute](att, value);1313: if (attrs.fy) {1314: att = "y";1315: value = attrs.y;1316: } else {1317: break;1318: }1319: case "y":1320: if (attrs.fy) {1321: value = -attrs.y - (attrs.height || 0);1322: }1323: case "ry":1324: if (att == "ry" && o.type == "rect") {1325: break;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 25: Raphael.js

Page:25/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1326: }1327: case "cy":1328: rotxy && (att == "y" || att == "cy") && (rotxy[2] +=

value - attrs[att]);1329: node[setAttribute](att, value);1330: o.pattern && updatePosition(o);1331: break;1332: case "r":1333: if (o.type == "rect") {1334: $(node, {rx: value, ry: value});1335: } else {1336: node[setAttribute](att, value);1337: }1338: break;1339: case "src":1340: if (o.type == "image") {1341: node.setAttributeNS(o.paper.xlink, "href", value);1342: }1343: break;1344: case "stroke-width":1345: node.style.strokeWidth = value;1346: // Need following line for Firefox1347: node[setAttribute](att, value);1348: if (attrs["stroke-dasharray"]) {1349: addDashes(o, attrs["stroke-dasharray"]);1350: }1351: break;1352: case "stroke-dasharray":1353: addDashes(o, value);1354: break;1355: case "translation":1356: var xy = Str(value)[split](separator);1357: xy[0] = +xy[0] || 0;1358: xy[1] = +xy[1] || 0;1359: if (rotxy) {1360: rotxy[1] += xy[0];1361: rotxy[2] += xy[1];1362: }1363: translate.call(o, xy[0], xy[1]);1364: break;1365: case "scale":1366: xy = Str(value)[split](separator);1367: o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1,

isNaN(toFloat(xy[2])) ? null : +xy[2], isNaN(toFloat(xy[3])) ? null : +xy[3]);1368: break;1369: case fillString:1370: var isURL = Str(value).match(ISURL);1371: if (isURL) {1372: el = $("pattern");1373: var ig = $("image");1374: el.id = createUUID();1375: $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse",

height: 1, width: 1});1376: $(ig, {x: 0, y: 0});1377: ig.setAttributeNS(o.paper.xlink, "href", isURL[1]);1378: el[appendChild](ig);1379: 1380: var img = doc.createElement("img");

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 26: Raphael.js

Page:26/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1381: img.style.cssText = "position:absolute;left:-9999em;top-9999em";

1382: img.onload = function () {1383: $(el, {width: this.offsetWidth, height:

this.offsetHeight});1384: $(ig, {width: this.offsetWidth, height:

this.offsetHeight});1385: doc.body.removeChild(this);1386: o.paper.safari();1387: };1388: doc.body[appendChild](img);1389: img.src = isURL[1];1390: o.paper.defs[appendChild](el);1391: node.style.fill = "url(#" + el.id + ")";1392: $(node, {fill: "url(#" + el.id + ")"});1393: o.pattern = el;1394: o.pattern && updatePosition(o);1395: break;1396: }1397: var clr = R.getRGB(value);1398: if (!clr.error) {1399: delete params.gradient;1400: delete attrs.gradient;1401: !R.is(attrs.opacity, "undefined") &&1402: R.is(params.opacity, "undefined") &&1403: $(node, {opacity: attrs.opacity});1404: !R.is(attrs["fill-opacity"], "undefined") &&1405: R.is(params["fill-opacity"], "undefined") &&1406: $(node, {"fill-opacity": attrs["fill-

opacity"]});1407: } else if ((({circle: 1, ellipse: 1})[has](o.type) ||

Str(value).charAt() != "r") && addGradientFill(node, value, o.paper)) {1408: attrs.gradient = value;1409: attrs.fill = "none";1410: break;1411: }1412: clr[has]("opacity") && $(node, {"fill-opacity":

clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});1413: case "stroke":1414: clr = R.getRGB(value);1415: node[setAttribute](att, clr.hex);1416: att == "stroke" && clr[has]("opacity") && $(node,

{"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});1417: break;1418: case "gradient":1419: (({circle: 1, ellipse: 1})[has](o.type) ||

Str(value).charAt() != "r") && addGradientFill(node, value, o.paper);1420: break;1421: case "opacity":1422: if (attrs.gradient && !attrs[has]("stroke-opacity")) {1423: $(node, {"stroke-opacity": value > 1 ? value / 100

: value});1424: }1425: // fall1426: case "fill-opacity":1427: if (attrs.gradient) {1428: var gradient =

doc.getElementById(node.getAttribute(fillString)[rp](/^url\(#|\)$/g, E));

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 27: Raphael.js

Page:27/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1429: if (gradient) {1430: var stops =

gradient.getElementsByTagName("stop");1431: stops[stops[length] - 1][setAttribute]("stop-

opacity", value);1432: }1433: break;1434: }1435: default:1436: att == "font-size" && (value = toInt(value, 10) + "px");1437: var cssrule = att[rp](/(\-.)/g, function (w) {1438: return upperCase.call(w.substring(1));1439: });1440: node.style[cssrule] = value;1441: // Need following line for Firefox1442: node[setAttribute](att, value);1443: break;1444: }1445: }1446: }1447: 1448: tuneText(o, params);1449: if (rotxy) {1450: o.rotate(rotxy.join(S));1451: } else {1452: toFloat(rot) && o.rotate(rot, true);1453: }1454: };1455: var leading = 1.2,1456: tuneText = function (el, params) {1457: if (el.type != "text" || !(params[has]("text") || params[has]("font")

|| params[has]("font-size") || params[has]("x") || params[has]("y"))) {1458: return;1459: }1460: var a = el.attrs,1461: node = el.node,1462: fontSize = node.firstChild ?

toInt(doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue(size"), 10) : 10;

1463: 1464: if (params[has]("text")) {1465: a.text = params.text;1466: while (node.firstChild) {1467: node.removeChild(node.firstChild);1468: }1469: var texts = Str(params.text)[split]("\n");1470: for (var i = 0, ii = texts[length]; i < ii; i++) if (texts[i]) {1471: var tspan = $("tspan");1472: i && $(tspan, {dy: fontSize * leading, x: a.x});1473: tspan[appendChild](doc.createTextNode(texts[i]));1474: node[appendChild](tspan);1475: }1476: } else {1477: texts = node.getElementsByTagName("tspan");1478: for (i = 0, ii = texts[length]; i < ii; i++) {1479: i && $(texts[i], {dy: fontSize * leading, x: a.x});1480: }1481: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 28: Raphael.js

Page:28/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1482: $(node, {y: a.y});1483: var bb = el.getBBox(),1484: dif = a.y - (bb.y + bb.height / 2);1485: dif && R.is(dif, "finite") && $(node, {y: a.y + dif});1486: },1487: Element = function (node, svg) {1488: var X = 0,1489: Y = 0;1490: this[0] = node;1491: this.id = R._oid++;1492: this.node = node;1493: node.raphael = this;1494: this.paper = svg;1495: this.attrs = this.attrs || {};1496: this.transformations = []; // rotate, translate, scale1497: this._ = {1498: tx: 0,1499: ty: 0,1500: rt: {deg: 0, cx: 0, cy: 0},1501: sx: 1,1502: sy: 11503: };1504: !svg.bottom && (svg.bottom = this);1505: this.prev = svg.top;1506: svg.top && (svg.top.next = this);1507: svg.top = this;1508: this.next = null;1509: };1510: var elproto = Element[proto];1511: Element[proto].rotate = function (deg, cx, cy) {1512: if (this.removed) {1513: return this;1514: }1515: if (deg == null) {1516: if (this._.rt.cx) {1517: return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S);1518: }1519: return this._.rt.deg;1520: }1521: var bbox = this.getBBox();1522: deg = Str(deg)[split](separator);1523: if (deg[length] - 1) {1524: cx = toFloat(deg[1]);1525: cy = toFloat(deg[2]);1526: }1527: deg = toFloat(deg[0]);1528: if (cx != null && cx !== false) {1529: this._.rt.deg = deg;1530: } else {1531: this._.rt.deg += deg;1532: }1533: (cy == null) && (cx = null);1534: this._.rt.cx = cx;1535: this._.rt.cy = cy;1536: cx = cx == null ? bbox.x + bbox.width / 2 : cx;1537: cy = cy == null ? bbox.y + bbox.height / 2 : cy;1538: if (this._.rt.deg) {1539: this.transformations[0] = R.format("rotate({0} {1} {2})",

this._.rt.deg, cx, cy);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 29: Raphael.js

Page:29/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1540: this.clip && $(this.clip, {transform: R.format("rotate({0} {1} {2})", -this._.rt.deg, cx, cy)});

1541: } else {1542: this.transformations[0] = E;1543: this.clip && $(this.clip, {transform: E});1544: }1545: $(this.node, {transform: this.transformations[join](S)});1546: return this;1547: };1548: Element[proto].hide = function () {1549: !this.removed && (this.node.style.display = "none");1550: return this;1551: };1552: Element[proto].show = function () {1553: !this.removed && (this.node.style.display = "");1554: return this;1555: };1556: Element[proto].remove = function () {1557: if (this.removed) {1558: return;1559: }1560: tear(this, this.paper);1561: this.node.parentNode.removeChild(this.node);1562: for (var i in this) {1563: delete this[i];1564: }1565: this.removed = true;1566: };1567: Element[proto].getBBox = function () {1568: if (this.removed) {1569: return this;1570: }1571: if (this.type == "path") {1572: return pathDimensions(this.attrs.path);1573: }1574: if (this.node.style.display == "none") {1575: this.show();1576: var hide = true;1577: }1578: var bbox = {};1579: try {1580: bbox = this.node.getBBox();1581: } catch(e) {1582: // Firefox 3.0.x plays badly here1583: } finally {1584: bbox = bbox || {};1585: }1586: if (this.type == "text") {1587: bbox = {x: bbox.x, y: Infinity, width: 0, height: 0};1588: for (var i = 0, ii = this.node.getNumberOfChars(); i < ii; i++) {1589: var bb = this.node.getExtentOfChar(i);1590: (bb.y < bbox.y) && (bbox.y = bb.y);1591: (bb.y + bb.height - bbox.y > bbox.height) && (bbox.height =

bb.y + bb.height - bbox.y);1592: (bb.x + bb.width - bbox.x > bbox.width) && (bbox.width = bb.x +

bb.width - bbox.x);1593: }1594: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 30: Raphael.js

Page:30/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1595: hide && this.hide();1596: return bbox;1597: };1598: Element[proto].attr = function (name, value) {1599: if (this.removed) {1600: return this;1601: }1602: if (name == null) {1603: var res = {};1604: for (var i in this.attrs) if (this.attrs[has](i)) {1605: res[i] = this.attrs[i];1606: }1607: this._.rt.deg && (res.rotation = this.rotate());1608: (this._.sx != 1 || this._.sy != 1) && (res.scale = this.scale());1609: res.gradient && res.fill == "none" && (res.fill = res.gradient) &&

delete res.gradient;1610: return res;1611: }1612: if (value == null && R.is(name, string)) {1613: if (name == "translation") {1614: return translate.call(this);1615: }1616: if (name == "rotation") {1617: return this.rotate();1618: }1619: if (name == "scale") {1620: return this.scale();1621: }1622: if (name == fillString && this.attrs.fill == "none" &&

this.attrs.gradient) {1623: return this.attrs.gradient;1624: }1625: return this.attrs[name];1626: }1627: if (value == null && R.is(name, array)) {1628: var values = {};1629: for (var j = 0, jj = name.length; j < jj; j++) {1630: values[name[j]] = this.attr(name[j]);1631: }1632: return values;1633: }1634: if (value != null) {1635: var params = {};1636: params[name] = value;1637: } else if (name != null && R.is(name, "object")) {1638: params = name;1639: }1640: for (var key in this.paper.customAttributes) if

(this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {

1641: var par = this.paper.customAttributes[key].apply(this, [][concat](params[key]));

1642: this.attrs[key] = params[key];1643: for (var subkey in par) if (par[has](subkey)) {1644: params[subkey] = par[subkey];1645: }1646: }1647: setFillAndStroke(this, params);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 31: Raphael.js

Page:31/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1648: return this;1649: };1650: Element[proto].toFront = function () {1651: if (this.removed) {1652: return this;1653: }1654: this.node.parentNode[appendChild](this.node);1655: var svg = this.paper;1656: svg.top != this && tofront(this, svg);1657: return this;1658: };1659: Element[proto].toBack = function () {1660: if (this.removed) {1661: return this;1662: }1663: if (this.node.parentNode.firstChild != this.node) {1664: this.node.parentNode.insertBefore(this.node,

this.node.parentNode.firstChild);1665: toback(this, this.paper);1666: var svg = this.paper;1667: }1668: return this;1669: };1670: Element[proto].insertAfter = function (element) {1671: if (this.removed) {1672: return this;1673: }1674: var node = element.node || element[element.length - 1].node;1675: if (node.nextSibling) {1676: node.parentNode.insertBefore(this.node, node.nextSibling);1677: } else {1678: node.parentNode[appendChild](this.node);1679: }1680: insertafter(this, element, this.paper);1681: return this;1682: };1683: Element[proto].insertBefore = function (element) {1684: if (this.removed) {1685: return this;1686: }1687: var node = element.node || element[0].node;1688: node.parentNode.insertBefore(this.node, node);1689: insertbefore(this, element, this.paper);1690: return this;1691: };1692: Element[proto].blur = function (size) {1693: // Experimental. No Safari support. Use it on your own risk.1694: var t = this;1695: if (+size !== 0) {1696: var fltr = $("filter"),1697: blur = $("feGaussianBlur");1698: t.attrs.blur = size;1699: fltr.id = createUUID();1700: $(blur, {stdDeviation: +size || 1.5});1701: fltr.appendChild(blur);1702: t.paper.defs.appendChild(fltr);1703: t._blur = fltr;1704: $(t.node, {filter: "url(#" + fltr.id + ")"});

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 32: Raphael.js

Page:32/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1705: } else {1706: if (t._blur) {1707: t._blur.parentNode.removeChild(t._blur);1708: delete t._blur;1709: delete t.attrs.blur;1710: }1711: t.node.removeAttribute("filter");1712: }1713: };1714: var theCircle = function (svg, x, y, r) {1715: var el = $("circle");1716: svg.canvas && svg.canvas[appendChild](el);1717: var res = new Element(el, svg);1718: res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"};1719: res.type = "circle";1720: $(el, res.attrs);1721: return res;1722: },1723: theRect = function (svg, x, y, w, h, r) {1724: var el = $("rect");1725: svg.canvas && svg.canvas[appendChild](el);1726: var res = new Element(el, svg);1727: res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0,

ry: r || 0, fill: "none", stroke: "#000"};1728: res.type = "rect";1729: $(el, res.attrs);1730: return res;1731: },1732: theEllipse = function (svg, x, y, rx, ry) {1733: var el = $("ellipse");1734: svg.canvas && svg.canvas[appendChild](el);1735: var res = new Element(el, svg);1736: res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke:

"#000"};1737: res.type = "ellipse";1738: $(el, res.attrs);1739: return res;1740: },1741: theImage = function (svg, src, x, y, w, h) {1742: var el = $("image");1743: $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"});1744: el.setAttributeNS(svg.xlink, "href", src);1745: svg.canvas && svg.canvas[appendChild](el);1746: var res = new Element(el, svg);1747: res.attrs = {x: x, y: y, width: w, height: h, src: src};1748: res.type = "image";1749: return res;1750: },1751: theText = function (svg, x, y, text) {1752: var el = $("text");1753: $(el, {x: x, y: y, "text-anchor": "middle"});1754: svg.canvas && svg.canvas[appendChild](el);1755: var res = new Element(el, svg);1756: res.attrs = {x: x, y: y, "text-anchor": "middle", text: text, font:

availableAttrs.font, stroke: "none", fill: "#000"};1757: res.type = "text";1758: setFillAndStroke(res, res.attrs);1759: return res;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 33: Raphael.js

Page:33/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1760: },1761: setSize = function (width, height) {1762: this.width = width || this.width;1763: this.height = height || this.height;1764: this.canvas[setAttribute]("width", this.width);1765: this.canvas[setAttribute]("height", this.height);1766: return this;1767: },1768: create = function () {1769: var con = getContainer[apply](0, arguments),1770: container = con && con.container,1771: x = con.x,1772: y = con.y,1773: width = con.width,1774: height = con.height;1775: if (!container) {1776: throw new Error("SVG container not found.");1777: }1778: var cnvs = $("svg");1779: x = x || 0;1780: y = y || 0;1781: width = width || 512;1782: height = height || 342;1783: $(cnvs, {1784: xmlns: "http://www.w3.org/2000/svg",1785: version: 1.1,1786: width: width,1787: height: height1788: });1789: if (container == 1) {1790: cnvs.style.cssText = "position:absolute;left:" + x + "px;top:" + y

+ "px";1791: doc.body[appendChild](cnvs);1792: } else {1793: if (container.firstChild) {1794: container.insertBefore(cnvs, container.firstChild);1795: } else {1796: container[appendChild](cnvs);1797: }1798: }1799: container = new Paper;1800: container.width = width;1801: container.height = height;1802: container.canvas = cnvs;1803: plugins.call(container, container, R.fn);1804: container.clear();1805: return container;1806: };1807: paperproto.clear = function () {1808: var c = this.canvas;1809: while (c.firstChild) {1810: c.removeChild(c.firstChild);1811: }1812: this.bottom = this.top = null;1813: (this.desc = $("desc"))[appendChild](doc.createTextNode("Created with

Rapha\xebl"));1814: c[appendChild](this.desc);1815: c[appendChild](this.defs = $("defs"));

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 34: Raphael.js

Page:34/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1816: };1817: paperproto.remove = function () {1818: this.canvas.parentNode &&

this.canvas.parentNode.removeChild(this.canvas);1819: for (var i in this) {1820: this[i] = removed(i);1821: }1822: };1823: } // SVG end - start: 10851824: 1825: // VML start - end: 26271826: if (R.vml) {1827: var map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"},1828: bites = /([clmz]),?([^clmz]*)/gi,1829: blurregexp = / progid:\S+Blur\([^\)]+\)/g,1830: val = /-?[^,\s-]+/g,1831: coordsize = 1e3 + S + 1e3,1832: zoom = 10,1833: pathlike = {path: 1, rect: 1},1834: path2vml = function (path) {1835: var total = /[ahqstv]/ig,1836: command = pathToAbsolute;1837: Str(path).match(total) && (command = path2curve);1838: total = /[clmz]/g;1839: if (command == pathToAbsolute && !Str(path).match(total)) {1840: var res = Str(path)[rp](bites, function (all, command, args) {1841: var vals = [],1842: isMove = lowerCase.call(command) == "m",1843: res = map[command];1844: args[rp](val, function (value) {1845: if (isMove && vals[length] == 2) {1846: res += vals + map[command == "m" ? "l" : "L"];1847: vals = [];1848: }1849: vals[push](round(value * zoom));1850: });1851: return res + vals;1852: });1853: return res;1854: }1855: var pa = command(path), p, r;1856: res = [];1857: for (var i = 0, ii = pa[length]; i < ii; i++) {1858: p = pa[i];1859: r = lowerCase.call(pa[i][0]);1860: r == "z" && (r = "x");1861: for (var j = 1, jj = p[length]; j < jj; j++) {1862: r += round(p[j] * zoom) + (j != jj - 1 ? "," : E);1863: }1864: res[push](r);1865: }1866: return res[join](S);1867: };1868: 1869: R[toString] = function () {1870: return "Your browser doesn\u2019t support SVG. Falling down to

VML.\nYou are running Rapha\xebl " + this.version;1871: };

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
Page 35: Raphael.js

Page:35/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1872: thePath = function (pathString, vml) {1873: var g = createNode("group");1874: g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width +

"px;height:" + vml.height + "px";1875: g.coordsize = vml.coordsize;1876: g.coordorigin = vml.coordorigin;1877: var el = createNode("shape"), ol = el.style;1878: ol.width = vml.width + "px";1879: ol.height = vml.height + "px";1880: el.coordsize = coordsize;1881: el.coordorigin = vml.coordorigin;1882: g[appendChild](el);1883: var p = new Element(el, g, vml),1884: attr = {fill: "none", stroke: "#000"};1885: pathString && (attr.path = pathString);1886: p.type = "path";1887: p.path = [];1888: p.Path = E;1889: setFillAndStroke(p, attr);1890: vml.canvas[appendChild](g);1891: return p;1892: };1893: setFillAndStroke = function (o, params) {1894: o.attrs = o.attrs || {};1895: var node = o.node,1896: a = o.attrs,1897: s = node.style,1898: xy,1899: newpath = (params.x != a.x || params.y != a.y || params.width !=

a.width || params.height != a.height || params.r != a.r) && o.type == "rect",1900: res = o;1901: 1902: for (var par in params) if (params[has](par)) {1903: a[par] = params[par];1904: }1905: if (newpath) {1906: a.path = rectPath(a.x, a.y, a.width, a.height, a.r);1907: o.X = a.x;1908: o.Y = a.y;1909: o.W = a.width;1910: o.H = a.height;1911: }1912: params.href && (node.href = params.href);1913: params.title && (node.title = params.title);1914: params.target && (node.target = params.target);1915: params.cursor && (s.cursor = params.cursor);1916: "blur" in params && o.blur(params.blur);1917: if (params.path && o.type == "path" || newpath) {1918: node.path = path2vml(a.path);1919: }1920: if (params.rotation != null) {1921: o.rotate(params.rotation, true);1922: }1923: if (params.translation) {1924: xy = Str(params.translation)[split](separator);1925: translate.call(o, xy[0], xy[1]);1926: if (o._.rt.cx != null) {1927: o._.rt.cx +=+ xy[0];

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 36: Raphael.js

Page:36/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1928: o._.rt.cy +=+ xy[1];1929: o.setBox(o.attrs, xy[0], xy[1]);1930: }1931: }1932: if (params.scale) {1933: xy = Str(params.scale)[split](separator);1934: o.scale(+xy[0] || 1, +xy[1] || +xy[0] || 1, +xy[2] || null, +xy[3]

|| null);1935: }1936: if ("clip-rect" in params) {1937: var rect = Str(params["clip-rect"])[split](separator);1938: if (rect[length] == 4) {1939: rect[2] = +rect[2] + (+rect[0]);1940: rect[3] = +rect[3] + (+rect[1]);1941: var div = node.clipRect || doc.createElement("div"),1942: dstyle = div.style,1943: group = node.parentNode;1944: dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect);1945: if (!node.clipRect) {1946: dstyle.position = "absolute";1947: dstyle.top = 0;1948: dstyle.left = 0;1949: dstyle.width = o.paper.width + "px";1950: dstyle.height = o.paper.height + "px";1951: group.parentNode.insertBefore(div, group);1952: div[appendChild](group);1953: node.clipRect = div;1954: }1955: }1956: if (!params["clip-rect"]) {1957: node.clipRect && (node.clipRect.style.clip = E);1958: }1959: }1960: if (o.type == "image" && params.src) {1961: node.src = params.src;1962: }1963: if (o.type == "image" && params.opacity) {1964: node.filterOpacity = ms + ".Alpha(opacity=" + (params.opacity *

100) + ")";1965: s.filter = (node.filterMatrix || E) + (node.filterOpacity || E);1966: }1967: params.font && (s.font = params.font);1968: params["font-family"] && (s.fontFamily = '"' + params["font-

family"][split](",")[0][rp](/^['"]+|['"]+$/g, E) + '"');1969: params["font-size"] && (s.fontSize = params["font-size"]);1970: params["font-weight"] && (s.fontWeight = params["font-weight"]);1971: params["font-style"] && (s.fontStyle = params["font-style"]);1972: if (params.opacity != null || 1973: params["stroke-width"] != null ||1974: params.fill != null ||1975: params.stroke != null ||1976: params["stroke-width"] != null ||1977: params["stroke-opacity"] != null ||1978: params["fill-opacity"] != null ||1979: params["stroke-dasharray"] != null ||1980: params["stroke-miterlimit"] != null ||1981: params["stroke-linejoin"] != null ||1982: params["stroke-linecap"] != null) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 37: Raphael.js

Page:37/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

1983: node = o.shape || node;1984: var fill = (node.getElementsByTagName(fillString) &&

node.getElementsByTagName(fillString)[0]),1985: newfill = false;1986: !fill && (newfill = fill = createNode(fillString));1987: if ("fill-opacity" in params || "opacity" in params) {1988: var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) *

((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1);1989: opacity = mmin(mmax(opacity, 0), 1);1990: fill.opacity = opacity;1991: }1992: params.fill && (fill.on = true);1993: if (fill.on == null || params.fill == "none") {1994: fill.on = false;1995: }1996: if (fill.on && params.fill) {1997: var isURL = params.fill.match(ISURL);1998: if (isURL) {1999: fill.src = isURL[1];2000: fill.type = "tile";2001: } else {2002: fill.color = R.getRGB(params.fill).hex;2003: fill.src = E;2004: fill.type = "solid";2005: if (R.getRGB(params.fill).error && (res.type in {circle: 1,

ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill)) {

2006: a.fill = "none";2007: a.gradient = params.fill;2008: }2009: }2010: }2011: newfill && node[appendChild](fill);2012: var stroke = (node.getElementsByTagName("stroke") &&

node.getElementsByTagName("stroke")[0]),2013: newstroke = false;2014: !stroke && (newstroke = stroke = createNode("stroke"));2015: if ((params.stroke && params.stroke != "none") ||2016: params["stroke-width"] ||2017: params["stroke-opacity"] != null ||2018: params["stroke-dasharray"] ||2019: params["stroke-miterlimit"] ||2020: params["stroke-linejoin"] ||2021: params["stroke-linecap"]) {2022: stroke.on = true;2023: }2024: (params.stroke == "none" || stroke.on == null || params.stroke == 0

|| params["stroke-width"] == 0) && (stroke.on = false);2025: var strokeColor = R.getRGB(params.stroke);2026: stroke.on && params.stroke && (stroke.color = strokeColor.hex);2027: opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1

|| 2) - 1) * ((+strokeColor.o + 1 || 2) - 1);2028: var width = (toFloat(params["stroke-width"]) || 1) * .75;2029: opacity = mmin(mmax(opacity, 0), 1);2030: params["stroke-width"] == null && (width = a["stroke-width"]);2031: params["stroke-width"] && (stroke.weight = width);2032: width && width < 1 && (opacity *= width) && (stroke.weight = 1);2033: stroke.opacity = opacity;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 38: Raphael.js

Page:38/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2034: 2035: params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-

linejoin"] || "miter");2036: stroke.miterlimit = params["stroke-miterlimit"] || 8;2037: params["stroke-linecap"] && (stroke.endcap = params["stroke-

linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round");

2038: if (params["stroke-dasharray"]) {2039: var dasharray = {2040: "-": "shortdash",2041: ".": "shortdot",2042: "-.": "shortdashdot",2043: "-..": "shortdashdotdot",2044: ". ": "dot",2045: "- ": "dash",2046: "--": "longdash",2047: "- .": "dashdot",2048: "--.": "longdashdot",2049: "--..": "longdashdotdot"2050: };2051: stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ?

dasharray[params["stroke-dasharray"]] : E;2052: }2053: newstroke && node[appendChild](stroke);2054: }2055: if (res.type == "text") {2056: s = res.paper.span.style;2057: a.font && (s.font = a.font);2058: a["font-family"] && (s.fontFamily = a["font-family"]);2059: a["font-size"] && (s.fontSize = a["font-size"]);2060: a["font-weight"] && (s.fontWeight = a["font-weight"]);2061: a["font-style"] && (s.fontStyle = a["font-style"]);2062: res.node.string && (res.paper.span.innerHTML =

Str(res.node.string)[rp](/</g, "&#60;")[rp](/&/g, "&#38;")[rp](/\n/g, "<br>"));2063: res.W = a.w = res.paper.span.offsetWidth;2064: res.H = a.h = res.paper.span.offsetHeight;2065: res.X = a.x;2066: res.Y = a.y + round(res.H / 2);2067: 2068: // text-anchor emulationm2069: switch (a["text-anchor"]) {2070: case "start":2071: res.node.style["v-text-align"] = "left";2072: res.bbx = round(res.W / 2);2073: break;2074: case "end":2075: res.node.style["v-text-align"] = "right";2076: res.bbx = -round(res.W / 2);2077: break;2078: default:2079: res.node.style["v-text-align"] = "center";2080: break;2081: }2082: }2083: };2084: addGradientFill = function (o, gradient) {2085: o.attrs = o.attrs || {};2086: var attrs = o.attrs,

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 39: Raphael.js

Page:39/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2087: fill,2088: type = "linear",2089: fxfy = ".5 .5";2090: o.attrs.gradient = gradient;2091: gradient = Str(gradient)[rp](radial_gradient, function (all, fx, fy) {2092: type = "radial";2093: if (fx && fy) {2094: fx = toFloat(fx);2095: fy = toFloat(fy);2096: pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 -

pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5);2097: fxfy = fx + S + fy;2098: }2099: return E;2100: });2101: gradient = gradient[split](/\s*\-\s*/);2102: if (type == "linear") {2103: var angle = gradient.shift();2104: angle = -toFloat(angle);2105: if (isNaN(angle)) {2106: return null;2107: }2108: }2109: var dots = parseDots(gradient);2110: if (!dots) {2111: return null;2112: }2113: o = o.shape || o.node;2114: fill = o.getElementsByTagName(fillString)[0] || createNode(fillString);2115: !fill.parentNode && o.appendChild(fill);2116: if (dots[length]) {2117: fill.on = true;2118: fill.method = "none";2119: fill.color = dots[0].color;2120: fill.color2 = dots[dots[length] - 1].color;2121: var clrs = [];2122: for (var i = 0, ii = dots[length]; i < ii; i++) {2123: dots[i].offset && clrs[push](dots[i].offset + S +

dots[i].color);2124: }2125: fill.colors && (fill.colors.value = clrs[length] ? clrs[join]() :

"0% " + fill.color);2126: if (type == "radial") {2127: fill.type = "gradientradial";2128: fill.focus = "100%";2129: fill.focussize = fxfy;2130: fill.focusposition = fxfy;2131: } else {2132: fill.type = "gradient";2133: fill.angle = (270 - angle) % 360;2134: }2135: }2136: return 1;2137: };2138: Element = function (node, group, vml) {2139: var Rotation = 0,2140: RotX = 0,2141: RotY = 0,

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 40: Raphael.js

Page:40/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2142: Scale = 1;2143: this[0] = node;2144: this.id = R._oid++;2145: this.node = node;2146: node.raphael = this;2147: this.X = 0;2148: this.Y = 0;2149: this.attrs = {};2150: this.Group = group;2151: this.paper = vml;2152: this._ = {2153: tx: 0,2154: ty: 0,2155: rt: {deg:0},2156: sx: 1,2157: sy: 12158: };2159: !vml.bottom && (vml.bottom = this);2160: this.prev = vml.top;2161: vml.top && (vml.top.next = this);2162: vml.top = this;2163: this.next = null;2164: };2165: elproto = Element[proto];2166: elproto.rotate = function (deg, cx, cy) {2167: if (this.removed) {2168: return this;2169: }2170: if (deg == null) {2171: if (this._.rt.cx) {2172: return [this._.rt.deg, this._.rt.cx, this._.rt.cy][join](S);2173: }2174: return this._.rt.deg;2175: }2176: deg = Str(deg)[split](separator);2177: if (deg[length] - 1) {2178: cx = toFloat(deg[1]);2179: cy = toFloat(deg[2]);2180: }2181: deg = toFloat(deg[0]);2182: if (cx != null) {2183: this._.rt.deg = deg;2184: } else {2185: this._.rt.deg += deg;2186: }2187: cy == null && (cx = null);2188: this._.rt.cx = cx;2189: this._.rt.cy = cy;2190: this.setBox(this.attrs, cx, cy);2191: this.Group.style.rotation = this._.rt.deg;2192: // gradient fix for rotation. TODO2193: // var fill = (this.shape ||

this.node).getElementsByTagName(fillString);2194: // fill = fill[0] || {};2195: // var b = ((360 - this._.rt.deg) - 270) % 360;2196: // !R.is(fill.angle, "undefined") && (fill.angle = b);2197: return this;2198: };

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 41: Raphael.js

Page:41/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2199: elproto.setBox = function (params, cx, cy) {2200: if (this.removed) {2201: return this;2202: }2203: var gs = this.Group.style,2204: os = (this.shape && this.shape.style) || this.node.style;2205: params = params || {};2206: for (var i in params) if (params[has](i)) {2207: this.attrs[i] = params[i];2208: }2209: cx = cx || this._.rt.cx;2210: cy = cy || this._.rt.cy;2211: var attr = this.attrs,2212: x,2213: y,2214: w,2215: h;2216: switch (this.type) {2217: case "circle":2218: x = attr.cx - attr.r;2219: y = attr.cy - attr.r;2220: w = h = attr.r * 2;2221: break;2222: case "ellipse":2223: x = attr.cx - attr.rx;2224: y = attr.cy - attr.ry;2225: w = attr.rx * 2;2226: h = attr.ry * 2;2227: break;2228: case "image":2229: x = +attr.x;2230: y = +attr.y;2231: w = attr.width || 0;2232: h = attr.height || 0;2233: break;2234: case "text":2235: this.textpath.v = ["m", round(attr.x), ", ", round(attr.y - 2),

"l", round(attr.x) + 1, ", ", round(attr.y - 2)][join](E);2236: x = attr.x - round(this.W / 2);2237: y = attr.y - this.H / 2;2238: w = this.W;2239: h = this.H;2240: break;2241: case "rect":2242: case "path":2243: if (!this.attrs.path) {2244: x = 0;2245: y = 0;2246: w = this.paper.width;2247: h = this.paper.height;2248: } else {2249: var dim = pathDimensions(this.attrs.path);2250: x = dim.x;2251: y = dim.y;2252: w = dim.width;2253: h = dim.height;2254: }2255: break;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 42: Raphael.js

Page:42/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2256: default:2257: x = 0;2258: y = 0;2259: w = this.paper.width;2260: h = this.paper.height;2261: break;2262: }2263: cx = (cx == null) ? x + w / 2 : cx;2264: cy = (cy == null) ? y + h / 2 : cy;2265: var left = cx - this.paper.width / 2,2266: top = cy - this.paper.height / 2, t;2267: gs.left != (t = left + "px") && (gs.left = t);2268: gs.top != (t = top + "px") && (gs.top = t);2269: this.X = pathlike[has](this.type) ? -left : x;2270: this.Y = pathlike[has](this.type) ? -top : y;2271: this.W = w;2272: this.H = h;2273: if (pathlike[has](this.type)) {2274: os.left != (t = -left * zoom + "px") && (os.left = t);2275: os.top != (t = -top * zoom + "px") && (os.top = t);2276: } else if (this.type == "text") {2277: os.left != (t = -left + "px") && (os.left = t);2278: os.top != (t = -top + "px") && (os.top = t);2279: } else {2280: gs.width != (t = this.paper.width + "px") && (gs.width = t);2281: gs.height != (t = this.paper.height + "px") && (gs.height = t);2282: os.left != (t = x - left + "px") && (os.left = t);2283: os.top != (t = y - top + "px") && (os.top = t);2284: os.width != (t = w + "px") && (os.width = t);2285: os.height != (t = h + "px") && (os.height = t);2286: }2287: };2288: elproto.hide = function () {2289: !this.removed && (this.Group.style.display = "none");2290: return this;2291: };2292: elproto.show = function () {2293: !this.removed && (this.Group.style.display = "block");2294: return this;2295: };2296: elproto.getBBox = function () {2297: if (this.removed) {2298: return this;2299: }2300: if (pathlike[has](this.type)) {2301: return pathDimensions(this.attrs.path);2302: }2303: return {2304: x: this.X + (this.bbx || 0),2305: y: this.Y,2306: width: this.W,2307: height: this.H2308: };2309: };2310: elproto.remove = function () {2311: if (this.removed) {2312: return;2313: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 43: Raphael.js

Page:43/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2314: tear(this, this.paper);2315: this.node.parentNode.removeChild(this.node);2316: this.Group.parentNode.removeChild(this.Group);2317: this.shape && this.shape.parentNode.removeChild(this.shape);2318: for (var i in this) {2319: delete this[i];2320: }2321: this.removed = true;2322: };2323: elproto.attr = function (name, value) {2324: if (this.removed) {2325: return this;2326: }2327: if (name == null) {2328: var res = {};2329: for (var i in this.attrs) if (this.attrs[has](i)) {2330: res[i] = this.attrs[i];2331: }2332: this._.rt.deg && (res.rotation = this.rotate());2333: (this._.sx != 1 || this._.sy != 1) && (res.scale = this.scale());2334: res.gradient && res.fill == "none" && (res.fill = res.gradient) &&

delete res.gradient;2335: return res;2336: }2337: if (value == null && R.is(name, "string")) {2338: if (name == "translation") {2339: return translate.call(this);2340: }2341: if (name == "rotation") {2342: return this.rotate();2343: }2344: if (name == "scale") {2345: return this.scale();2346: }2347: if (name == fillString && this.attrs.fill == "none" &&

this.attrs.gradient) {2348: return this.attrs.gradient;2349: }2350: return this.attrs[name];2351: }2352: if (this.attrs && value == null && R.is(name, array)) {2353: var ii, values = {};2354: for (i = 0, ii = name[length]; i < ii; i++) {2355: values[name[i]] = this.attr(name[i]);2356: }2357: return values;2358: }2359: var params;2360: if (value != null) {2361: params = {};2362: params[name] = value;2363: }2364: value == null && R.is(name, "object") && (params = name);2365: if (params) {2366: for (var key in this.paper.customAttributes) if

(this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) {

2367: var par = this.paper.customAttributes[key].apply(this, [][concat](params[key]));

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 44: Raphael.js

Page:44/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2368: this.attrs[key] = params[key];2369: for (var subkey in par) if (par[has](subkey)) {2370: params[subkey] = par[subkey];2371: }2372: }2373: if (params.text && this.type == "text") {2374: this.node.string = params.text;2375: }2376: setFillAndStroke(this, params);2377: if (params.gradient && (({circle: 1, ellipse: 1})[has](this.type)

|| Str(params.gradient).charAt() != "r")) {2378: addGradientFill(this, params.gradient);2379: }2380: (!pathlike[has](this.type) || this._.rt.deg) &&

this.setBox(this.attrs);2381: }2382: return this;2383: };2384: elproto.toFront = function () {2385: !this.removed && this.Group.parentNode[appendChild](this.Group);2386: this.paper.top != this && tofront(this, this.paper);2387: return this;2388: };2389: elproto.toBack = function () {2390: if (this.removed) {2391: return this;2392: }2393: if (this.Group.parentNode.firstChild != this.Group) {2394: this.Group.parentNode.insertBefore(this.Group,

this.Group.parentNode.firstChild);2395: toback(this, this.paper);2396: }2397: return this;2398: };2399: elproto.insertAfter = function (element) {2400: if (this.removed) {2401: return this;2402: }2403: if (element.constructor == Set) {2404: element = element[element.length - 1];2405: }2406: if (element.Group.nextSibling) {2407: element.Group.parentNode.insertBefore(this.Group,

element.Group.nextSibling);2408: } else {2409: element.Group.parentNode[appendChild](this.Group);2410: }2411: insertafter(this, element, this.paper);2412: return this;2413: };2414: elproto.insertBefore = function (element) {2415: if (this.removed) {2416: return this;2417: }2418: if (element.constructor == Set) {2419: element = element[0];2420: }2421: element.Group.parentNode.insertBefore(this.Group, element.Group);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 45: Raphael.js

Page:45/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2422: insertbefore(this, element, this.paper);2423: return this;2424: };2425: elproto.blur = function (size) {2426: var s = this.node.runtimeStyle,2427: f = s.filter;2428: f = f.replace(blurregexp, E);2429: if (+size !== 0) {2430: this.attrs.blur = size;2431: s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")";2432: s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5));2433: } else {2434: s.filter = f;2435: s.margin = 0;2436: delete this.attrs.blur;2437: }2438: };2439: 2440: theCircle = function (vml, x, y, r) {2441: var g = createNode("group"),2442: o = createNode("oval"),2443: ol = o.style;2444: g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width +

"px;height:" + vml.height + "px";2445: g.coordsize = coordsize;2446: g.coordorigin = vml.coordorigin;2447: g[appendChild](o);2448: var res = new Element(o, g, vml);2449: res.type = "circle";2450: setFillAndStroke(res, {stroke: "#000", fill: "none"});2451: res.attrs.cx = x;2452: res.attrs.cy = y;2453: res.attrs.r = r;2454: res.setBox({x: x - r, y: y - r, width: r * 2, height: r * 2});2455: vml.canvas[appendChild](g);2456: return res;2457: };2458: function rectPath(x, y, w, h, r) {2459: if (r) {2460: return R.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},

0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z", x + r, y, w - r * 2, r, -r, h - r * 2, r * 2 - w, r * 2 - h);

2461: } else {2462: return R.format("M{0},{1}l{2},0,0,{3},{4},0z", x, y, w, h, -w);2463: }2464: }2465: theRect = function (vml, x, y, w, h, r) {2466: var path = rectPath(x, y, w, h, r),2467: res = vml.path(path),2468: a = res.attrs;2469: res.X = a.x = x;2470: res.Y = a.y = y;2471: res.W = a.width = w;2472: res.H = a.height = h;2473: a.r = r;2474: a.path = path;2475: res.type = "rect";2476: return res;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 46: Raphael.js

Page:46/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2477: };2478: theEllipse = function (vml, x, y, rx, ry) {2479: var g = createNode("group"),2480: o = createNode("oval"),2481: ol = o.style;2482: g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width +

"px;height:" + vml.height + "px";2483: g.coordsize = coordsize;2484: g.coordorigin = vml.coordorigin;2485: g[appendChild](o);2486: var res = new Element(o, g, vml);2487: res.type = "ellipse";2488: setFillAndStroke(res, {stroke: "#000"});2489: res.attrs.cx = x;2490: res.attrs.cy = y;2491: res.attrs.rx = rx;2492: res.attrs.ry = ry;2493: res.setBox({x: x - rx, y: y - ry, width: rx * 2, height: ry * 2});2494: vml.canvas[appendChild](g);2495: return res;2496: };2497: theImage = function (vml, src, x, y, w, h) {2498: var g = createNode("group"),2499: o = createNode("image");2500: g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width +

"px;height:" + vml.height + "px";2501: g.coordsize = coordsize;2502: g.coordorigin = vml.coordorigin;2503: o.src = src;2504: g[appendChild](o);2505: var res = new Element(o, g, vml);2506: res.type = "image";2507: res.attrs.src = src;2508: res.attrs.x = x;2509: res.attrs.y = y;2510: res.attrs.w = w;2511: res.attrs.h = h;2512: res.setBox({x: x, y: y, width: w, height: h});2513: vml.canvas[appendChild](g);2514: return res;2515: };2516: theText = function (vml, x, y, text) {2517: var g = createNode("group"),2518: el = createNode("shape"),2519: ol = el.style,2520: path = createNode("path"),2521: ps = path.style,2522: o = createNode("textpath");2523: g.style.cssText = "position:absolute;left:0;top:0;width:" + vml.width +

"px;height:" + vml.height + "px";2524: g.coordsize = coordsize;2525: g.coordorigin = vml.coordorigin;2526: path.v = R.format("m{0},{1}l{2},{1}", round(x * 10), round(y * 10),

round(x * 10) + 1);2527: path.textpathok = true;2528: ol.width = vml.width;2529: ol.height = vml.height;2530: o.string = Str(text);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 47: Raphael.js

Page:47/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2531: o.on = true;2532: el[appendChild](o);2533: el[appendChild](path);2534: g[appendChild](el);2535: var res = new Element(o, g, vml);2536: res.shape = el;2537: res.textpath = path;2538: res.type = "text";2539: res.attrs.text = text;2540: res.attrs.x = x;2541: res.attrs.y = y;2542: res.attrs.w = 1;2543: res.attrs.h = 1;2544: setFillAndStroke(res, {font: availableAttrs.font, stroke: "none", fill:

"#000"});2545: res.setBox();2546: vml.canvas[appendChild](g);2547: return res;2548: };2549: setSize = function (width, height) {2550: var cs = this.canvas.style;2551: width == +width && (width += "px");2552: height == +height && (height += "px");2553: cs.width = width;2554: cs.height = height;2555: cs.clip = "rect(0 " + width + " " + height + " 0)";2556: return this;2557: };2558: var createNode;2559: doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");2560: try {2561: !doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-

microsoft-com:vml");2562: createNode = function (tagName) {2563: return doc.createElement('<rvml:' + tagName + ' class="rvml">');2564: };2565: } catch (e) {2566: createNode = function (tagName) {2567: return doc.createElement('<' + tagName + ' xmlns="urn:schemas-

microsoft.com:vml" class="rvml">');2568: };2569: }2570: create = function () {2571: var con = getContainer[apply](0, arguments),2572: container = con.container,2573: height = con.height,2574: s,2575: width = con.width,2576: x = con.x,2577: y = con.y;2578: if (!container) {2579: throw new Error("VML container not found.");2580: }2581: var res = new Paper,2582: c = res.canvas = doc.createElement("div"),2583: cs = c.style;2584: x = x || 0;2585: y = y || 0;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 48: Raphael.js

Page:48/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2586: width = width || 512;2587: height = height || 342;2588: width == +width && (width += "px");2589: height == +height && (height += "px");2590: res.width = 1e3;2591: res.height = 1e3;2592: res.coordsize = zoom * 1e3 + S + zoom * 1e3;2593: res.coordorigin = "0 0";2594: res.span = doc.createElement("span");2595: res.span.style.cssText = "position:absolute;left:-9999em;top:-

9999em;padding:0;margin:0;line-height:1;display:inline;";2596: c[appendChild](res.span);2597: cs.cssText = R.format("top:0;left:0;width:{0};height:{1};display:inline-

block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height);2598: if (container == 1) {2599: doc.body[appendChild](c);2600: cs.left = x + "px";2601: cs.top = y + "px";2602: cs.position = "absolute";2603: } else {2604: if (container.firstChild) {2605: container.insertBefore(c, container.firstChild);2606: } else {2607: container[appendChild](c);2608: }2609: }2610: plugins.call(res, res, R.fn);2611: return res;2612: };2613: paperproto.clear = function () {2614: this.canvas.innerHTML = E;2615: this.span = doc.createElement("span");2616: this.span.style.cssText = "position:absolute;left:-9999em;top:-

9999em;padding:0;margin:0;line-height:1;display:inline;";2617: this.canvas[appendChild](this.span);2618: this.bottom = this.top = null;2619: };2620: paperproto.remove = function () {2621: this.canvas.parentNode.removeChild(this.canvas);2622: for (var i in this) {2623: this[i] = removed(i);2624: }2625: return true;2626: };2627: } // VML end - start: 18242628: 2629: // rest2630: // WebKit rendering bug workaround method2631: var version = navigator.userAgent.match(/Version\/(.*?)\s/);2632: if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4

|| navigator.platform.slice(0, 2) == "iP")) {2633: paperproto.safari = function () {2634: var rect = this.rect(-99, -99, this.width + 99, this.height +

99).attr({stroke: "none"});2635: win.setTimeout(function () {rect.remove();});2636: };2637: } else {2638: paperproto.safari = function () {};

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
Page 49: Raphael.js

Page:49/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2639: }2640: 2641: // Events start - end: 30642642: var preventDefault = function () {2643: this.returnValue = false;2644: },2645: preventTouch = function () {2646: return this.originalEvent.preventDefault();2647: },2648: stopPropagation = function () {2649: this.cancelBubble = true;2650: },2651: stopTouch = function () {2652: return this.originalEvent.stopPropagation();2653: },2654: addEvent = (function () {2655: if (doc.addEventListener) {2656: return function (obj, type, fn, element) {2657: var realName = supportsTouch && touchMap[type] ? touchMap[type] :

type;2658: var f = function (e) {2659: if (supportsTouch && touchMap[has](type)) {2660: for (var i = 0, ii = e.targetTouches &&

e.targetTouches.length; i < ii; i++) {2661: if (e.targetTouches[i].target == obj) {2662: var olde = e;2663: e = e.targetTouches[i];2664: e.originalEvent = olde;2665: e.preventDefault = preventTouch;2666: e.stopPropagation = stopTouch;2667: break;2668: }2669: }2670: }2671: return fn.call(element, e);2672: };2673: obj.addEventListener(realName, f, false);2674: return function () {2675: obj.removeEventListener(realName, f, false);2676: return true;2677: };2678: };2679: } else if (doc.attachEvent) {2680: return function (obj, type, fn, element) {2681: var f = function (e) {2682: e = e || win.event;2683: e.preventDefault = e.preventDefault || preventDefault;2684: e.stopPropagation = e.stopPropagation || stopPropagation;2685: return fn.call(element, e);2686: };2687: obj.attachEvent("on" + type, f);2688: var detacher = function () {2689: obj.detachEvent("on" + type, f);2690: return true;2691: };2692: return detacher;2693: };2694: }

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
Page 50: Raphael.js

Page:50/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2695: })(),2696: drag = [],2697: dragMove = function (e) {2698: var x = e.clientX,2699: y = e.clientY,2700: scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,2701: scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft,2702: dragi,2703: j = drag.length;2704: while (j--) {2705: dragi = drag[j];2706: if (supportsTouch) {2707: var i = e.touches.length,2708: touch;2709: while (i--) {2710: touch = e.touches[i];2711: if (touch.identifier == dragi.el._drag.id) {2712: x = touch.clientX;2713: y = touch.clientY;2714: (e.originalEvent ? e.originalEvent : e).preventDefault();2715: break;2716: }2717: }2718: } else {2719: e.preventDefault();2720: }2721: x += scrollX;2722: y += scrollY;2723: dragi.move && dragi.move.call(dragi.move_scope || dragi.el, x -

dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);2724: }2725: },2726: dragUp = function (e) {2727: R.unmousemove(dragMove).unmouseup(dragUp);2728: var i = drag.length,2729: dragi;2730: while (i--) {2731: dragi = drag[i];2732: dragi.el._drag = {};2733: dragi.end && dragi.end.call(dragi.end_scope || dragi.start_scope ||

dragi.move_scope || dragi.el, e);2734: }2735: drag = [];2736: };2737: for (var i = events[length]; i--;) {2738: (function (eventName) {2739: R[eventName] = Element[proto][eventName] = function (fn, scope) {2740: if (R.is(fn, "function")) {2741: this.events = this.events || [];2742: this.events.push({name: eventName, f: fn, unbind:

addEvent(this.shape || this.node || doc, eventName, fn, scope || this)});2743: }2744: return this;2745: };2746: R["un" + eventName] = Element[proto]["un" + eventName] = function (fn) {2747: var events = this.events,2748: l = events[length];2749: while (l--) if (events[l].name == eventName && events[l].f == fn) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 51: Raphael.js

Page:51/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2750: events[l].unbind();2751: events.splice(l, 1);2752: !events.length && delete this.events;2753: return this;2754: }2755: return this;2756: };2757: })(events[i]);2758: }2759: elproto.hover = function (f_in, f_out, scope_in, scope_out) {2760: return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out ||

scope_in);2761: };2762: elproto.unhover = function (f_in, f_out) {2763: return this.unmouseover(f_in).unmouseout(f_out);2764: };2765: elproto.drag = function (onmove, onstart, onend, move_scope, start_scope,

end_scope) {2766: this._drag = {};2767: this.mousedown(function (e) {2768: (e.originalEvent || e).preventDefault();2769: var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,2770: scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;2771: this._drag.x = e.clientX + scrollX;2772: this._drag.y = e.clientY + scrollY;2773: this._drag.id = e.identifier;2774: onstart && onstart.call(start_scope || move_scope || this, e.clientX +

scrollX, e.clientY + scrollY, e);2775: !drag.length && R.mousemove(dragMove).mouseup(dragUp);2776: drag.push({el: this, move: onmove, end: onend, move_scope: move_scope,

start_scope: start_scope, end_scope: end_scope});2777: });2778: return this;2779: };2780: elproto.undrag = function (onmove, onstart, onend) {2781: var i = drag.length;2782: while (i--) {2783: drag[i].el == this && (drag[i].move == onmove && drag[i].end == onend)

&& drag.splice(i++, 1);2784: }2785: !drag.length && R.unmousemove(dragMove).unmouseup(dragUp);2786: };2787: paperproto.circle = function (x, y, r) {2788: return theCircle(this, x || 0, y || 0, r || 0);2789: };2790: paperproto.rect = function (x, y, w, h, r) {2791: return theRect(this, x || 0, y || 0, w || 0, h || 0, r || 0);2792: };2793: paperproto.ellipse = function (x, y, rx, ry) {2794: return theEllipse(this, x || 0, y || 0, rx || 0, ry || 0);2795: };2796: paperproto.path = function (pathString) {2797: pathString && !R.is(pathString, string) && !R.is(pathString[0], array) &&

(pathString += E);2798: return thePath(R.format[apply](R, arguments), this);2799: };2800: paperproto.image = function (src, x, y, w, h) {2801: return theImage(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 52: Raphael.js

Page:52/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2802: };2803: paperproto.text = function (x, y, text) {2804: return theText(this, x || 0, y || 0, Str(text));2805: };2806: paperproto.set = function (itemsArray) {2807: arguments[length] > 1 && (itemsArray = Array[proto].splice.call(arguments,

0, arguments[length]));2808: return new Set(itemsArray);2809: };2810: paperproto.setSize = setSize;2811: paperproto.top = paperproto.bottom = null;2812: paperproto.raphael = R;2813: function x_y() {2814: return this.x + S + this.y;2815: }2816: elproto.resetScale = function () {2817: if (this.removed) {2818: return this;2819: }2820: this._.sx = 1;2821: this._.sy = 1;2822: this.attrs.scale = "1 1";2823: };2824: elproto.scale = function (x, y, cx, cy) {2825: if (this.removed) {2826: return this;2827: }2828: if (x == null && y == null) {2829: return {2830: x: this._.sx,2831: y: this._.sy,2832: toString: x_y2833: };2834: }2835: y = y || x;2836: !+y && (y = x);2837: var dx,2838: dy,2839: dcx,2840: dcy,2841: a = this.attrs;2842: if (x != 0) {2843: var bb = this.getBBox(),2844: rcx = bb.x + bb.width / 2,2845: rcy = bb.y + bb.height / 2,2846: kx = abs(x / this._.sx),2847: ky = abs(y / this._.sy);2848: cx = (+cx || cx == 0) ? cx : rcx;2849: cy = (+cy || cy == 0) ? cy : rcy;2850: var posx = this._.sx > 0,2851: posy = this._.sy > 0,2852: dirx = ~~(x / abs(x)),2853: diry = ~~(y / abs(y)),2854: dkx = kx * dirx,2855: dky = ky * diry,2856: s = this.node.style,2857: ncx = cx + abs(rcx - cx) * dkx * (rcx > cx == posx ? 1 : -1),2858: ncy = cy + abs(rcy - cy) * dky * (rcy > cy == posy ? 1 : -1),

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 53: Raphael.js

Page:53/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2859: fr = (x * dirx > y * diry ? ky : kx);2860: switch (this.type) {2861: case "rect":2862: case "image":2863: var neww = a.width * kx,2864: newh = a.height * ky;2865: this.attr({2866: height: newh,2867: r: a.r * fr,2868: width: neww,2869: x: ncx - neww / 2,2870: y: ncy - newh / 22871: });2872: break;2873: case "circle":2874: case "ellipse":2875: this.attr({2876: rx: a.rx * kx,2877: ry: a.ry * ky,2878: r: a.r * fr,2879: cx: ncx,2880: cy: ncy2881: });2882: break;2883: case "text":2884: this.attr({2885: x: ncx,2886: y: ncy2887: });2888: break;2889: case "path":2890: var path = pathToRelative(a.path),2891: skip = true,2892: fx = posx ? dkx : kx,2893: fy = posy ? dky : ky;2894: for (var i = 0, ii = path[length]; i < ii; i++) {2895: var p = path[i],2896: P0 = upperCase.call(p[0]);2897: if (P0 == "M" && skip) {2898: continue;2899: } else {2900: skip = false;2901: }2902: if (P0 == "A") {2903: p[path[i][length] - 2] *= fx;2904: p[path[i][length] - 1] *= fy;2905: p[1] *= kx;2906: p[2] *= ky;2907: p[5] = +(dirx + diry ? !!+p[5] : !+p[5]);2908: } else if (P0 == "H") {2909: for (var j = 1, jj = p[length]; j < jj; j++) {2910: p[j] *= fx;2911: }2912: } else if (P0 == "V") {2913: for (j = 1, jj = p[length]; j < jj; j++) {2914: p[j] *= fy;2915: }2916: } else {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 54: Raphael.js

Page:54/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2917: for (j = 1, jj = p[length]; j < jj; j++) {2918: p[j] *= (j % 2) ? fx : fy;2919: }2920: }2921: }2922: var dim2 = pathDimensions(path);2923: dx = ncx - dim2.x - dim2.width / 2;2924: dy = ncy - dim2.y - dim2.height / 2;2925: path[0][1] += dx;2926: path[0][2] += dy;2927: this.attr({path: path});2928: break;2929: }2930: if (this.type in {text: 1, image:1} && (dirx != 1 || diry != 1)) {2931: if (this.transformations) {2932: this.transformations[2] = "scale("[concat](dirx, ",", diry,

")");2933: this.node[setAttribute]("transform",

this.transformations[join](S));2934: dx = (dirx == -1) ? -a.x - (neww || 0) : a.x;2935: dy = (diry == -1) ? -a.y - (newh || 0) : a.y;2936: this.attr({x: dx, y: dy});2937: a.fx = dirx - 1;2938: a.fy = diry - 1;2939: } else {2940: this.node.filterMatrix = ms + ".Matrix(M11="[concat](dirx,2941: ", M12=0, M21=0, M22=", diry,2942: ", Dx=0, Dy=0, sizingmethod='auto expand',

filtertype='bilinear')");2943: s.filter = (this.node.filterMatrix || E) +

(this.node.filterOpacity || E);2944: }2945: } else {2946: if (this.transformations) {2947: this.transformations[2] = E;2948: this.node[setAttribute]("transform",

this.transformations[join](S));2949: a.fx = 0;2950: a.fy = 0;2951: } else {2952: this.node.filterMatrix = E;2953: s.filter = (this.node.filterMatrix || E) +

(this.node.filterOpacity || E);2954: }2955: }2956: a.scale = [x, y, cx, cy][join](S);2957: this._.sx = x;2958: this._.sy = y;2959: }2960: return this;2961: };2962: elproto.clone = function () {2963: if (this.removed) {2964: return null;2965: }2966: var attr = this.attr();2967: delete attr.scale;2968: delete attr.translation;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 55: Raphael.js

Page:55/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

2969: return this.paper[this.type]().attr(attr);2970: };2971: var curveslengths = {},2972: getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y,

length) {2973: var len = 0,2974: precision = 100,2975: name = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y].join(),2976: cache = curveslengths[name],2977: old, dot;2978: !cache && (curveslengths[name] = cache = {data: []});2979: cache.timer && clearTimeout(cache.timer);2980: cache.timer = setTimeout(function () {delete curveslengths[name];}, 2000);2981: if (length != null) {2982: var total = getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x,

p2y);2983: precision = ~~total * 10;2984: }2985: for (var i = 0; i < precision + 1; i++) {2986: if (cache.data[length] > i) {2987: dot = cache.data[i * precision];2988: } else {2989: dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i

/ precision);2990: cache.data[i] = dot;2991: }2992: i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5));2993: if (length != null && len >= length) {2994: return dot;2995: }2996: old = dot;2997: }2998: if (length == null) {2999: return len;3000: }3001: },3002: getLengthFactory = function (istotal, subpath) {3003: return function (path, length, onlystart) {3004: path = path2curve(path);3005: var x, y, p, l, sp = "", subpaths = {}, point,3006: len = 0;3007: for (var i = 0, ii = path.length; i < ii; i++) {3008: p = path[i];3009: if (p[0] == "M") {3010: x = +p[1];3011: y = +p[2];3012: } else {3013: l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5],

p[6]);3014: if (len + l > length) {3015: if (subpath && !subpaths.start) {3016: point = getPointAtSegmentLength(x, y, p[1], p[2], p[3],

p[4], p[5], p[6], length - len);3017: sp += ["C", point.start.x, point.start.y, point.m.x,

point.m.y, point.x, point.y];3018: if (onlystart) {return sp;}3019: subpaths.start = sp;3020: sp = ["M", point.x, point.y + "C", point.n.x, point.n.y,

point.end.x, point.end.y, p[5], p[6]][join]();

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 56: Raphael.js

Page:56/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3021: len += l;3022: x = +p[5];3023: y = +p[6];3024: continue;3025: }3026: if (!istotal && !subpath) {3027: point = getPointAtSegmentLength(x, y, p[1], p[2], p[3],

p[4], p[5], p[6], length - len);3028: return {x: point.x, y: point.y, alpha: point.alpha};3029: }3030: }3031: len += l;3032: x = +p[5];3033: y = +p[6];3034: }3035: sp += p;3036: }3037: subpaths.end = sp;3038: point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y,

p[1], p[2], p[3], p[4], p[5], p[6], 1);3039: point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});3040: return point;3041: };3042: };3043: var getTotalLength = getLengthFactory(1),3044: getPointAtLength = getLengthFactory(),3045: getSubpathsAtLength = getLengthFactory(0, 1);3046: elproto.getTotalLength = function () {3047: if (this.type != "path") {return;}3048: if (this.node.getTotalLength) {3049: return this.node.getTotalLength();3050: }3051: return getTotalLength(this.attrs.path);3052: };3053: elproto.getPointAtLength = function (length) {3054: if (this.type != "path") {return;}3055: return getPointAtLength(this.attrs.path, length);3056: };3057: elproto.getSubpath = function (from, to) {3058: if (this.type != "path") {return;}3059: if (abs(this.getTotalLength() - to) < "1e-6") {3060: return getSubpathsAtLength(this.attrs.path, from).end;3061: }3062: var a = getSubpathsAtLength(this.attrs.path, to, 1);3063: return from ? getSubpathsAtLength(a, from).end : a;3064: }; // Events end - start: 26413065: 3066: // animation easing formulas start - end: 35133067: R.easing_formulas = {3068: linear: function (n) {3069: return n;3070: },3071: "<": function (n) {3072: return pow(n, 3);3073: },3074: ">": function (n) {3075: return pow(n - 1, 3) + 1;3076: },

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
Page 57: Raphael.js

Page:57/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3077: "<>": function (n) {3078: n = n * 2;3079: if (n < 1) {3080: return pow(n, 3) / 2;3081: }3082: n -= 2;3083: return (pow(n, 3) + 2) / 2;3084: },3085: backIn: function (n) {3086: var s = 1.70158;3087: return n * n * ((s + 1) * n - s);3088: },3089: backOut: function (n) {3090: n = n - 1;3091: var s = 1.70158;3092: return n * n * ((s + 1) * n + s) + 1;3093: },3094: elastic: function (n) {3095: if (n == 0 || n == 1) {3096: return n;3097: }3098: var p = .3,3099: s = p / 4;3100: return pow(2, -10 * n) * math.sin((n - s) * (2 * PI) / p) + 1;3101: },3102: bounce: function (n) {3103: var s = 7.5625,3104: p = 2.75,3105: l;3106: if (n < (1 / p)) {3107: l = s * n * n;3108: } else {3109: if (n < (2 / p)) {3110: n -= (1.5 / p);3111: l = s * n * n + .75;3112: } else {3113: if (n < (2.5 / p)) {3114: n -= (2.25 / p);3115: l = s * n * n + .9375;3116: } else {3117: n -= (2.625 / p);3118: l = s * n * n + .984375;3119: }3120: }3121: }3122: return l;3123: }3124: };3125: 3126: var animationElements = [],3127: animation = function () {3128: var Now = +new Date;3129: for (var l = 0; l < animationElements[length]; l++) {3130: var e = animationElements[l];3131: if (e.stop || e.el.removed) {3132: continue;3133: }3134: var time = Now - e.start,

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 58: Raphael.js

Page:58/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3135: ms = e.ms,3136: easing = e.easing,3137: from = e.from,3138: diff = e.diff,3139: to = e.to,3140: t = e.t,3141: that = e.el,3142: set = {},3143: now;3144: if (time < ms) {3145: var pos = easing(time / ms);3146: for (var attr in from) if (from[has](attr)) {3147: switch (availableAnimAttrs[attr]) {3148: case "along":3149: now = pos * ms * diff[attr];3150: to.back && (now = to.len - now);3151: var point = getPointAtLength(to[attr], now);3152: that.translate(diff.sx - diff.x || 0, diff.sy -

diff.y || 0);3153: diff.x = point.x;3154: diff.y = point.y;3155: that.translate(point.x - diff.sx, point.y -

diff.sy);3156: to.rot && that.rotate(diff.r + point.alpha, point.x,

point.y);3157: break;3158: case nu:3159: now = +from[attr] + pos * ms * diff[attr];3160: break;3161: case "colour":3162: now = "rgb(" + [3163: upto255(round(from[attr].r + pos * ms *

diff[attr].r)),3164: upto255(round(from[attr].g + pos * ms *

diff[attr].g)),3165: upto255(round(from[attr].b + pos * ms *

diff[attr].b))3166: ][join](",") + ")";3167: break;3168: case "path":3169: now = [];3170: for (var i = 0, ii = from[attr][length]; i < ii;

i++) {3171: now[i] = [from[attr][i][0]];3172: for (var j = 1, jj = from[attr][i][length]; j <

jj; j++) {3173: now[i][j] = +from[attr][i][j] + pos * ms *

diff[attr][i][j];3174: }3175: now[i] = now[i][join](S);3176: }3177: now = now[join](S);3178: break;3179: case "csv":3180: switch (attr) {3181: case "translation":3182: var x = pos * ms * diff[attr][0] - t.x,3183: y = pos * ms * diff[attr][1] - t.y;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 59: Raphael.js

Page:59/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3184: t.x += x;3185: t.y += y;3186: now = x + S + y;3187: break;3188: case "rotation":3189: now = +from[attr][0] + pos * ms *

diff[attr][0];3190: from[attr][1] && (now += "," +

from[attr][1] + "," + from[attr][2]);3191: break;3192: case "scale":3193: now = [+from[attr][0] + pos * ms *

diff[attr][0], +from[attr][1] + pos * ms * diff[attr][1], (2 in to[attr] ? to[attr][2] : E), (3 in to[attr] ? to[attr][3] : E)][join](S);

3194: break;3195: case "clip-rect":3196: now = [];3197: i = 4;3198: while (i--) {3199: now[i] = +from[attr][i] + pos * ms *

diff[attr][i];3200: }3201: break;3202: }3203: break;3204: default:3205: var from2 = [].concat(from[attr]);3206: now = [];3207: i = that.paper.customAttributes[attr].length;3208: while (i--) {3209: now[i] = +from2[i] + pos * ms * diff[attr][i];3210: }3211: break;3212: }3213: set[attr] = now;3214: }3215: that.attr(set);3216: that._run && that._run.call(that);3217: } else {3218: if (to.along) {3219: point = getPointAtLength(to.along, to.len * !to.back);3220: that.translate(diff.sx - (diff.x || 0) + point.x - diff.sx,

diff.sy - (diff.y || 0) + point.y - diff.sy);3221: to.rot && that.rotate(diff.r + point.alpha, point.x,

point.y);3222: }3223: (t.x || t.y) && that.translate(-t.x, -t.y);3224: to.scale && (to.scale += E);3225: that.attr(to);3226: animationElements.splice(l--, 1);3227: }3228: }3229: R.svg && that && that.paper && that.paper.safari();3230: animationElements[length] && setTimeout(animation);3231: },3232: keyframesRun = function (attr, element, time, prev, prevcallback) {3233: var dif = time - prev;3234: element.timeouts.push(setTimeout(function () {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 60: Raphael.js

Page:60/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3235: R.is(prevcallback, "function") && prevcallback.call(element);3236: element.animate(attr, dif, attr.easing);3237: }, prev));3238: },3239: upto255 = function (color) {3240: return mmax(mmin(color, 255), 0);3241: },3242: translate = function (x, y) {3243: if (x == null) {3244: return {x: this._.tx, y: this._.ty, toString: x_y};3245: }3246: this._.tx += +x;3247: this._.ty += +y;3248: switch (this.type) {3249: case "circle":3250: case "ellipse":3251: this.attr({cx: +x + this.attrs.cx, cy: +y + this.attrs.cy});3252: break;3253: case "rect":3254: case "image":3255: case "text":3256: this.attr({x: +x + this.attrs.x, y: +y + this.attrs.y});3257: break;3258: case "path":3259: var path = pathToRelative(this.attrs.path);3260: path[0][1] += +x;3261: path[0][2] += +y;3262: this.attr({path: path});3263: break;3264: }3265: return this;3266: };3267: elproto.animateWith = function (element, params, ms, easing, callback) {3268: for (var i = 0, ii = animationElements.length; i < ii; i++) {3269: if (animationElements[i].el.id == element.id) {3270: params.start = animationElements[i].start;3271: }3272: }3273: return this.animate(params, ms, easing, callback);3274: };3275: elproto.animateAlong = along();3276: elproto.animateAlongBack = along(1);3277: function along(isBack) {3278: return function (path, ms, rotate, callback) {3279: var params = {back: isBack};3280: R.is(rotate, "function") ? (callback = rotate) : (params.rot = rotate);3281: path && path.constructor == Element && (path = path.attrs.path);3282: path && (params.along = path);3283: return this.animate(params, ms, callback);3284: };3285: }3286: function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {3287: var cx = 3 * p1x,3288: bx = 3 * (p2x - p1x) - cx,3289: ax = 1 - cx - bx,3290: cy = 3 * p1y,3291: by = 3 * (p2y - p1y) - cy,3292: ay = 1 - cy - by;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 61: Raphael.js

Page:61/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3293: function sampleCurveX(t) {3294: return ((ax * t + bx) * t + cx) * t;3295: }3296: function solve(x, epsilon) {3297: var t = solveCurveX(x, epsilon);3298: return ((ay * t + by) * t + cy) * t;3299: }3300: function solveCurveX(x, epsilon) {3301: var t0, t1, t2, x2, d2, i;3302: for(t2 = x, i = 0; i < 8; i++) {3303: x2 = sampleCurveX(t2) - x;3304: if (abs(x2) < epsilon) {3305: return t2;3306: }3307: d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;3308: if (abs(d2) < 1e-6) {3309: break;3310: }3311: t2 = t2 - x2 / d2;3312: }3313: t0 = 0;3314: t1 = 1;3315: t2 = x;3316: if (t2 < t0) {3317: return t0;3318: }3319: if (t2 > t1) {3320: return t1;3321: }3322: while (t0 < t1) {3323: x2 = sampleCurveX(t2);3324: if (abs(x2 - x) < epsilon) {3325: return t2;3326: }3327: if (x > x2) {3328: t0 = t2;3329: } else {3330: t1 = t2;3331: }3332: t2 = (t1 - t0) / 2 + t0;3333: }3334: return t2;3335: }3336: return solve(t, 1 / (200 * duration));3337: }3338: elproto.onAnimation = function (f) {3339: this._run = f || 0;3340: return this;3341: };3342: elproto.animate = function (params, ms, easing, callback) {3343: var element = this;3344: element.timeouts = element.timeouts || [];3345: if (R.is(easing, "function") || !easing) {3346: callback = easing || null;3347: }3348: if (element.removed) {3349: callback && callback.call(element);3350: return element;

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 62: Raphael.js

Page:62/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3351: }3352: var from = {},3353: to = {},3354: animateable = false,3355: diff = {};3356: for (var attr in params) if (params[has](attr)) {3357: if (availableAnimAttrs[has](attr) ||

element.paper.customAttributes[has](attr)) {3358: animateable = true;3359: from[attr] = element.attr(attr);3360: (from[attr] == null) && (from[attr] = availableAttrs[attr]);3361: to[attr] = params[attr];3362: switch (availableAnimAttrs[attr]) {3363: case "along":3364: var len = getTotalLength(params[attr]);3365: var point = getPointAtLength(params[attr], len *

!!params.back);3366: var bb = element.getBBox();3367: diff[attr] = len / ms;3368: diff.tx = bb.x;3369: diff.ty = bb.y;3370: diff.sx = point.x;3371: diff.sy = point.y;3372: to.rot = params.rot;3373: to.back = params.back;3374: to.len = len;3375: params.rot && (diff.r = toFloat(element.rotate()) || 0);3376: break;3377: case nu:3378: diff[attr] = (to[attr] - from[attr]) / ms;3379: break;3380: case "colour":3381: from[attr] = R.getRGB(from[attr]);3382: var toColour = R.getRGB(to[attr]);3383: diff[attr] = {3384: r: (toColour.r - from[attr].r) / ms,3385: g: (toColour.g - from[attr].g) / ms,3386: b: (toColour.b - from[attr].b) / ms3387: };3388: break;3389: case "path":3390: var pathes = path2curve(from[attr], to[attr]);3391: from[attr] = pathes[0];3392: var toPath = pathes[1];3393: diff[attr] = [];3394: for (var i = 0, ii = from[attr][length]; i < ii; i++) {3395: diff[attr][i] = [0];3396: for (var j = 1, jj = from[attr][i][length]; j < jj;

j++) {3397: diff[attr][i][j] = (toPath[i][j] -

from[attr][i][j]) / ms;3398: }3399: }3400: break;3401: case "csv":3402: var values = Str(params[attr])[split](separator),3403: from2 = Str(from[attr])[split](separator);3404: switch (attr) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 63: Raphael.js

Page:63/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3405: case "translation":3406: from[attr] = [0, 0];3407: diff[attr] = [values[0] / ms, values[1] / ms];3408: break;3409: case "rotation":3410: from[attr] = (from2[1] == values[1] && from2[2] ==

values[2]) ? from2 : [0, values[1], values[2]];3411: diff[attr] = [(values[0] - from[attr][0]) / ms, 0,

0];3412: break;3413: case "scale":3414: params[attr] = values;3415: from[attr] = Str(from[attr])[split](separator);3416: diff[attr] = [(values[0] - from[attr][0]) / ms,

(values[1] - from[attr][1]) / ms, 0, 0];3417: break;3418: case "clip-rect":3419: from[attr] = Str(from[attr])[split](separator);3420: diff[attr] = [];3421: i = 4;3422: while (i--) {3423: diff[attr][i] = (values[i] - from[attr][i]) /

ms;3424: }3425: break;3426: }3427: to[attr] = values;3428: break;3429: default:3430: values = [].concat(params[attr]);3431: from2 = [].concat(from[attr]);3432: diff[attr] = [];3433: i = element.paper.customAttributes[attr][length];3434: while (i--) {3435: diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) /

ms;3436: }3437: break;3438: }3439: }3440: }3441: if (!animateable) {3442: var attrs = [],3443: lastcall;3444: for (var key in params) if (params[has](key) &&

animKeyFrames.test(key)) {3445: attr = {value: params[key]};3446: key == "from" && (key = 0);3447: key == "to" && (key = 100);3448: attr.key = toInt(key, 10);3449: attrs.push(attr);3450: }3451: attrs.sort(sortByKey);3452: if (attrs[0].key) {3453: attrs.unshift({key: 0, value: element.attrs});3454: }3455: for (i = 0, ii = attrs[length]; i < ii; i++) {3456: keyframesRun(attrs[i].value, element, ms / 100 * attrs[i].key, ms /

100 * (attrs[i - 1] && attrs[i - 1].key || 0), attrs[i - 1] && attrs[i - 1].value.callback);

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 64: Raphael.js

Page:64/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3457: }3458: lastcall = attrs[attrs[length] - 1].value.callback;3459: if (lastcall) {3460: element.timeouts.push(setTimeout(function ()

{lastcall.call(element);}, ms));3461: }3462: } else {3463: var easyeasy = R.easing_formulas[easing];3464: if (!easyeasy) {3465: easyeasy = Str(easing).match(bezierrg);3466: if (easyeasy && easyeasy[length] == 5) {3467: var curve = easyeasy;3468: easyeasy = function (t) {3469: return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3],

+curve[4], ms);3470: };3471: } else {3472: easyeasy = function (t) {3473: return t;3474: };3475: }3476: }3477: animationElements.push({3478: start: params.start || +new Date,3479: ms: ms,3480: easing: easyeasy,3481: from: from,3482: diff: diff,3483: to: to,3484: el: element,3485: t: {x: 0, y: 0}3486: });3487: R.is(callback, "function") && (element._ac = setTimeout(function () {3488: callback.call(element);3489: }, ms));3490: animationElements[length] == 1 && setTimeout(animation);3491: }3492: return this;3493: };3494: elproto.stop = function () {3495: for (var i = 0; i < animationElements.length; i++) {3496: animationElements[i].el.id == this.id && animationElements.splice(i--,

1);3497: }3498: for (i = 0, ii = this.timeouts && this.timeouts.length; i < ii; i++) {3499: clearTimeout(this.timeouts[i]);3500: }3501: this.timeouts = [];3502: clearTimeout(this._ac);3503: delete this._ac;3504: return this;3505: };3506: elproto.translate = function (x, y) {3507: return this.attr({translation: x + " " + y});3508: };3509: elproto[toString] = function () {3510: return "Rapha\xebl\u2019s object";3511: };

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 65: Raphael.js

Page:65/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3512: R.ae = animationElements;3513: // Animation easing end - start: 30663514: // Set start - end: 36183515: var Set = function (items) {3516: this.items = [];3517: this[length] = 0;3518: this.type = "set";3519: if (items) {3520: for (var i = 0, ii = items[length]; i < ii; i++) {3521: if (items[i] && (items[i].constructor == Element ||

items[i].constructor == Set)) {3522: this[this.items[length]] = this.items[this.items[length]] =

items[i];3523: this[length]++;3524: }3525: }3526: }3527: };3528: Set[proto][push] = function () {3529: var item,3530: len;3531: for (var i = 0, ii = arguments[length]; i < ii; i++) {3532: item = arguments[i];3533: if (item && (item.constructor == Element || item.constructor == Set)) {3534: len = this.items[length];3535: this[len] = this.items[len] = item;3536: this[length]++;3537: }3538: }3539: return this;3540: };3541: Set[proto].pop = function () {3542: delete this[this[length]--];3543: return this.items.pop();3544: };3545: for (var method in elproto) if (elproto[has](method)) {3546: Set[proto][method] = (function (methodname) {3547: return function () {3548: for (var i = 0, ii = this.items[length]; i < ii; i++) {3549: this.items[i][methodname][apply](this.items[i], arguments);3550: }3551: return this;3552: };3553: })(method);3554: }3555: Set[proto].attr = function (name, value) {3556: if (name && R.is(name, array) && R.is(name[0], "object")) {3557: for (var j = 0, jj = name[length]; j < jj; j++) {3558: this.items[j].attr(name[j]);3559: }3560: } else {3561: for (var i = 0, ii = this.items[length]; i < ii; i++) {3562: this.items[i].attr(name, value);3563: }3564: }3565: return this;3566: };3567: Set[proto].animate = function (params, ms, easing, callback) {

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
nilray
Highlight
Page 66: Raphael.js

Page:66/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3568: (R.is(easing, "function") || !easing) && (callback = easing || null);3569: var len = this.items[length],3570: i = len,3571: item,3572: set = this,3573: collector;3574: callback && (collector = function () {3575: !--len && callback.call(set);3576: });3577: easing = R.is(easing, string) ? easing : collector;3578: item = this.items[--i].animate(params, ms, easing, collector);3579: while (i--) {3580: this.items[i] && !this.items[i].removed &&

this.items[i].animateWith(item, params, ms, easing, collector);3581: }3582: return this;3583: };3584: Set[proto].insertAfter = function (el) {3585: var i = this.items[length];3586: while (i--) {3587: this.items[i].insertAfter(el);3588: }3589: return this;3590: };3591: Set[proto].getBBox = function () {3592: var x = [],3593: y = [],3594: w = [],3595: h = [];3596: for (var i = this.items[length]; i--;) {3597: var box = this.items[i].getBBox();3598: x[push](box.x);3599: y[push](box.y);3600: w[push](box.x + box.width);3601: h[push](box.y + box.height);3602: }3603: x = mmin[apply](0, x);3604: y = mmin[apply](0, y);3605: return {3606: x: x,3607: y: y,3608: width: mmax[apply](0, w) - x,3609: height: mmax[apply](0, h) - y3610: };3611: };3612: Set[proto].clone = function (s) {3613: s = new Set;3614: for (var i = 0, ii = this.items[length]; i < ii; i++) {3615: s[push](this.items[i].clone());3616: }3617: return s;3618: }; // Set end - start: 35143619: 3620: R.registerFont = function (font) {3621: if (!font.face) {3622: return font;3623: }3624: this.fonts = this.fonts || {};

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

nilray
Highlight
Page 67: Raphael.js

Page:67/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3625: var fontcopy = {3626: w: font.w,3627: face: {},3628: glyphs: {}3629: },3630: family = font.face["font-family"];3631: for (var prop in font.face) if (font.face[has](prop)) {3632: fontcopy.face[prop] = font.face[prop];3633: }3634: if (this.fonts[family]) {3635: this.fonts[family][push](fontcopy);3636: } else {3637: this.fonts[family] = [fontcopy];3638: }3639: if (!font.svg) {3640: fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10);3641: for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) {3642: var path = font.glyphs[glyph];3643: fontcopy.glyphs[glyph] = {3644: w: path.w,3645: k: {},3646: d: path.d && "M" + path.d[rp](/[mlcxtrv]/g, function (command) {3647: return {l: "L", c: "C", x: "z", t: "m", r: "l", v:

"c"}[command] || "M";3648: }) + "z"3649: };3650: if (path.k) {3651: for (var k in path.k) if (path[has](k)) {3652: fontcopy.glyphs[glyph].k[k] = path.k[k];3653: }3654: }3655: }3656: }3657: return font;3658: };3659: paperproto.getFont = function (family, weight, style, stretch) {3660: stretch = stretch || "normal";3661: style = style || "normal";3662: weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder:

800}[weight] || 400;3663: if (!R.fonts) {3664: return;3665: }3666: var font = R.fonts[family];3667: if (!font) {3668: var name = new RegExp("(^|\\s)" + family[rp](/[^\w\d\s+!~.:_-]/g, E) +

"(\\s|$)", "i");3669: for (var fontName in R.fonts) if (R.fonts[has](fontName)) {3670: if (name.test(fontName)) {3671: font = R.fonts[fontName];3672: break;3673: }3674: }3675: }3676: var thefont;3677: if (font) {3678: for (var i = 0, ii = font[length]; i < ii; i++) {3679: thefont = font[i];

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om

Page 68: Raphael.js

Page:68/68Raphael.jsLast modification: 1/27/2011 3:25:16 PMC:\Data\Niloy\Learning\Development\Testing\ramp_pulley\

3680: if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) {

3681: break;3682: }3683: }3684: }3685: return thefont;3686: };3687: paperproto.print = function (x, y, string, font, size, origin, letter_spacing) {3688: origin = origin || "middle"; // baseline|middle3689: letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);3690: var out = this.set(),3691: letters = Str(string)[split](E),3692: shift = 0,3693: path = E,3694: scale;3695: R.is(font, string) && (font = this.getFont(font));3696: if (font) {3697: scale = (size || 16) / font.face["units-per-em"];3698: var bb = font.face.bbox.split(separator),3699: top = +bb[0],3700: height = +bb[1] + (origin == "baseline" ? bb[3] - bb[1] +

(+font.face.descent) : (bb[3] - bb[1]) / 2);3701: for (var i = 0, ii = letters[length]; i < ii; i++) {3702: var prev = i && font.glyphs[letters[i - 1]] || {},3703: curr = font.glyphs[letters[i]];3704: shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] ||

0) + (font.w * letter_spacing) : 0;3705: curr && curr.d && out[push](this.path(curr.d).attr({fill: "#000",

stroke: "none", translation: [shift, 0]}));3706: }3707: out.scale(scale, scale, top, height).translate(x - top, y - height);3708: }3709: return out;3710: };3711: 3712: R.format = function (token, params) {3713: var args = R.is(params, array) ? [0][concat](params) : arguments;3714: token && R.is(token, string) && args[length] - 1 && (token =

token[rp](formatrg, function (str, i) {3715: return args[++i] == null ? E : args[i];3716: }));3717: return token || E;3718: };3719: R.ninja = function () {3720: oldRaphael.was ? (win.Raphael = oldRaphael.is) : delete Raphael;3721: return R;3722: };3723: R.el = elproto;3724: R.st = Set[proto];3725: 3726: oldRaphael.was ? (win.Raphael = R) : (Raphael = R);3727: })();

nilray1/27/2011 3:25:48 PMPSPad editor 4.5.4 (2356) www.pspad.com

Click t

o buy N

OW!PD

F-XChange Viewer

ww

w.docu-track.com Clic

k to b

uy NOW

!PD

F-XChange Viewer

ww

w.docu-track.c

om