Move definitions and test in separate folders

This enables each definition to have a readme if necessary.
Also a .json metadata file to help with package managers.
And last, to have different versions of the definitions.
This commit is contained in:
Boris Yankov
2012-11-18 22:28:44 +02:00
parent b2e85b459f
commit c91c45f9ae
92 changed files with 1354 additions and 1354 deletions
+291
View File
@@ -0,0 +1,291 @@
// Type definitions for Raphael 2.1
// Project: http://raphaeljs.com
// Definitions by: https://github.com/CheCoxshall
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
interface BoundingBox {
x: number;
y: number;
x2: number;
y2: number;
width: number;
height: number;
}
interface RaphaelAnimation {
delay(delay: number): RaphaelAnimation;
repeat(repeat: number): RaphaelAnimation;
}
interface RaphaelFont {
}
interface RaphaelElement {
animate(params: { [key: any]: any; }, ms: number, easing?: string, callback?: Function): RaphaelElement;
animate(animation: RaphaelAnimation): RaphaelElement;
animateWith(el: RaphaelElement, anim: RaphaelAnimation, params: any, ms: number, easing?: string, callback?: Function): RaphaelElement;
animateWith(el: RaphaelElement, anim: RaphaelAnimation, animation: RaphaelAnimation): RaphaelElement;
attr(attrName: string, value: any): RaphaelElement;
attr(params: { [key: any]: any; }): RaphaelElement;
attr(attrName: string): any;
attr(attrNames: string[]): any[];
click(handler: Function): RaphaelElement;
clone(): RaphaelElement;
data(key: string): any;
data(key: string, value: any): RaphaelElement;
dblclick(handler: Function): RaphaelElement;
drag(onmove: (dx: number, dy: number, x: number, y: number, event: DragEvent) =>{ }, onstart: (x: number, y: number, event: DragEvent) =>{ }, onend: (DragEvent) =>{ }, mcontext?: any, scontext?: any, econtext?: any): RaphaelElement;
getBBox(isWithoutTransform?: bool): BoundingBox;
glow(glow?: { width?: number; fill?: bool; opacity?: number; offsetx?: number; offsety?: number; color?: string; }): RraphaelSet;
hide(): RaphaelElement;
hover(f_in: Function, f_out: Function, icontext?: any, ocontext?: any): RaphaelElement;
id: string;
insertAfter(): RaphaelElement;
insertBefore(): RaphaelElement;
isPointInside(x: number, y: number): bool;
isVisible(): bool;
matrix: RaphaelMatrix;
mousedown(handler: Function): RaphaelElement;
mousemove(handler: Function): RaphaelElement;
mouseout(handler: Function): RaphaelElement;
mouseover(handler: Function): RaphaelElement;
mouseup(handler: Function): RaphaelElement;
next: RaphaelElement;
node: Element;
onDragOver(f: Function): RaphaelElement;
paper: RaphaelPaper;
pause(anim?: RaphaelAnimation): RaphaelElement;
prev: RaphaelElement;
raphael: RaphaelStatic;
remove();
removeData(key?: string): RaphaelElement;
resume(anim?: RaphaelAnimation): RaphaelElement;
setTime(anim: RaphaelAnimation);
setTime(anim: RaphaelAnimation, value: number): RaphaelElement;
show(): RaphaelElement;
status(): { anim: RaphaelAnimation; status: number; }[];
status(anim: RaphaelAnimation): number;
status(anim: RaphaelAnimation, value: number): RaphaelElement;
stop(anim?: RaphaelAnimation): RaphaelElement;
toBack(): RaphaelElement;
toFront(): RaphaelElement;
touchcancel(handler: Function): RaphaelElement;
touchend(handler: Function): RaphaelElement;
touchmove(handler: Function): RaphaelElement;
touchstart(handler: Function): RaphaelElement;
transform(): string;
transform(tstr: string): RaphaelElement;
unclick(handler? ): RaphaelElement;
undblclick(handler? ): RaphaelElement;
undrag(): RaphaelElement;
unhover(): RaphaelElement;
unhover(f_in, f_out): RaphaelElement;
unmousedown(handler? ): RaphaelElement;
unmousemove(handler? ): RaphaelElement;
unmouseout(handler? ): RaphaelElement;
unmouseover(handler? ): RaphaelElement;
unmouseup(handler? ): RaphaelElement;
untouchcancel(handler? ): RaphaelElement;
untouchend(handler? ): RaphaelElement;
untouchmove(handler? ): RaphaelElement;
untouchstart(handler? ): RaphaelElement;
}
interface RaphaelPath extends RaphaelElement {
getPointAtLength(length: number): { x: number; y: number; alpha: number; };
getSubpath(from: number, to: number): string;
getTotalLength(): number;
}
interface RraphaelSet {
clear();
exclude(element: RaphaelElement): bool;
forEach(callback: Function, thisArg?: any): RraphaelSet;
pop(): RaphaelElement;
push(...RaphaelElement: any[]): RaphaelElement;
splice(index: number, count: number): RraphaelSet;
splice(index: number, count: number, ...insertion: RaphaelElement[]): RraphaelSet;
length: number;
[key: number]: RaphaelElement;
animate(params: { [key: any]: any; }, ms: number, easing?: string, callback?: Function): RaphaelElement;
animate(animation: RaphaelAnimation): RaphaelElement;
animateWith(el: RaphaelElement, anim: RaphaelAnimation, params: any, ms: number, easing?: string, callback?: Function): RaphaelElement;
animateWith(el: RaphaelElement, anim: RaphaelAnimation, animation: RaphaelAnimation): RaphaelElement;
attr(attrName: string, value: any): RaphaelElement;
attr(params: { [key: any]: any; }): RaphaelElement;
attr(attrName: string): any;
attr(attrNames: string[]): any[];
click(handler: Function): RaphaelElement;
clone(): RaphaelElement;
data(key: string): any;
data(key: string, value: any): RaphaelElement;
dblclick(handler: Function): RaphaelElement;
drag(onmove: (dx: number, dy: number, x: number, y: number, event: DragEvent) =>{ }, onstart: (x: number, y: number, event: DragEvent) =>{ }, onend: (DragEvent) =>{ }, mcontext?: any, scontext?: any, econtext?: any): RaphaelElement;
getBBox(isWithoutTransform?: bool): BoundingBox;
glow(glow?: { width?: number; fill?: bool; opacity?: number; offsetx?: number; offsety?: number; color?: string; }): RraphaelSet;
hide(): RaphaelElement;
hover(f_in: Function, f_out: Function, icontext?: any, ocontext?: any): RaphaelElement;
id: string;
insertAfter(): RaphaelElement;
insertBefore(): RaphaelElement;
isPointInside(x: number, y: number): bool;
isVisible(): bool;
matrix: RaphaelMatrix;
mousedown(handler: Function): RaphaelElement;
mousemove(handler: Function): RaphaelElement;
mouseout(handler: Function): RaphaelElement;
mouseover(handler: Function): RaphaelElement;
mouseup(handler: Function): RaphaelElement;
next: RaphaelElement;
onDragOver(f: Function): RaphaelElement;
paper: RaphaelPaper;
pause(anim?: RaphaelAnimation): RaphaelElement;
prev: RaphaelElement;
raphael: RaphaelStatic;
remove();
removeData(key?: string): RaphaelElement;
resume(anim?: RaphaelAnimation): RaphaelElement;
setTime(anim: RaphaelAnimation);
setTime(anim: RaphaelAnimation, value: number): RaphaelElement;
show(): RaphaelElement;
status(): { anim: RaphaelAnimation; status: number; }[];
status(anim: RaphaelAnimation): number;
status(anim: RaphaelAnimation, value: number): RaphaelElement;
stop(anim?: RaphaelAnimation): RaphaelElement;
toBack(): RaphaelElement;
toFront(): RaphaelElement;
touchcancel(handler: Function): RaphaelElement;
touchend(handler: Function): RaphaelElement;
touchmove(handler: Function): RaphaelElement;
touchstart(handler: Function): RaphaelElement;
transform(): string;
transform(tstr: string): RaphaelElement;
unclick(handler? ): RaphaelElement;
undblclick(handler? ): RaphaelElement;
undrag(): RaphaelElement;
unhover(): RaphaelElement;
unhover(f_in, f_out): RaphaelElement;
unmousedown(handler? ): RaphaelElement;
unmousemove(handler? ): RaphaelElement;
unmouseout(handler? ): RaphaelElement;
unmouseover(handler? ): RaphaelElement;
unmouseup(handler? ): RaphaelElement;
untouchcancel(handler? ): RaphaelElement;
untouchend(handler? ): RaphaelElement;
untouchmove(handler? ): RaphaelElement;
untouchstart(handler? ): RaphaelElement;
}
interface RaphaelMatrix {
add(a: number, b: number, c: number, d: number, e: number, f: number, matrix: RaphaelMatrix): RaphaelMatrix;
clone(): RaphaelMatrix;
invert(): RaphaelMatrix;
rotate(a: number, x: number, y: number);
scale(x: number, y?: number, cx?: number, cy?: number);
split(): { dx: number; dy: number; scalex: number; scaley: number; shear: number; rotate: number; isSimple: bool; };
toTransformString(): string;
translate(x: number, y: number);
x(x: number, y: number);
y(x: number, y: number);
}
interface RaphaelPaper {
add(JSON): RraphaelSet;
bottom: RaphaelElement;
canvas: Element;
circle(x: number, y: number, r: number): RaphaelElement;
clear();
defs: Element;
ellipse(x: number, y: number, rx: number, ry: number): RaphaelElement;
forEach(callback: number, thisArg: any): RaphaelStatic;
getById(id: number): RaphaelElement;
getElementByPoint(x: number, y: number): RaphaelElement;
getElementsByPoint(x: number, y: number): RraphaelSet;
getFont(family: string, weight?: string, style?: string, stretch?: string): RaphaelFont;
getFont(family: string, weight?: number, style?: string, stretch?: string): RaphaelFont;
height: number;
image(src: string, x: number, y: number, width: number, height: number): RaphaelElement;
path(pathString?: string): RaphaelPath;
print(x: number, y: number, str: string, font: RaphaelFont, size?: number, origin?: string, letter_spacing?: number): RaphaelPath;
rect(x: number, y: number, width: number, height: number, r?: number): RaphaelElement;
remove();
renderfix();
safari();
set(elements?: RaphaelElement[]): RraphaelSet;
setFinish();
setSize(width: number, height: number);
setStart();
setViewBox(x: number, y: number, w: number, h: number, fit: bool);
text(x: number, y: number, text: string): RaphaelElement;
top: RaphaelElement;
width: number;
}
interface RaphaelStatic {
(container: HTMLElement, width: number, height: number, callback?: Function): RaphaelPaper;
(container: string, width: number, height: number, callback?: Function): RaphaelPaper;
(x: number, y: number, width: number, height: number, callback?: Function): RaphaelPaper;
(all: Array, callback?: Function): RaphaelPaper;
(onReadyCallback?: Function): RaphaelPaper;
angle(x1: number, y1: number, x2: number, y2: number, x3?: number, y3?: number): number;
animation(params: any, ms: number, easing?: string, callback?: Function): RaphaelAnimation;
bezierBBox(p1x: number, p1y: number, c1x: number, c1y: number, c2x: number, c2y: number, p2x: number, p2y: number): { min: { x: number; y: number; }; max: { x: number; y: number; }; };
bezierBBox(bez: Array): { min: { x: number; y: number; }; max: { x: number; y: number; }; };
color(clr: string): { r: number; g: number; b: number; hex: string; error: bool; h: number; s: number; v: number; l: number; };
createUUID(): string;
deg(deg: number): number;
easing_formulas: any;
el: any;
findDotsAtSegment(p1x: number, p1y: number, c1x: number, c1y: number, c2x: number, c2y: number, p2x: number, p2y: number, t: number): { x: number; y: number; m: { x: number; y: number; }; n: { x: number; y: number; }; start: { x: number; y: number; }; end: { x: number; y: number; }; alpha: number; };
fn: any;
format(token: string, ...parameters: any[]): string;
fullfill(token: string, json: JSON): string;
getColor(value?: number): string;
getColor: { reset(); };
getPointAtLength(path: string, length: number): { x: number; y: number; alpha: number; };
getRGB(colour: string): { r: number; g: number; b: number; hex: string; error: bool; };
getSubpath(path: string, from: number, to: number): string;
getTotalLength(path: string): number;
hsb(h: number, s: number, b: number): string;
hsb2rgb(h: number, s: number, v: number): { r: number; g: number; b: number; hex: string; };
hsl(h: number, s: number, l: number): string;
hsl2rgb(h: number, s: number, l: number): { r: number; g: number; b: number; hex: string; };
is(o: any, type: string): bool;
isBBoxIntersect(bbox1: string, bbox2: string): bool;
isPointInsideBBox(bbox: string, x: number, y: number): bool;
isPointInsidePath(path: string, x: number, y: number): bool;
matrix(a: number, b: number, c: number, d: number, e: number, f: number): RaphaelMatrix;
ninja();
parsePathString(pathString: string): string[];
parsePathString(pathString: string[]): string[];
parseTransformString(TString: string): string[];
parseTransformString(TString: string[]): string[];
path2curve(pathString: string): string[];
path2curve(pathString: string[]): string[];
pathBBox(path: string): BoundingBox;
pathIntersection(path1: string, path2: string): { x: number; y: number; t1: number; t2: number; segment1: number; segment2: number; bez1: Array; bez2: Array; }[];
pathToRelative(pathString: string): string[];
pathToRelative(pathString: string[]): string[];
rad(deg: number): number;
registerFont(font: RaphaelFont): RaphaelFont;
rgb(r: number, g: number, b: number): string;
rgb2hsb(r: number, g: number, b: number): { h: number; s: number; b: number; };
rgb2hsl(r: number, g: number, b: number): { h: number; s: number; l: number; };
setWindow(newwin: Window);
snapTo(values: number, value: number, tolerance?: number): number;
snapTo(values: number[], value: number, tolerance?: number): number;
st: any;
svg: bool;
toMatrix(path: string, transform: string): RaphaelMatrix;
toMatrix(path: string, transform: string[]): RaphaelMatrix;
transformPath(path: string, transform: string): string;
transformPath(path: string, transform: string[]): string;
type: string;
vml: bool;
}
declare var Raphael: RaphaelStatic;
+56
View File
@@ -0,0 +1,56 @@
/// <reference path="../Definitions/raphael-2.1.d.ts" />
var paper = Raphael(10, 50, 320, 200);
var circle = paper.circle(50, 40, 10);
circle.attr("fill", "#f00");
circle.attr("stroke", "#fff");
var anim = Raphael.animation({ cx: 10, cy: 20 }, 2e3);
paper.circle(320, 240, 60).animate({ fill: "#223fa3", stroke: "#000", "stroke-width": 80, "stroke-opacity": 0.5 }, 2000);
declare var img, src;
img.style.display = "none";
var r = Raphael("holder", 600, 540);
r.image(img.src, 140, 140, 320, 240);
document.getElementById("holder").innerHTML = "";
var R = Raphael("holder", 640, 480);
R.circle(320, 240, 200).attr({ fill: "#000", "fill-opacity": .5, "stroke-width": 5 });
var img2 = R.image(src, 160, 120, 320, 240);
var butt1 = R.set(),
butt2 = R.set();
butt1.push(R.circle(24.833, 26.917, 26.667).attr({ stroke: "#ccc", fill: "#fff", "fill-opacity": .4, "stroke-width": 2 }),
R.path("M12.582,9.551C3.251,16.237,0.921,29.021,7.08,38.564l-2.36,1.689l4.893,2.262l4.893,2.262l-0.568-5.36l-0.567-5.359l-2.365,1.694c-4.657-7.375-2.83-17.185,4.352-22.33c7.451-5.338,17.817-3.625,23.156,3.824c5.337,7.449,3.625,17.813-3.821,23.152l2.857,3.988c9.617-6.893,11.827-20.277,4.935-29.896C35.591,4.87,22.204,2.658,12.582,9.551z").attr({ stroke: "none", fill: "#000" }),
R.circle(24.833, 26.917, 26.667).attr({ fill: "#fff", opacity: 0 }));
butt2.push(R.circle(24.833, 26.917, 26.667).attr({ stroke: "#ccc", fill: "#fff", "fill-opacity": .4, "stroke-width": 2 }),
R.path("M37.566,9.551c9.331,6.686,11.661,19.471,5.502,29.014l2.36,1.689l-4.893,2.262l-4.893,2.262l0.568-5.36l0.567-5.359l2.365,1.694c4.657-7.375,2.83-17.185-4.352-22.33c-7.451-5.338-17.817-3.625-23.156,3.824C6.3,24.695,8.012,35.06,15.458,40.398l-2.857,3.988C2.983,37.494,0.773,24.109,7.666,14.49C14.558,4.87,27.944,2.658,37.566,9.551z").attr({ stroke: "none", fill: "#000" }),
R.circle(24.833, 26.917, 26.667).attr({ fill: "#fff", opacity: 0 }));
var butt3: RaphaelMatrix, butt4: RaphaelMatrix, angle: number;
butt3.translate(10, 181);
butt4.translate(10, 245);
butt3[2].click(function () {
angle -= 90;
img.stop().animate({ transform: "r" + angle }, 1000, "<>");
}).mouseover(function () {
butt1[1].animate({ fill: "#fc0" }, 300);
}).mouseout(function () {
butt1[1].stop().attr({ fill: "#000" });
});
butt2[2].click(function () {
angle += 90;
img.animate({ transform: "r" + angle }, 1000, "<>");
}).mouseover(function () {
butt2[1].animate({ fill: "#fc0" }, 300);
}).mouseout(function () {
butt2[1].stop().attr({ fill: "#000" });
});
var hldr = document.getElementById("holder"),
text = hldr.innerHTML.replace(/^\s+|\s+$|<[^>]+>/g, "");
hldr.innerHTML = "";
var R2 = Raphael("holder", 640, 480),
txt = [],
attr = { font: "50px Helvetica", opacity: 0.5 };
txt[0] = R2.text(320, 240, text).attr(attr).attr({ fill: "#0f0" });
R.safari();