• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * This externs file prevents the Closure JS compiler from minifying away
3 * names of objects created by Emscripten.
4 * Basically, by defining empty objects and functions here, Closure will
5 * know not to rename them.  This is needed because of our pre-js files,
6 * that is, the JS we hand-write to bundle into PathKit.
7 *
8 * Emscripten does not support automatically generating an externs file, so we
9 * do it by hand. The general process is to write some JS code, and then put any
10 * calls to PathKit or related things in here. Running ./compile.sh and then
11 * looking at the minified results or running the Release-PathKit trybot should
12 * verify nothing was missed. Optionally, looking directly at the minified
13 * pathkit.js can be useful when developing locally.
14 *
15 * Docs:
16 *   https://github.com/cljsjs/packages/wiki/Creating-Externs
17 *   https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System
18 *
19 * Example externs:
20 *   https://github.com/google/closure-compiler/tree/master/externs
21 */
22
23var PathKit = {
24	SkBits2FloatUnsigned: function(num) {},
25	_malloc: function(size) {},
26	_free: function(ptr) {},
27	onRuntimeInitialized: function() {},
28	_FromCmds: function(ptr, size) {},
29	loadCmdsTypedArray: function(arr) {},
30	FromCmds: function(arr) {},
31	_SkCubicMap: function(cp1, cp2) {},
32	cubicYFromX: function(cpx1, cpy1, cpx2, cpy2, X) {},
33	cubicPtFromT: function(cpx1, cpy1, cpx2, cpy2, T) {},
34
35	/**
36	 * @type {Float32Array}
37	 */
38	HEAPF32: {},
39
40	SkPath: {
41		_addPath: function(path, scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2) {},
42		_arc: function(x, y, radius, startAngle, endAngle, ccw) {},
43		_arcTo: function(x1, y1, x2, y2, radius) {},
44		_dash: function(on, off, phase) {},
45		_close: function() {},
46		_conicTo: function(x1, y1, x2, y2, w) {},
47		copy: function() {},
48		_cubicTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {},
49		_ellipse: function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {},
50		_lineTo: function(x1, y1) {},
51		_moveTo: function(x1, y1) {},
52		_op: function(otherPath, op) {},
53		_quadTo: function(cpx, cpy, x, y) {},
54		_rect: function(x, y, w, h) {},
55		_simplify: function() {},
56		_stroke: function(opts) {},
57		_trim: function(startT, stopT, isComplement) {},
58		_transform: function() {}, // takes 1 or 9 params
59	},
60
61	StrokeCap: {
62		BUTT: {},
63		ROUND: {},
64		SQUARE: {},
65	},
66	StrokeJoin: {
67		MITER: {},
68		ROUND: {},
69		BEVEL: {},
70	}
71};
72
73// Define StrokeOpts object
74var StrokeOpts = {};
75StrokeOpts.prototype.width;
76StrokeOpts.prototype.miter_limit;
77StrokeOpts.prototype.cap;
78StrokeOpts.prototype.join;
79
80// Define CubicMap object
81var CubicMap = {};
82CubicMap.prototype.computeYFromX = function(x) {};
83CubicMap.prototype.computePtFromT = function(t) {};
84
85
86// For whatever reason, the closure compiler thinks it can rename some of our
87// prototype methods.  Not entirely sure why.
88// Listing them here prevents that.
89PathKit.SkPath.prototype.addPath = function() {};
90PathKit.SkPath.prototype.arc = function(x, y, radius, startAngle, endAngle, ccw) {};
91PathKit.SkPath.prototype.arcTo = function(x1, y1, x2, y2, radius) {};
92PathKit.SkPath.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
93PathKit.SkPath.prototype.close = function() {};
94PathKit.SkPath.prototype.closePath = function() {};
95PathKit.SkPath.prototype.conicTo = function(x1, y1, x2, y2, w) {};
96PathKit.SkPath.prototype.cubicTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
97PathKit.SkPath.prototype.dash = function(on, off, phase) {};
98PathKit.SkPath.prototype.ellipse = function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {};
99PathKit.SkPath.prototype.lineTo = function(x, y) {};
100PathKit.SkPath.prototype.moveTo = function(x, y) {};
101PathKit.SkPath.prototype.op = function(otherPath, op) {};
102PathKit.SkPath.prototype.quadTo = function(x1, y1, x2, y2) {};
103PathKit.SkPath.prototype.quadraticCurveTo = function(x1, y1, x2, y2) {};
104PathKit.SkPath.prototype.rect = function(x, y, w, h) {};
105PathKit.SkPath.prototype.simplify = function() {};
106PathKit.SkPath.prototype.stroke = function(opts) {};
107PathKit.SkPath.prototype.transform = function() {};
108PathKit.SkPath.prototype.trim = function(startT, stopT, isComplement) {};
109// The following was taken from https://github.com/google/closure-compiler/blob/master/contrib/externs/svg.js
110
111/**
112 * @constructor
113 */
114function SVGMatrix(){}
115
116
117/**
118 * @type {number}
119 */
120SVGMatrix.prototype.a;
121
122
123/**
124 * @type {number}
125 */
126SVGMatrix.prototype.b;
127
128
129/**
130 * @type {number}
131 */
132SVGMatrix.prototype.c;
133
134
135/**
136 * @type {number}
137 */
138SVGMatrix.prototype.d;
139
140
141/**
142 * @type {number}
143 */
144SVGMatrix.prototype.e;
145
146
147/**
148 * @type {number}
149 */
150SVGMatrix.prototype.f;