UNPKG

273 kBPlain TextView Raw
1/*
2* Copyright (C) 1998-2021 by Northwoods Software Corporation. All Rights Reserved.
3*/
4
5// This file holds definitions of all standard shape figures -- string values for Shape.figure.
6// You do not need to load this file in order to use named Shape figure.
7
8// The following figures are built-in to the go.js library and thus do not need to be redefined:
9// Rectangle, Square, RoundedRectangle, Border, Ellipse, Circle,
10// TriangleRight, TriangleDown, TriangleLeft, TriangleUp, Triangle,
11// LineH, LineV, None, BarH, BarV, MinusLine, PlusLine, XLine
12// If you need any of the other figures that are defined in this file, we suggest that you copy
13// just those definitions into your own code. Do not load this file unless you really want to
14// define a lot of code that your app does not use and will not get garbage-collected.
15
16import * as go from '../release/go-module.js';
17
18// The following functions and variables are used throughout this file:
19
20/**
21 * @hidden @internal
22 * This FigureParameter class describes various properties each parameter uses in figures.
23 */
24export class FigureParameter {
25 public static definedParameters: {[key: string]: Array<FigureParameter>} = {};
26 private _name: string;
27 private _defaultValue: number;
28 private _minimum: number;
29 private _maximum: number;
30 constructor(name: string, def: number, min?: number, max?: number) {
31 if (min === undefined) min = 0.0;
32 if (max === undefined) max = Infinity;
33 this._name = name;
34 this._defaultValue = def;
35 this._minimum = min;
36 this._maximum = max;
37 // (go.Shape as any)['_FigureParameters'] = {};
38 }
39
40 /**
41 * Gets or sets the name of the figure.
42 */
43 get name(): string { return this._name; }
44 set name(val: string) {
45 if (typeof val !== 'string' || val === '') throw new Error('Shape name must be a valid string.');
46 this._name = val;
47 }
48
49 /**
50 * Gets or sets the default value for the parameter.
51 */
52 get defaultValue(): number { return this._defaultValue; }
53 set defaultValue(val: number) {
54 if (typeof val !== 'number' || isNaN(val)) throw new Error('The default value must be a real number, not: ' + val);
55 this._defaultValue = val;
56 }
57
58 /**
59 * Gets or sets the minimum value allowed for the figure parameter.
60 */
61 get minimum(): number { return this._minimum; }
62 set minimum(val: number) {
63 if (typeof val !== 'number' || isNaN(val)) throw new Error('Minimum must be a real number, not: ' + val);
64 this._minimum = val;
65 }
66
67 /**
68 * Gets or sets the maximum value allowed for the figure parameter.
69 */
70 get maximum(): number { return this._maximum; }
71 set maximum(val: number) {
72 if (typeof val !== 'number' || isNaN(val)) throw new Error('Maximum must be a real number, not: ' + val);
73 this._maximum = val;
74 }
75
76 /**
77 * This static function gets a FigureParameter for a particular figure name.
78 * @param {String} figurename
79 * @param {number} index, currently must be either 0 or 1
80 * @return {FigureParameter}
81 */
82 public static getFigureParameter(figurename: string, index: number): FigureParameter | null {
83 // const arr = (go.Shape as any)['_FigureParameters'][figurename];
84 const arr = FigureParameter.definedParameters[figurename];
85 if (!arr) return null;
86 return arr[index];
87 }
88
89 /**
90 * This static function sets a FigureParameter for a particular figure name.
91 * @param {String} figurename
92 * @param {number} index, currently must be either 0 or 1
93 * @param {FigureParameter} figparam
94 */
95 public static setFigureParameter(figurename: string, index: number, figparam: FigureParameter) {
96 if (!(figparam instanceof FigureParameter)) throw new Error('Third argument to FigureParameter.setFigureParameter is not FigureParameter: ' + figparam);
97 if (figparam.defaultValue < figparam.minimum || figparam.defaultValue > figparam.maximum) {
98 throw new Error('defaultValue must be between minimum and maximum, not: ' + figparam.defaultValue);
99 }
100 // const paramObj = (go.Shape as any)['_FigureParameters'];
101 // let arr = paramObj[figurename];
102 let arr: Array<FigureParameter> = FigureParameter.definedParameters[figurename];
103 if (!arr) {
104 // arr = [];
105 // paramObj[figurename] = arr;
106 arr = [];
107 FigureParameter.definedParameters[figurename] = arr;
108 }
109 arr[index] = figparam;
110 }
111}
112/** @ignore */
113const _CachedPoints: Array<go.Point> = [];
114
115/**
116 * @ignore
117 * @param {number} x
118 * @param {number} y
119 * @return {Point}
120 */
121function tempPointAt(x: number, y: number): go.Point {
122 const temp = _CachedPoints.pop();
123 if (temp === undefined) return new go.Point(x, y);
124 temp.x = x;
125 temp.y = y;
126 return temp;
127}
128
129/**
130 * @ignore
131 * @return {Point}
132 */
133function tempPoint(): go.Point {
134 const temp = _CachedPoints.pop();
135 if (temp === undefined) return new go.Point();
136 return temp;
137}
138
139/**
140 * @ignore
141 * @param {Point} temp
142 */
143function freePoint(temp: go.Point) {
144 _CachedPoints.push(temp);
145}
146
147/**
148 * @ignore
149 * @param {number} p1x
150 * @param {number} p1y
151 * @param {number} p2x
152 * @param {number} p2y
153 * @param {number} q1x
154 * @param {number} q1y
155 * @param {number} q2x
156 * @param {number} q2y
157 * @param {Point} result
158 * @return {Point}
159 */
160function getIntersection(p1x: number, p1y: number, p2x: number, p2y: number, q1x: number, q1y: number, q2x: number, q2y: number, result: go.Point): go.Point {
161 const dx1 = p1x - p2x;
162 const dx2 = q1x - q2x;
163 let x;
164 let y;
165
166 if (dx1 === 0 || dx2 === 0) {
167 if (dx1 === 0) {
168 const m2 = (q1y - q2y) / dx2;
169 const b2 = q1y - m2 * q1x;
170 x = p1x;
171 y = m2 * x + b2;
172 } else {
173 const m1 = (p1y - p2y) / dx1;
174 const b1 = p1y - m1 * p1x;
175 x = q1x;
176 y = m1 * x + b1;
177 }
178 } else {
179 const m1 = (p1y - p2y) / dx1;
180 const m2 = (q1y - q2y) / dx2;
181 const b1 = p1y - m1 * p1x;
182 const b2 = q1y - m2 * q1x;
183
184 x = (b2 - b1) / (m1 - m2);
185 y = m1 * x + b1;
186 }
187
188 result.x = x;
189 result.y = y;
190 return result;
191}
192
193/**
194 * @ignore
195 * @param {number} startx
196 * @param {number} starty
197 * @param {number} c1x
198 * @param {number} c1y
199 * @param {number} c2x
200 * @param {number} c2y
201 * @param {number} endx
202 * @param {number} endy
203 * @param {number} fraction
204 * @param {Point} curve1cp1 // modified result control point
205 * @param {Point} curve1cp2 // modified result control point
206 * @param {Point} midpoint // modified result
207 * @param {Point} curve2cp1 // modified result control point
208 * @param {Point} curve2cp2 // modified result control point
209 */
210function breakUpBezier(startx: number, starty: number, c1x: number, c1y: number, c2x: number, c2y: number, endx: number, endy: number, fraction: number,
211 curve1cp1: go.Point, curve1cp2: go.Point, midpoint: go.Point, curve2cp1: go.Point, curve2cp2: go.Point) {
212 const fo = 1 - fraction;
213 const so = fraction;
214 const m1x = (startx * fo + c1x * so);
215 const m1y = (starty * fo + c1y * so);
216 const m2x = (c1x * fo + c2x * so);
217 const m2y = (c1y * fo + c2y * so);
218 const m3x = (c2x * fo + endx * so);
219 const m3y = (c2y * fo + endy * so);
220 const m12x = (m1x * fo + m2x * so);
221 const m12y = (m1y * fo + m2y * so);
222 const m23x = (m2x * fo + m3x * so);
223 const m23y = (m2y * fo + m3y * so);
224 const m123x = (m12x * fo + m23x * so);
225 const m123y = (m12y * fo + m23y * so);
226
227 curve1cp1.x = m1x;
228 curve1cp1.y = m1y;
229
230 curve1cp2.x = m12x;
231 curve1cp2.y = m12y;
232
233 midpoint.x = m123x;
234 midpoint.y = m123y;
235
236 curve2cp1.x = m23x;
237 curve2cp1.y = m23y;
238
239 curve2cp2.x = m3x;
240 curve2cp2.y = m3y;
241}
242
243const GeneratorEllipseSpot1 = new go.Spot(0.156, 0.156);
244
245const GeneratorEllipseSpot2 = new go.Spot(0.844, 0.844);
246
247const KAPPA = 4 * ((Math.sqrt(2) - 1) / 3);
248
249
250// PREDEFINED figures, built into the v2.0 library:
251
252// These first few are commented out due to optimizations in the built-in definitions.
253
254//go.Shape.defineFigureGenerator('Rectangle', (shape, w, h) => { // predefined in 2.0
255// const geo = new go.Geometry(go.Geometry.Rectangle);
256// geo.startX = 0;
257// geo.startY = 0;
258// geo.endX = w;
259// geo.endY = h;
260// return geo;
261//});
262
263//go.Shape.defineFigureGenerator('Square', (shape, w, h) => { // predefined in 2.0
264// const geo = new go.Geometry(go.Geometry.Rectangle);
265// geo.startX = 0;
266// geo.startY = 0;
267// geo.endX = w;
268// geo.endY = h;
269// geo.defaultStretch = go.GraphObject.Uniform;
270// return geo;
271//});
272
273FigureParameter.setFigureParameter('RoundedRectangle', 0, new FigureParameter('CornerRounding', 5));
274go.Shape.defineFigureGenerator('RoundedRectangle', (shape, w, h) => { // predefined in 2.0
275 let param1 = shape ? shape.parameter1 : NaN;
276 if (isNaN(param1) || param1 < 0) param1 = 5; // default corner
277 param1 = Math.min(param1, w / 3);
278 param1 = Math.min(param1, h / 3);
279
280 const cpOffset = param1 * KAPPA;
281 const geo = new go.Geometry()
282 .add(new go.PathFigure(param1, 0, true)
283 .add(new go.PathSegment(go.PathSegment.Line, w - param1, 0))
284 .add(new go.PathSegment(go.PathSegment.Bezier, w, param1, w - cpOffset, 0, w, cpOffset))
285 .add(new go.PathSegment(go.PathSegment.Line, w, h - param1))
286 .add(new go.PathSegment(go.PathSegment.Bezier, w - param1, h, w, h - cpOffset, w - cpOffset, h))
287 .add(new go.PathSegment(go.PathSegment.Line, param1, h))
288 .add(new go.PathSegment(go.PathSegment.Bezier, 0, h - param1, cpOffset, h, 0, h - cpOffset))
289 .add(new go.PathSegment(go.PathSegment.Line, 0, param1))
290 .add(new go.PathSegment(go.PathSegment.Bezier, param1, 0, 0, cpOffset, cpOffset, 0).close()));
291 if (cpOffset > 1) {
292 geo.spot1 = new go.Spot(0, 0, cpOffset, cpOffset);
293 geo.spot2 = new go.Spot(1, 1, -cpOffset, -cpOffset);
294 }
295 return geo;
296});
297
298go.Shape.defineFigureGenerator('Border', 'RoundedRectangle'); // predefined in 2.0
299
300//go.Shape.defineFigureGenerator('Ellipse', (shape, w, h) => { // predefined in 2.0
301// const geo = new go.Geometry(go.Geometry.Ellipse);
302// geo.startX = 0;
303// geo.startY = 0;
304// geo.endX = w;
305// geo.endY = h;
306// geo.spot1 = GeneratorEllipseSpot1;
307// geo.spot2 = GeneratorEllipseSpot2;
308// return geo;
309//});
310
311//go.Shape.defineFigureGenerator('Circle', (shape, w, h) => { // predefined in 2.0
312// const geo = new go.Geometry(go.Geometry.Ellipse);
313// geo.startX = 0;
314// geo.startY = 0;
315// geo.endX = w;
316// geo.endY = h;
317// geo.spot1 = GeneratorEllipseSpot1;
318// geo.spot2 = GeneratorEllipseSpot2;
319// geo.defaultStretch = go.GraphObject.Uniform;
320// return geo;
321//});
322
323go.Shape.defineFigureGenerator('TriangleRight', (shape, w, h) => { // predefined in 2.0
324 return new go.Geometry()
325 .add(new go.PathFigure(0, 0)
326 .add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h))
327 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()))
328 .setSpots(0, 0.25, 0.5, 0.75);
329});
330
331go.Shape.defineFigureGenerator('TriangleDown', (shape, w, h) => { // predefined in 2.0
332 return new go.Geometry()
333 .add(new go.PathFigure(0, 0)
334 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
335 .add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h).close()))
336 .setSpots(0.25, 0, 0.75, 0.5);
337});
338
339go.Shape.defineFigureGenerator('TriangleLeft', (shape, w, h) => { // predefined in 2.0
340 return new go.Geometry()
341 .add(new go.PathFigure(w, h)
342 .add(new go.PathSegment(go.PathSegment.Line, 0, 0.5 * h))
343 .add(new go.PathSegment(go.PathSegment.Line, w, 0).close()))
344 .setSpots(0.5, 0.25, 1, 0.75);
345});
346
347go.Shape.defineFigureGenerator('TriangleUp', (shape, w, h) => { // predefined in 2.0
348 return new go.Geometry()
349 .add(new go.PathFigure(w, h)
350 .add(new go.PathSegment(go.PathSegment.Line, 0, h))
351 .add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0).close()))
352 .setSpots(0.25, 0.5, 0.75, 1);
353});
354
355go.Shape.defineFigureGenerator('Triangle', 'TriangleUp'); // predefined in 2.0
356
357go.Shape.defineFigureGenerator('Diamond', (shape, w, h) => { // predefined in 2.0
358 return new go.Geometry()
359 .add(new go.PathFigure(0.5 * w, 0)
360 .add(new go.PathSegment(go.PathSegment.Line, 0, 0.5 * h))
361 .add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h))
362 .add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h).close()))
363 .setSpots(0.25, 0.25, 0.75, 0.75);
364});
365
366go.Shape.defineFigureGenerator('LineH', (shape, w, h) => { // predefined in 2.0
367 const geo = new go.Geometry(go.Geometry.Line);
368 geo.startX = 0;
369 geo.startY = h / 2;
370 geo.endX = w;
371 geo.endY = h / 2;
372 return geo;
373});
374
375go.Shape.defineFigureGenerator('LineV', (shape, w, h) => { // predefined in 2.0
376 const geo = new go.Geometry(go.Geometry.Line);
377 geo.startX = w / 2;
378 geo.startY = 0;
379 geo.endX = w / 2;
380 geo.endY = h;
381 return geo;
382});
383
384go.Shape.defineFigureGenerator('BarH', 'Rectangle'); // predefined in 2.0
385go.Shape.defineFigureGenerator('BarV', 'Rectangle'); // predefined in 2.0
386go.Shape.defineFigureGenerator('MinusLine', 'LineH'); // predefined in 2.0
387
388go.Shape.defineFigureGenerator('PlusLine', (shape, w, h) => { // predefined in 2.0
389 return new go.Geometry()
390 .add(new go.PathFigure(0, h / 2, false)
391 .add(new go.PathSegment(go.PathSegment.Line, w, h / 2))
392 .add(new go.PathSegment(go.PathSegment.Move, w / 2, 0))
393 .add(new go.PathSegment(go.PathSegment.Line, w / 2, h)));
394});
395
396go.Shape.defineFigureGenerator('XLine', (shape, w, h) => { // predefined in 2.0
397 return new go.Geometry()
398 .add(new go.PathFigure(0, h, false)
399 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
400 .add(new go.PathSegment(go.PathSegment.Move, 0, 0))
401 .add(new go.PathSegment(go.PathSegment.Line, w, h)));
402});
403
404
405// OPTIONAL figures, not predefined in the v2.0 library:
406
407go.Shape.defineFigureGenerator('AsteriskLine', (shape, w, h) => {
408 const offset = .2 / Math.SQRT2;
409 return new go.Geometry()
410 .add(new go.PathFigure(offset * w, (1 - offset) * h, false)
411 .add(new go.PathSegment(go.PathSegment.Line, (1 - offset) * w, offset * h))
412 .add(new go.PathSegment(go.PathSegment.Move, offset * w, offset * h))
413 .add(new go.PathSegment(go.PathSegment.Line, (1 - offset) * w, (1 - offset) * h))
414 .add(new go.PathSegment(go.PathSegment.Move, 0, h / 2))
415 .add(new go.PathSegment(go.PathSegment.Line, w, h / 2))
416 .add(new go.PathSegment(go.PathSegment.Move, w / 2, 0))
417 .add(new go.PathSegment(go.PathSegment.Line, w / 2, h)));
418});
419
420go.Shape.defineFigureGenerator('CircleLine', (shape, w, h) => {
421 const rad = w / 2;
422 const geo = new go.Geometry()
423 .add(new go.PathFigure(w, w / 2, false) // clockwise
424 .add(new go.PathSegment(go.PathSegment.Arc, 0, 360, rad, rad, rad, rad).close()));
425 geo.spot1 = GeneratorEllipseSpot1;
426 geo.spot2 = GeneratorEllipseSpot2;
427 geo.defaultStretch = go.GraphObject.Uniform;
428 return geo;
429});
430
431go.Shape.defineFigureGenerator('Line1', (shape, w, h) => {
432 const geo = new go.Geometry(go.Geometry.Line);
433 geo.startX = 0;
434 geo.startY = 0;
435 geo.endX = w;
436 geo.endY = h;
437 return geo;
438});
439
440go.Shape.defineFigureGenerator('Line2', (shape, w, h) => {
441 const geo = new go.Geometry(go.Geometry.Line);
442 geo.startX = w;
443 geo.startY = 0;
444 geo.endX = 0;
445 geo.endY = h;
446 return geo;
447});
448
449go.Shape.defineFigureGenerator('Curve1', (shape, w, h) => {
450 return new go.Geometry()
451 .add(new go.PathFigure(0, 0, false)
452 .add(new go.PathSegment(go.PathSegment.Bezier, w, h, KAPPA * w, 0, w, (1 - KAPPA) * h)));
453});
454
455go.Shape.defineFigureGenerator('Curve2', (shape, w, h) => {
456 return new go.Geometry()
457 .add(new go.PathFigure(0, 0, false)
458 .add(new go.PathSegment(go.PathSegment.Bezier, w, h, 0, KAPPA * h, (1 - KAPPA) * w, h)));
459});
460
461go.Shape.defineFigureGenerator('Curve3', (shape, w, h) => {
462 return new go.Geometry()
463 .add(new go.PathFigure(w, 0, false)
464 .add(new go.PathSegment(go.PathSegment.Bezier, 0, h, w, KAPPA * h, KAPPA * w, h)));
465});
466
467go.Shape.defineFigureGenerator('Curve4', (shape, w, h) => {
468 return new go.Geometry()
469 .add(new go.PathFigure(w, 0, false)
470 .add(new go.PathSegment(go.PathSegment.Bezier, 0, h, (1 - KAPPA) * w, 0, 0, (1 - KAPPA) * h)));
471});
472
473go.Shape.defineFigureGenerator('TriangleDownLeft', (shape, w, h) => {
474 return new go.Geometry()
475 .add(new go.PathFigure(0, 0, true)
476 .add(new go.PathSegment(go.PathSegment.Line, w, h))
477 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()))
478 .setSpots(0, 0.5, 0.5, 1);
479});
480
481go.Shape.defineFigureGenerator('TriangleDownRight', (shape, w, h) => {
482 return new go.Geometry()
483 .add(new go.PathFigure(w, 0, true)
484 .add(new go.PathSegment(go.PathSegment.Line, w, h))
485 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()))
486 .setSpots(0.5, 0.5, 1, 1);
487});
488
489go.Shape.defineFigureGenerator('TriangleUpLeft', (shape, w, h) => {
490 return new go.Geometry()
491 .add(new go.PathFigure(0, 0, true)
492 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
493 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()))
494 .setSpots(0, 0, 0.5, 0.5);
495});
496
497go.Shape.defineFigureGenerator('TriangleUpRight', (shape, w, h) => {
498 return new go.Geometry()
499 .add(new go.PathFigure(0, 0, true)
500 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
501 .add(new go.PathSegment(go.PathSegment.Line, w, h).close()))
502 .setSpots(0.5, 0, 1, 0.5);
503});
504
505go.Shape.defineFigureGenerator('RightTriangle', 'TriangleDownLeft');
506
507FigureParameter.setFigureParameter('Parallelogram1', 0, new FigureParameter('Indent', .1, -.99, .99));
508go.Shape.defineFigureGenerator('Parallelogram1', (shape, w, h) => {
509 let param1 = shape ? shape.parameter1 : NaN; // indent's percent distance
510 if (isNaN(param1)) param1 = 0.1;
511 else if (param1 < -1) param1 = -1;
512 else if (param1 > 1) param1 = 1;
513 const indent = Math.abs(param1) * w;
514
515 if (param1 === 0) {
516 const geo = new go.Geometry(go.Geometry.Rectangle);
517 geo.startX = 0;
518 geo.startY = 0;
519 geo.endX = w;
520 geo.endY = h;
521 return geo;
522 } else {
523 const geo = new go.Geometry();
524 if (param1 > 0) {
525 geo.add(new go.PathFigure(indent, 0)
526 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
527 .add(new go.PathSegment(go.PathSegment.Line, w - indent, h))
528 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()));
529 } else { // param1 < 0
530 geo.add(new go.PathFigure(0, 0)
531 .add(new go.PathSegment(go.PathSegment.Line, w - indent, 0))
532 .add(new go.PathSegment(go.PathSegment.Line, w, h))
533 .add(new go.PathSegment(go.PathSegment.Line, indent, h).close()));
534 }
535 if (indent < w / 2) {
536 geo.setSpots(indent / w, 0, (w - indent) / w, 1);
537 }
538 return geo;
539 }
540});
541go.Shape.defineFigureGenerator('Parallelogram', 'Parallelogram1'); // alias
542
543// Parallelogram with absolutes instead of scaling
544FigureParameter.setFigureParameter('Parallelogram2', 0, new FigureParameter('Indent', 10, -Infinity, Infinity));
545go.Shape.defineFigureGenerator('Parallelogram2', (shape, w, h) => {
546 let param1 = shape ? shape.parameter1 : NaN; // indent's x distance
547 if (isNaN(param1)) param1 = 10;
548 else if (param1 < -1) param1 = -w;
549 else if (param1 > 1) param1 = w;
550 const indent = Math.abs(param1);
551
552 if (param1 === 0) {
553 const geo = new go.Geometry(go.Geometry.Rectangle);
554 geo.startX = 0;
555 geo.startY = 0;
556 geo.endX = w;
557 geo.endY = h;
558 return geo;
559 } else {
560 const geo = new go.Geometry();
561 if (param1 > 0) {
562 geo.add(new go.PathFigure(indent, 0)
563 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
564 .add(new go.PathSegment(go.PathSegment.Line, w - indent, h))
565 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()));
566 } else { // param1 < 0
567 geo.add(new go.PathFigure(0, 0)
568 .add(new go.PathSegment(go.PathSegment.Line, w - indent, 0))
569 .add(new go.PathSegment(go.PathSegment.Line, w, h))
570 .add(new go.PathSegment(go.PathSegment.Line, indent, h).close()));
571 }
572 if (indent < w / 2) {
573 geo.setSpots(indent / w, 0, (w - indent) / w, 1);
574 }
575 return geo;
576 }
577});
578
579FigureParameter.setFigureParameter('Trapezoid1', 0, new FigureParameter('Indent', .2, -.99, .99));
580go.Shape.defineFigureGenerator('Trapezoid1', (shape, w, h) => {
581 let param1 = shape ? shape.parameter1 : NaN; // indent's percent distance
582 if (isNaN(param1)) param1 = 0.2;
583 else if (param1 < 0.5) param1 = -0.5;
584 else if (param1 > 0.5) param1 = 0.5;
585 const indent = Math.abs(param1) * w;
586
587 if (param1 === 0) {
588 const geo = new go.Geometry(go.Geometry.Rectangle);
589 geo.startX = 0;
590 geo.startY = 0;
591 geo.endX = w;
592 geo.endY = h;
593 return geo;
594 } else {
595 const geo = new go.Geometry();
596 if (param1 > 0) {
597 geo.add(new go.PathFigure(indent, 0)
598 .add(new go.PathSegment(go.PathSegment.Line, w - indent, 0))
599 .add(new go.PathSegment(go.PathSegment.Line, w, h))
600 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()));
601 } else { // param1 < 0
602 geo.add(new go.PathFigure(0, 0)
603 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
604 .add(new go.PathSegment(go.PathSegment.Line, w - indent, h))
605 .add(new go.PathSegment(go.PathSegment.Line, indent, h).close()));
606 }
607 if (indent < w / 2) {
608 geo.setSpots(indent / w, 0, (w - indent) / w, 1);
609 }
610 return geo;
611 }
612});
613go.Shape.defineFigureGenerator('Trapezoid', 'Trapezoid1'); // alias
614
615// Trapezoid with absolutes instead of scaling
616FigureParameter.setFigureParameter('Trapezoid2', 0, new FigureParameter('Indent', 20, -Infinity, Infinity));
617go.Shape.defineFigureGenerator('Trapezoid2', (shape, w, h) => {
618 let param1 = shape ? shape.parameter1 : NaN; // indent's x distance
619 if (isNaN(param1)) param1 = 20; // default value
620 else if (param1 < -w) param1 = -w / 2;
621 else if (param1 > w) param1 = w / 2;
622 const indent = Math.abs(param1);
623
624 if (param1 === 0) {
625 const geo = new go.Geometry(go.Geometry.Rectangle);
626 geo.startX = 0;
627 geo.startY = 0;
628 geo.endX = w;
629 geo.endY = h;
630 return geo;
631 } else {
632 const geo = new go.Geometry();
633 if (param1 > 0) {
634 geo.add(new go.PathFigure(indent, 0)
635 .add(new go.PathSegment(go.PathSegment.Line, w - indent, 0))
636 .add(new go.PathSegment(go.PathSegment.Line, w, h))
637 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()));
638 } else { // param1 < 0
639 geo.add(new go.PathFigure(0, 0)
640 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
641 .add(new go.PathSegment(go.PathSegment.Line, w - indent, h))
642 .add(new go.PathSegment(go.PathSegment.Line, indent, h).close()));
643 }
644 if (indent < w / 2) {
645 geo.setSpots(indent / w, 0, (w - indent) / w, 1);
646 }
647 return geo;
648 }
649});
650
651FigureParameter.setFigureParameter('ManualOperation', 0, new FigureParameter('Indent', 10, -Infinity, Infinity));
652go.Shape.defineFigureGenerator('ManualOperation', (shape, w, h) => {
653 let param1 = shape ? shape.parameter1 : NaN;
654 // Distance from topleft of bounding rectangle,
655 // in % of the total width, of the topleft corner
656 if (isNaN(param1)) param1 = 10; // default value
657 else if (param1 < -w) param1 = -w / 2;
658 else if (param1 > w) param1 = w / 2;
659 const indent = Math.abs(param1);
660
661 if (param1 === 0) {
662 const geo = new go.Geometry(go.Geometry.Rectangle);
663 geo.startX = 0;
664 geo.startY = 0;
665 geo.endX = w;
666 geo.endY = h;
667 return geo;
668 } else {
669 const geo = new go.Geometry();
670 if (param1 > 0) {
671 geo.add(new go.PathFigure(0, 0)
672 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
673 .add(new go.PathSegment(go.PathSegment.Line, w - indent, h))
674 .add(new go.PathSegment(go.PathSegment.Line, indent, h).close()));
675 } else { // param1 < 0
676 geo.add(new go.PathFigure(indent, 0)
677 .add(new go.PathSegment(go.PathSegment.Line, w - indent, 0))
678 .add(new go.PathSegment(go.PathSegment.Line, w, h))
679 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()));
680 }
681 if (indent < w / 2) {
682 geo.setSpots(indent / w, 0, (w - indent) / w, 1);
683 }
684 return geo;
685 }
686});
687
688// The following functions are used by a group of regular figures that are defined below:
689
690/** @ignore */
691const _CachedArrays: Array<any> = [];
692
693/**
694 * @ignore
695 * @return {Array}
696 */
697function tempArray(): Array<any> {
698 const temp = _CachedArrays.pop();
699 if (temp === undefined) return [];
700 return temp;
701}
702
703/**
704 * @ignore
705 * @param {Array} a
706 */
707function freeArray(a: Array<any>) {
708 a.length = 0; // clear any references to objects
709 _CachedArrays.push(a);
710}
711
712
713/**
714 * @ignore
715 * This allocates a temporary Array that should be freeArray()'ed by the caller.
716 * @param {number} sides
717 * @return {Array}
718 */
719function createPolygon(sides: number): Array<any> {
720 // Point[] points = new Point[sides + 1];
721 const points = tempArray();
722 const radius = .5;
723 const center = .5;
724 const offsetAngle = Math.PI * 1.5;
725 let angle = 0;
726
727 // Loop through each side of the polygon
728 for (let i = 0; i < sides; i++) {
729 angle = 2 * Math.PI / sides * i + offsetAngle;
730 points[i] = new go.Point((center + radius * Math.cos(angle)), (center + radius * Math.sin(angle)));
731 }
732
733 // Add the last line
734 // points[points.length - 1] = points[0];
735 points.push(points[0]);
736 return points;
737}
738
739/**
740 * @ignore
741 * This allocates a temporary Array that should be freeArray()'ed by the caller.
742 * @param {number} points
743 * @return {Array}
744 */
745function createBurst(points: number): Array<any> {
746 const star = createStar(points);
747 const pts = tempArray(); // new Point[points * 3 + 1];
748
749 pts[0] = star[0];
750 for (let i = 1, count = 1; i < star.length; i += 2, count += 3) {
751 pts[count] = star[i];
752 pts[count + 1] = star[i];
753 pts[count + 2] = star[i + 1];
754 }
755
756 freeArray(star);
757 return pts;
758}
759
760/**
761 * @ignore
762 * This allocates a temporary Array that should be freeArray()'ed by the caller.
763 * @param {number} points
764 * @return {Array}
765 */
766function createStar(points: number): Array<any> {
767 // First, create a regular polygon
768 const polygon = createPolygon(points);
769 // Calculate the points inbetween
770 const pts = tempArray(); // new Point[points * 2 + 1];
771
772 const half = Math.floor(polygon.length / 2);
773 const count = polygon.length - 1;
774 const offset = (points % 2 === 0) ? 2 : 1;
775
776 for (let i = 0; i < count; i++) {
777 // Get the intersection of two lines
778 const p0 = polygon[i];
779 const p1 = polygon[i + 1];
780 const q21 = polygon[(half + i - 1) % count];
781 const q2off = polygon[(half + i + offset) % count];
782 pts[i * 2] = p0;
783 pts[i * 2 + 1] = getIntersection(p0.x, p0.y,
784 q21.x, q21.y,
785 p1.x, p1.y,
786 q2off.x, q2off.y, new go.Point()); // ?? not currently managed
787 }
788
789 pts[pts.length] = pts[0];
790
791 freeArray(polygon);
792 return pts;
793}
794
795
796go.Shape.defineFigureGenerator('Pentagon', (shape, w, h) => {
797 const points = createPolygon(5);
798 const geo = new go.Geometry();
799 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
800 geo.add(fig);
801
802 for (let i = 1; i < 5; i++) {
803 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
804 }
805 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
806 freeArray(points);
807 geo.spot1 = new go.Spot(.2, .22);
808 geo.spot2 = new go.Spot(.8, .9);
809 return geo;
810});
811
812go.Shape.defineFigureGenerator('Hexagon', (shape, w, h) => {
813 const points = createPolygon(6);
814 const geo = new go.Geometry();
815 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
816 geo.add(fig);
817
818 for (let i = 1; i < 6; i++) {
819 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
820 }
821 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
822 freeArray(points);
823 geo.spot1 = new go.Spot(.07, .25);
824 geo.spot2 = new go.Spot(.93, .75);
825 return geo;
826});
827
828go.Shape.defineFigureGenerator('Heptagon', (shape, w, h) => {
829 const points = createPolygon(7);
830 const geo = new go.Geometry();
831 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
832 geo.add(fig);
833
834 for (let i = 1; i < 7; i++) {
835 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
836 }
837 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
838 freeArray(points);
839 geo.spot1 = new go.Spot(.2, .15);
840 geo.spot2 = new go.Spot(.8, .85);
841 return geo;
842});
843
844go.Shape.defineFigureGenerator('Octagon', (shape, w, h) => {
845 const points = createPolygon(8);
846 const geo = new go.Geometry();
847 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
848 geo.add(fig);
849
850 for (let i = 1; i < 8; i++) {
851 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
852 }
853 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
854 freeArray(points);
855 geo.spot1 = new go.Spot(.15, .15);
856 geo.spot2 = new go.Spot(.85, .85);
857 return geo;
858});
859
860go.Shape.defineFigureGenerator('Nonagon', (shape, w, h) => {
861 const points = createPolygon(9);
862 const geo = new go.Geometry();
863 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
864 geo.add(fig);
865
866 for (let i = 1; i < 9; i++) {
867 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
868 }
869 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
870 freeArray(points);
871 geo.spot1 = new go.Spot(.17, .13);
872 geo.spot2 = new go.Spot(.82, .82);
873 return geo;
874});
875
876go.Shape.defineFigureGenerator('Decagon', (shape, w, h) => {
877 const points = createPolygon(10);
878 const geo = new go.Geometry();
879 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
880 geo.add(fig);
881
882 for (let i = 1; i < 10; i++) {
883 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
884 }
885 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
886 freeArray(points);
887 geo.spot1 = new go.Spot(.16, .16);
888 geo.spot2 = new go.Spot(.84, .84);
889 return geo;
890});
891
892go.Shape.defineFigureGenerator('Dodecagon', (shape, w, h) => {
893 const points = createPolygon(12);
894 const geo = new go.Geometry();
895 const fig = new go.PathFigure(points[0].x * w, points[0].y * h, true);
896 geo.add(fig);
897
898 for (let i = 1; i < 12; i++) {
899 fig.add(new go.PathSegment(go.PathSegment.Line, points[i].x * w, points[i].y * h));
900 }
901 fig.add(new go.PathSegment(go.PathSegment.Line, points[0].x * w, points[0].y * h).close());
902 freeArray(points);
903 geo.spot1 = new go.Spot(.16, .16);
904 geo.spot2 = new go.Spot(.84, .84);
905 return geo;
906});
907
908go.Shape.defineFigureGenerator('FivePointedStar', (shape, w, h) => {
909 const starPoints = createStar(5);
910 const geo = new go.Geometry();
911 const fig = new go.PathFigure(starPoints[0].x * w, starPoints[0].y * h, true);
912 geo.add(fig);
913
914 for (let i = 1; i < 10; i++) {
915 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[i].x * w, starPoints[i].y * h));
916 }
917 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[0].x * w, starPoints[0].y * h).close());
918 freeArray(starPoints);
919 geo.spot1 = new go.Spot(.266, .333);
920 geo.spot2 = new go.Spot(.733, .733);
921 return geo;
922});
923
924go.Shape.defineFigureGenerator('SixPointedStar', (shape, w, h) => {
925 const starPoints = createStar(6);
926 const geo = new go.Geometry();
927 const fig = new go.PathFigure(starPoints[0].x * w, starPoints[0].y * h, true);
928 geo.add(fig);
929
930 for (let i = 1; i < 12; i++) {
931 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[i].x * w, starPoints[i].y * h));
932 }
933 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[0].x * w, starPoints[0].y * h).close());
934 freeArray(starPoints);
935 geo.spot1 = new go.Spot(.17, .25);
936 geo.spot2 = new go.Spot(.83, .75);
937 return geo;
938});
939
940go.Shape.defineFigureGenerator('SevenPointedStar', (shape, w, h) => {
941 const starPoints = createStar(7);
942 const geo = new go.Geometry();
943 const fig = new go.PathFigure(starPoints[0].x * w, starPoints[0].y * h, true);
944 geo.add(fig);
945
946 for (let i = 1; i < 14; i++) {
947 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[i].x * w, starPoints[i].y * h));
948 }
949 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[0].x * w, starPoints[0].y * h).close());
950 freeArray(starPoints);
951 geo.spot1 = new go.Spot(.222, .277);
952 geo.spot2 = new go.Spot(.777, .666);
953 return geo;
954});
955
956go.Shape.defineFigureGenerator('EightPointedStar', (shape, w, h) => {
957 const starPoints = createStar(8);
958 const geo = new go.Geometry();
959 const fig = new go.PathFigure(starPoints[0].x * w, starPoints[0].y * h, true);
960 geo.add(fig);
961
962 for (let i = 1; i < 16; i++) {
963 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[i].x * w, starPoints[i].y * h));
964 }
965 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[0].x * w, starPoints[0].y * h).close());
966 freeArray(starPoints);
967 geo.spot1 = new go.Spot(.25, .25);
968 geo.spot2 = new go.Spot(.75, .75);
969 return geo;
970});
971
972go.Shape.defineFigureGenerator('NinePointedStar', (shape, w, h) => {
973 const starPoints = createStar(9);
974 const geo = new go.Geometry();
975 const fig = new go.PathFigure(starPoints[0].x * w, starPoints[0].y * h, true);
976 geo.add(fig);
977
978 for (let i = 1; i < 18; i++) {
979 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[i].x * w, starPoints[i].y * h));
980 }
981 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[0].x * w, starPoints[0].y * h).close());
982 freeArray(starPoints);
983 geo.spot1 = new go.Spot(.222, .277);
984 geo.spot2 = new go.Spot(.777, .666);
985 return geo;
986});
987
988go.Shape.defineFigureGenerator('TenPointedStar', (shape, w, h) => {
989 const starPoints = createStar(10);
990 const geo = new go.Geometry();
991 const fig = new go.PathFigure(starPoints[0].x * w, starPoints[0].y * h, true);
992 geo.add(fig);
993
994 for (let i = 1; i < 20; i++) {
995 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[i].x * w, starPoints[i].y * h));
996 }
997 fig.add(new go.PathSegment(go.PathSegment.Line, starPoints[0].x * w, starPoints[0].y * h).close());
998 freeArray(starPoints);
999 geo.spot1 = new go.Spot(.281, .261);
1000 geo.spot2 = new go.Spot(.723, .748);
1001 return geo;
1002});
1003
1004go.Shape.defineFigureGenerator('FivePointedBurst', (shape, w, h) => {
1005 const burstPoints = createBurst(5);
1006 const geo = new go.Geometry();
1007 const fig = new go.PathFigure(burstPoints[0].x * w, burstPoints[0].y * h, true);
1008 geo.add(fig);
1009
1010 for (let i = 1; i < burstPoints.length; i += 3) {
1011 fig.add(new go.PathSegment(go.PathSegment.Bezier, burstPoints[i + 2].x * w,
1012 burstPoints[i + 2].y * h, burstPoints[i].x * w,
1013 burstPoints[i].y * h, burstPoints[i + 1].x * w,
1014 burstPoints[i + 1].y * h));
1015 }
1016 const lst = fig.segments.last();
1017 if (lst !== null) lst.close();
1018 freeArray(burstPoints);
1019 geo.spot1 = new go.Spot(.222, .277);
1020 geo.spot2 = new go.Spot(.777, .777);
1021 return geo;
1022});
1023
1024go.Shape.defineFigureGenerator('SixPointedBurst', (shape, w, h) => {
1025 const burstPoints = createBurst(6);
1026 const geo = new go.Geometry();
1027 const fig = new go.PathFigure(burstPoints[0].x * w, burstPoints[0].y * h, true);
1028 geo.add(fig);
1029
1030 for (let i = 1; i < burstPoints.length; i += 3) {
1031 fig.add(new go.PathSegment(go.PathSegment.Bezier, burstPoints[i + 2].x * w,
1032 burstPoints[i + 2].y * h, burstPoints[i].x * w,
1033 burstPoints[i].y * h, burstPoints[i + 1].x * w,
1034 burstPoints[i + 1].y * h));
1035 }
1036 const lst = fig.segments.last();
1037 if (lst !== null) lst.close();
1038 freeArray(burstPoints);
1039 geo.spot1 = new go.Spot(.170, .222);
1040 geo.spot2 = new go.Spot(.833, .777);
1041 return geo;
1042});
1043
1044go.Shape.defineFigureGenerator('SevenPointedBurst', (shape, w, h) => {
1045 const burstPoints = createBurst(7);
1046 const geo = new go.Geometry();
1047 const fig = new go.PathFigure(burstPoints[0].x * w, burstPoints[0].y * h, true);
1048 geo.add(fig);
1049
1050 for (let i = 1; i < burstPoints.length; i += 3) {
1051 fig.add(new go.PathSegment(go.PathSegment.Bezier, burstPoints[i + 2].x * w,
1052 burstPoints[i + 2].y * h, burstPoints[i].x * w,
1053 burstPoints[i].y * h, burstPoints[i + 1].x * w,
1054 burstPoints[i + 1].y * h));
1055 }
1056 const lst = fig.segments.last();
1057 if (lst !== null) lst.close();
1058 freeArray(burstPoints);
1059 geo.spot1 = new go.Spot(.222, .222);
1060 geo.spot2 = new go.Spot(.777, .777);
1061 return geo;
1062});
1063
1064go.Shape.defineFigureGenerator('EightPointedBurst', (shape, w, h) => {
1065 const burstPoints = createBurst(8);
1066 const geo = new go.Geometry();
1067 const fig = new go.PathFigure(burstPoints[0].x * w, burstPoints[0].y * h, true);
1068 geo.add(fig);
1069
1070 for (let i = 1; i < burstPoints.length; i += 3) {
1071 fig.add(new go.PathSegment(go.PathSegment.Bezier, burstPoints[i + 2].x * w,
1072 burstPoints[i + 2].y * h, burstPoints[i].x * w,
1073 burstPoints[i].y * h, burstPoints[i + 1].x * w,
1074 burstPoints[i + 1].y * h));
1075 }
1076 const lst = fig.segments.last();
1077 if (lst !== null) lst.close();
1078 freeArray(burstPoints);
1079 geo.spot1 = new go.Spot(.222, .222);
1080 geo.spot2 = new go.Spot(.777, .777);
1081 return geo;
1082});
1083
1084go.Shape.defineFigureGenerator('NinePointedBurst', (shape, w, h) => {
1085 const burstPoints = createBurst(9);
1086 const geo = new go.Geometry();
1087 const fig = new go.PathFigure(burstPoints[0].x * w, burstPoints[0].y * h, true);
1088 geo.add(fig);
1089
1090 for (let i = 1; i < burstPoints.length; i += 3) {
1091 fig.add(new go.PathSegment(go.PathSegment.Bezier, burstPoints[i + 2].x * w,
1092 burstPoints[i + 2].y * h, burstPoints[i].x * w,
1093 burstPoints[i].y * h, burstPoints[i + 1].x * w,
1094 burstPoints[i + 1].y * h));
1095 }
1096 const lst = fig.segments.last();
1097 if (lst !== null) lst.close();
1098 freeArray(burstPoints);
1099 geo.spot1 = new go.Spot(.222, .222);
1100 geo.spot2 = new go.Spot(.777, .777);
1101 return geo;
1102});
1103
1104go.Shape.defineFigureGenerator('TenPointedBurst', (shape, w, h) => {
1105 const burstPoints = createBurst(10);
1106 const geo = new go.Geometry();
1107 const fig = new go.PathFigure(burstPoints[0].x * w, burstPoints[0].y * h, true);
1108 geo.add(fig);
1109
1110 for (let i = 1; i < burstPoints.length; i += 3) {
1111 fig.add(new go.PathSegment(go.PathSegment.Bezier, burstPoints[i + 2].x * w,
1112 burstPoints[i + 2].y * h, burstPoints[i].x * w,
1113 burstPoints[i].y * h, burstPoints[i + 1].x * w,
1114 burstPoints[i + 1].y * h));
1115 }
1116 const lst = fig.segments.last();
1117 if (lst !== null) lst.close();
1118 freeArray(burstPoints);
1119 geo.spot1 = new go.Spot(.222, .222);
1120 geo.spot2 = new go.Spot(.777, .777);
1121 return geo;
1122});
1123
1124
1125
1126FigureParameter.setFigureParameter('FramedRectangle', 0, new FigureParameter('ThicknessX', 8));
1127FigureParameter.setFigureParameter('FramedRectangle', 1, new FigureParameter('ThicknessY', 8));
1128go.Shape.defineFigureGenerator('FramedRectangle', (shape, w, h) => {
1129 let param1 = shape ? shape.parameter1 : NaN;
1130 let param2 = shape ? shape.parameter2 : NaN;
1131 if (isNaN(param1)) param1 = 8; // default values PARAMETER 1 is for WIDTH
1132 if (isNaN(param2)) param2 = 8; // default values PARAMETER 2 is for HEIGHT
1133
1134 const geo = new go.Geometry();
1135 const fig = new go.PathFigure(0, 0, true);
1136 geo.add(fig);
1137 // outer rectangle, clockwise
1138 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
1139 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
1140 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
1141 if (param1 < w / 2 && param2 < h / 2) {
1142 // inner rectangle, counter-clockwise
1143 fig.add(new go.PathSegment(go.PathSegment.Move, param1, param2)); // subpath
1144 fig.add(new go.PathSegment(go.PathSegment.Line, param1, h - param2));
1145 fig.add(new go.PathSegment(go.PathSegment.Line, w - param1, h - param2));
1146 fig.add(new go.PathSegment(go.PathSegment.Line, w - param1, param2).close());
1147 }
1148 geo.setSpots(0, 0, 1, 1, param1, param2, -param1, -param2);
1149 return geo;
1150});
1151
1152FigureParameter.setFigureParameter('Ring', 0, new FigureParameter('Thickness', 8));
1153go.Shape.defineFigureGenerator('Ring', (shape, w, h) => {
1154 let param1 = shape ? shape.parameter1 : NaN;
1155 if (isNaN(param1) || param1 < 0) param1 = 8;
1156
1157 const rad = w / 2;
1158 const geo = new go.Geometry();
1159 const fig = new go.PathFigure(w, w / 2, true); // clockwise
1160 geo.add(fig);
1161 fig.add(new go.PathSegment(go.PathSegment.Arc, 0, 360, rad, rad, rad, rad).close());
1162
1163 const rad2 = Math.max(rad - param1, 0);
1164 if (rad2 > 0) { // counter-clockwise
1165 fig.add(new go.PathSegment(go.PathSegment.Move, w / 2 + rad2, w / 2));
1166 fig.add(new go.PathSegment(go.PathSegment.Arc, 0, -360, rad, rad, rad2, rad2).close());
1167 }
1168 geo.spot1 = GeneratorEllipseSpot1;
1169 geo.spot2 = GeneratorEllipseSpot2;
1170 geo.defaultStretch = go.GraphObject.Uniform;
1171 return geo;
1172});
1173
1174go.Shape.defineFigureGenerator('Cloud', (shape, w, h) => {
1175 return new go.Geometry()
1176 .add(new go.PathFigure(.08034461 * w, .1944299 * h, true)
1177 .add(new go.PathSegment(go.PathSegment.Bezier,
1178 .2008615 * w, .05349299 * h, -.09239631 * w, .07836421 * h, .1406031 * w, -.0542823 * h))
1179 .add(new go.PathSegment(go.PathSegment.Bezier,
1180 .4338609 * w, .074219 * h, .2450511 * w, -.00697547 * h, .3776197 * w, -.01112067 * h))
1181 .add(new go.PathSegment(go.PathSegment.Bezier,
1182 .6558228 * w, .07004196 * h, .4539471 * w, 0, .6066018 * w, -.02526587 * h))
1183 .add(new go.PathSegment(go.PathSegment.Bezier,
1184 .8921095 * w, .08370865 * h, .6914277 * w, -.01904177 * h, .8921095 * w, -.01220843 * h))
1185 .add(new go.PathSegment(go.PathSegment.Bezier,
1186 .9147671 * w, .3194596 * h, 1.036446 * w, .04105738 * h, 1.020377 * w, .3022052 * h))
1187 .add(new go.PathSegment(go.PathSegment.Bezier,
1188 .9082935 * w, .562044 * h, 1.04448 * w, .360238 * h, .992256 * w, .5219009 * h))
1189 .add(new go.PathSegment(go.PathSegment.Bezier,
1190 .9212406 * w, .8217117 * h, 1.032337 * w, .5771781 * h, 1.018411 * w, .8120651 * h))
1191 .add(new go.PathSegment(go.PathSegment.Bezier,
1192 .7592566 * w, .9156953 * h, 1.028411 * w, .9571472 * h, .8556702 * w, 1.052487 * h))
1193 .add(new go.PathSegment(go.PathSegment.Bezier,
1194 .5101666 * w, .9310455 * h, .7431877 * w, 1.009325 * h, .5624123 * w, 1.021761 * h))
1195 .add(new go.PathSegment(go.PathSegment.Bezier,
1196 .2609328 * w, .9344623 * h, .4820677 * w, 1.031761 * h, .3030112 * w, 1.002796 * h))
1197 .add(new go.PathSegment(go.PathSegment.Bezier,
1198 .08034461 * w, .870098 * h, .2329994 * w, 1.01518 * h, .03213784 * w, 1.01518 * h))
1199 .add(new go.PathSegment(go.PathSegment.Bezier,
1200 .06829292 * w, .6545475 * h, -.02812061 * w, .9032597 * h, -.01205169 * w, .6835638 * h))
1201 .add(new go.PathSegment(go.PathSegment.Bezier,
1202 .06427569 * w, .4265613 * h, -.01812061 * w, .6089503 * h, -.00606892 * w, .4555777 * h))
1203 .add(new go.PathSegment(go.PathSegment.Bezier,
1204 .08034461 * w, .1944299 * h, -.01606892 * w, .3892545 * h, -.01205169 * w, .1944299 * h)))
1205 .setSpots(.1, .1, .9, .9);
1206});
1207
1208go.Shape.defineFigureGenerator('StopSign', (shape, w, h) => {
1209 const part = 1 / (Math.SQRT2 + 2);
1210 return new go.Geometry()
1211 .add(new go.PathFigure(part * w, 0, true)
1212 .add(new go.PathSegment(go.PathSegment.Line, (1 - part) * w, 0))
1213 .add(new go.PathSegment(go.PathSegment.Line, w, part * h))
1214 .add(new go.PathSegment(go.PathSegment.Line, w, (1 - part) * h))
1215 .add(new go.PathSegment(go.PathSegment.Line, (1 - part) * w, h))
1216 .add(new go.PathSegment(go.PathSegment.Line, part * w, h))
1217 .add(new go.PathSegment(go.PathSegment.Line, 0, (1 - part) * h))
1218 .add(new go.PathSegment(go.PathSegment.Line, 0, part * h).close()))
1219 .setSpots(part / 2, part / 2, 1 - part / 2, 1 - part / 2);
1220});
1221
1222FigureParameter.setFigureParameter('Pie', 0, new FigureParameter('Start', 0, -360, 360));
1223FigureParameter.setFigureParameter('Pie', 1, new FigureParameter('Sweep', 315, -360, 360));
1224go.Shape.defineFigureGenerator('Pie', (shape, w, h) => {
1225 let param1 = shape ? shape.parameter1 : NaN;
1226 let param2 = shape ? shape.parameter2 : NaN;
1227 if (isNaN(param1)) param1 = 0; // default values PARAMETER 1 is for Start Angle
1228 if (isNaN(param2)) param2 = 315; // default values PARAMETER 2 is for Sweep Angle
1229
1230 let start = param1 % 360;
1231 if (start < 0) start += 360;
1232 const sweep = param2 % 360;
1233 const rad = Math.min(w, h) / 2;
1234
1235 return new go.Geometry()
1236 .add(new go.PathFigure(rad, rad) // start point
1237 .add(new go.PathSegment(go.PathSegment.Arc,
1238 start, sweep, // angles
1239 rad, rad, // center
1240 rad, rad) // radius
1241 .close()));
1242});
1243
1244go.Shape.defineFigureGenerator('PiePiece', (shape, w, h) => {
1245 const factor = KAPPA / Math.SQRT2 * .5;
1246 const x1 = Math.SQRT2 / 2;
1247 const y1 = 1 - Math.SQRT2 / 2;
1248 return new go.Geometry()
1249 .add(new go.PathFigure(w, h, true)
1250 .add(new go.PathSegment(go.PathSegment.Bezier, x1 * w, y1 * h, w, (1 - factor) * h, (x1 + factor) * w, (y1 + factor) * h))
1251 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close()));
1252});
1253
1254FigureParameter.setFigureParameter('ThickCross', 0, new FigureParameter('Thickness', 30));
1255go.Shape.defineFigureGenerator('ThickCross', (shape, w, h) => {
1256 let param1 = shape ? shape.parameter1 : NaN;
1257 if (isNaN(param1) || param1 < 0) param1 = 30;
1258
1259 const t = Math.min(param1, w) / 2;
1260 const mx = w / 2;
1261 const my = h / 2;
1262
1263 return new go.Geometry()
1264 .add(new go.PathFigure(mx - t, 0, true)
1265 .add(new go.PathSegment(go.PathSegment.Line, mx + t, 0))
1266 .add(new go.PathSegment(go.PathSegment.Line, mx + t, my - t))
1267
1268 .add(new go.PathSegment(go.PathSegment.Line, w, my - t))
1269 .add(new go.PathSegment(go.PathSegment.Line, w, my + t))
1270 .add(new go.PathSegment(go.PathSegment.Line, mx + t, my + t))
1271
1272 .add(new go.PathSegment(go.PathSegment.Line, mx + t, h))
1273 .add(new go.PathSegment(go.PathSegment.Line, mx - t, h))
1274 .add(new go.PathSegment(go.PathSegment.Line, mx - t, my + t))
1275
1276 .add(new go.PathSegment(go.PathSegment.Line, 0, my + t))
1277 .add(new go.PathSegment(go.PathSegment.Line, 0, my - t))
1278 .add(new go.PathSegment(go.PathSegment.Line, mx - t, my - t).close()));
1279});
1280
1281FigureParameter.setFigureParameter('ThinCross', 0, new FigureParameter('Thickness', 10));
1282go.Shape.defineFigureGenerator('ThinCross', (shape, w, h) => {
1283 let param1 = shape ? shape.parameter1 : NaN;
1284 if (isNaN(param1) || param1 < 0) param1 = 10;
1285
1286 const t = Math.min(param1, w) / 2;
1287 const mx = w / 2;
1288 const my = h / 2;
1289
1290 return new go.Geometry()
1291 .add(new go.PathFigure(mx - t, 0, true)
1292 .add(new go.PathSegment(go.PathSegment.Line, mx + t, 0))
1293 .add(new go.PathSegment(go.PathSegment.Line, mx + t, my - t))
1294
1295 .add(new go.PathSegment(go.PathSegment.Line, w, my - t))
1296 .add(new go.PathSegment(go.PathSegment.Line, w, my + t))
1297 .add(new go.PathSegment(go.PathSegment.Line, mx + t, my + t))
1298
1299 .add(new go.PathSegment(go.PathSegment.Line, mx + t, h))
1300 .add(new go.PathSegment(go.PathSegment.Line, mx - t, h))
1301 .add(new go.PathSegment(go.PathSegment.Line, mx - t, my + t))
1302
1303 .add(new go.PathSegment(go.PathSegment.Line, 0, my + t))
1304 .add(new go.PathSegment(go.PathSegment.Line, 0, my - t))
1305 .add(new go.PathSegment(go.PathSegment.Line, mx - t, my - t).close()));
1306});
1307
1308
1309FigureParameter.setFigureParameter('ThickX', 0, new FigureParameter('Thickness', 30));
1310go.Shape.defineFigureGenerator('ThickX', (shape, w, h) => {
1311 let param1 = shape ? shape.parameter1 : NaN;
1312 if (isNaN(param1) || param1 < 0) param1 = 30;
1313 if (w === 0 || h === 0) {
1314 const geo = new go.Geometry(go.Geometry.Rectangle);
1315 geo.startX = 0;
1316 geo.startY = 0;
1317 geo.endX = w;
1318 geo.endY = h;
1319 return geo;
1320 } else {
1321 const w2 = w / 2;
1322 const h2 = h / 2;
1323 const a2 = Math.atan2(h, w);
1324 const dx = param1 - Math.min(Math.cos(a2) * param1 / 2, w2);
1325 const dy = param1 - Math.min(Math.sin(a2) * param1 / 2, h2);
1326
1327 const geo = new go.Geometry();
1328 const fig = new go.PathFigure(dx, 0, true);
1329 geo.add(fig);
1330 fig.add(new go.PathSegment(go.PathSegment.Line, w2, .2 * h));
1331 fig.add(new go.PathSegment(go.PathSegment.Line, w - dx, 0));
1332 fig.add(new go.PathSegment(go.PathSegment.Line, w, dy));
1333 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, h2));
1334 fig.add(new go.PathSegment(go.PathSegment.Line, w, h - dy));
1335 fig.add(new go.PathSegment(go.PathSegment.Line, w - dx, h));
1336 fig.add(new go.PathSegment(go.PathSegment.Line, w2, .8 * h));
1337 fig.add(new go.PathSegment(go.PathSegment.Line, dx, h));
1338 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h - dy));
1339 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, h2));
1340 fig.add(new go.PathSegment(go.PathSegment.Line, 0, dy).close());
1341 return geo;
1342 }
1343});
1344
1345FigureParameter.setFigureParameter('ThinX', 0, new FigureParameter('Thickness', 10));
1346go.Shape.defineFigureGenerator('ThinX', (shape, w, h) => {
1347 let param1 = shape ? shape.parameter1 : NaN;
1348 if (isNaN(param1) || param1 < 0) param1 = 10;
1349
1350 const geo = new go.Geometry();
1351 const fig = new go.PathFigure(.1 * w, 0, true);
1352 geo.add(fig);
1353 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .4 * h));
1354 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, 0));
1355 fig.add(new go.PathSegment(go.PathSegment.Line, w, .1 * h));
1356 fig.add(new go.PathSegment(go.PathSegment.Line, .6 * w, .5 * h));
1357 fig.add(new go.PathSegment(go.PathSegment.Line, w, .9 * h));
1358 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, h));
1359 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .6 * h));
1360 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, h));
1361 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .9 * h));
1362 fig.add(new go.PathSegment(go.PathSegment.Line, .4 * w, .5 * h));
1363 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .1 * h).close());
1364 return geo;
1365});
1366
1367// adjust the width of the vertical beam
1368FigureParameter.setFigureParameter('SquareIBeam', 0, new FigureParameter('BeamWidth', 0.2, 0.1, 0.9));
1369go.Shape.defineFigureGenerator('SquareIBeam', (shape, w, h) => {
1370 let param1 = shape ? shape.parameter1 : NaN; // width of the ibeam in % of the total width
1371 if (isNaN(param1)) param1 = .2;
1372
1373 const geo = new go.Geometry();
1374 const fig = new go.PathFigure(0, 0, true);
1375 geo.add(fig);
1376 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
1377 fig.add(new go.PathSegment(go.PathSegment.Line, w, param1 * h));
1378 fig.add(new go.PathSegment(go.PathSegment.Line, (.5 + param1 / 2) * w, param1 * h));
1379 fig.add(new go.PathSegment(go.PathSegment.Line, (.5 + param1 / 2) * w, (1 - param1) * h));
1380 fig.add(new go.PathSegment(go.PathSegment.Line, w, (1 - param1) * h));
1381 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
1382 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
1383 fig.add(new go.PathSegment(go.PathSegment.Line, 0, (1 - param1) * h));
1384 fig.add(new go.PathSegment(go.PathSegment.Line, (.5 - param1 / 2) * w, (1 - param1) * h));
1385 fig.add(new go.PathSegment(go.PathSegment.Line, (.5 - param1 / 2) * w, param1 * h));
1386 fig.add(new go.PathSegment(go.PathSegment.Line, 0, param1 * h).close());
1387 return geo;
1388});
1389
1390// parameter allows it easy to adjust the roundness of the curves that cut inward
1391FigureParameter.setFigureParameter('RoundedIBeam', 0, new FigureParameter('Curviness', .5, .05, .65));
1392go.Shape.defineFigureGenerator('RoundedIBeam', (shape, w, h) => {
1393 let param1 = shape ? shape.parameter1 : NaN; // curviness of the ibeam relative to total width
1394 if (isNaN(param1)) param1 = .5;
1395
1396 const geo = new go.Geometry();
1397 const fig = new go.PathFigure(0, 0, true);
1398 geo.add(fig);
1399 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
1400 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, h, Math.abs((1 - param1)) * w, .25 * h, Math.abs((1 - param1)) * w, .75 * h));
1401 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
1402 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0, param1 * w, .75 * h,
1403 param1 * w, .25 * h).close());
1404 return geo;
1405});
1406
1407go.Shape.defineFigureGenerator('HalfEllipse', (shape, w, h) => {
1408 return new go.Geometry()
1409 .add(new go.PathFigure(0, 0, true)
1410 .add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, KAPPA * w, 0, w, (.5 - KAPPA / 2) * h))
1411 .add(new go.PathSegment(go.PathSegment.Bezier, 0, h, w, (.5 + KAPPA / 2) * h, KAPPA * w, h).close()))
1412 .setSpots(0, 0.156, 0.844, 0.844);
1413});
1414
1415go.Shape.defineFigureGenerator('Crescent', (shape, w, h) => {
1416 return new go.Geometry()
1417 .add(new go.PathFigure(0, 0, true)
1418 .add(new go.PathSegment(go.PathSegment.Bezier,
1419 0, h, w, 0, w, h))
1420 .add(new go.PathSegment(go.PathSegment.Bezier,
1421 0, 0, 0.5 * w, 0.75 * h, 0.5 * w, 0.25 * h).close()))
1422 .setSpots(.311, 0.266, 0.744, 0.744);
1423});
1424
1425go.Shape.defineFigureGenerator('Heart', (shape, w, h) => {
1426 return new go.Geometry()
1427 .add(new go.PathFigure(.5 * w, h, true)
1428 .add(new go.PathSegment(go.PathSegment.Bezier, 0, .3 * h, .1 * w, .8 * h, 0, .5 * h))
1429 .add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .3 * h, 0, 0, .45 * w, 0))
1430 .add(new go.PathSegment(go.PathSegment.Bezier, w, .3 * h, .55 * w, 0, w, 0))
1431 .add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h, w, .5 * h, .9 * w, .8 * h).close()))
1432 .setSpots(.14, .29, .86, .78);
1433});
1434
1435go.Shape.defineFigureGenerator('Spade', (shape, w, h) => {
1436 return new go.Geometry()
1437 .add(new go.PathFigure(.5 * w, 0, true)
1438 .add(new go.PathSegment(go.PathSegment.Line, .51 * w, .01 * h))
1439 .add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, .6 * w, .2 * h, w, .25 * h))
1440 .add(new go.PathSegment(go.PathSegment.Bezier, .55 * w, .7 * h, w, .8 * h, .6 * w, .8 * h))
1441 .add(new go.PathSegment(go.PathSegment.Bezier, .75 * w, h, .5 * w, .75 * h, .55 * w, .95 * h))
1442 .add(new go.PathSegment(go.PathSegment.Line, .25 * w, h))
1443 .add(new go.PathSegment(go.PathSegment.Bezier, .45 * w, .7 * h, .45 * w, .95 * h, .5 * w, .75 * h))
1444 .add(new go.PathSegment(go.PathSegment.Bezier, 0, .5 * h, .4 * w, .8 * h, 0, .8 * h))
1445 .add(new go.PathSegment(go.PathSegment.Bezier, .49 * w, .01 * h, 0, .25 * h, .4 * w, .2 * h).close()))
1446 .setSpots(.14, .26, .86, .78);
1447});
1448
1449go.Shape.defineFigureGenerator('Club', (shape, w, h) => {
1450 const geo = new go.Geometry();
1451 const fig = new go.PathFigure(.4 * w, .6 * h, true);
1452 geo.add(fig);
1453 // Start the base
1454 fig.add(new go.PathSegment(go.PathSegment.Bezier, .15 * w, h, .5 * w, .75 * h, .45 * w, .95 * h));
1455 fig.add(new go.PathSegment(go.PathSegment.Line, .85 * w, h));
1456 fig.add(new go.PathSegment(go.PathSegment.Bezier, .6 * w, .6 * h, .55 * w, .95 * h, .5 * w, .75 * h));
1457 // First circle:
1458 let r = .2; // radius
1459 let cx = .3; // offset from Center x
1460 let cy = 0; // offset from Center y
1461 let d = r * KAPPA;
1462 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 + r + cy) * h,
1463 (.5 - r + cx) * w, (.5 + d + cy) * h,
1464 (.5 - d + cx) * w, (.5 + r + cy) * h));
1465 fig.add(new go.PathSegment(go.PathSegment.Bezier, (1 - .5 + r + cx) * w, (.5 + cy) * h,
1466 (.5 + d + cx) * w, (.5 + r + cy) * h,
1467 (.5 + r + cx) * w, (.5 + d + cy) * h));
1468 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 - r + cy) * h,
1469 (1 - .5 + r + cx) * w, (.5 - d + cy) * h,
1470 (.5 + d + cx) * w, (.5 - r + cy) * h));
1471 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.65) * w, (0.36771243) * h,
1472 (.5 - d + cx) * w, (.5 - r + cy) * h,
1473 (.5 - r + cx + .05) * w, (.5 - d + cy - .02) * h));
1474 r = .2; // radius
1475 cx = 0; // offset from Center x
1476 cy = -.3; // offset from Center y
1477 d = r * KAPPA;
1478 fig.add(new go.PathSegment(go.PathSegment.Bezier, (1 - .5 + r + cx) * w, (.5 + cy) * h,
1479 (.5 + d + cx) * w, (.5 + r + cy) * h,
1480 (.5 + r + cx) * w, (.5 + d + cy) * h));
1481 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 - r + cy) * h,
1482 (1 - .5 + r + cx) * w, (.5 - d + cy) * h,
1483 (.5 + d + cx) * w, (.5 - r + cy) * h));
1484 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 - r + cx) * w, (.5 + cy) * h,
1485 (.5 - d + cx) * w, (.5 - r + cy) * h,
1486 (.5 - r + cx) * w, (.5 - d + cy) * h));
1487 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 - d + cx) * w, (.5 + r + cy) * h,
1488 (.5 - r + cx) * w, (.5 + d + cy) * h,
1489 (.5 - d + cx) * w, (.5 + r + cy) * h));
1490 r = .2; // radius
1491 cx = -.3; // offset from Center x
1492 cy = 0; // offset from Center y
1493 d = r * KAPPA;
1494 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 - r + cy) * h,
1495 (1 - .5 + r + cx - .05) * w, (.5 - d + cy - .02) * h,
1496 (.5 + d + cx) * w, (.5 - r + cy) * h));
1497 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 - r + cx) * w, (.5 + cy) * h,
1498 (.5 - d + cx) * w, (.5 - r + cy) * h,
1499 (.5 - r + cx) * w, (.5 - d + cy) * h));
1500 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 + r + cy) * h,
1501 (.5 - r + cx) * w, (.5 + d + cy) * h,
1502 (.5 - d + cx) * w, (.5 + r + cy) * h));
1503 fig.add(new go.PathSegment(go.PathSegment.Bezier, .4 * w, .6 * h,
1504 (.5 + d + cx) * w, (.5 + r + cy) * h,
1505 (.5 + r + cx) * w, (.5 + d + cy) * h).close());
1506 geo.setSpots(.06, .33, .93, .68);
1507 return geo;
1508});
1509
1510go.Shape.defineFigureGenerator('YinYang', (shape, w, h) => {
1511 const geo = new go.Geometry();
1512 let fig = new go.PathFigure(w * 0.5, 0, true);
1513 geo.add(fig);
1514 // Right semi-circle
1515 fig.add(new go.PathSegment(go.PathSegment.Arc, 270, 180, w * 0.5, w * 0.5, w * 0.5, w * 0.5));
1516 // bottom semi-circle
1517 fig.add(new go.PathSegment(go.PathSegment.Arc, 90, -180, w * 0.5, w * 0.75, w * 0.25, w * 0.25));
1518 // top semi-circle
1519 fig.add(new go.PathSegment(go.PathSegment.Arc, 90, 180, w * 0.5, w * 0.25, w * 0.25, w * 0.25));
1520 const radius = .1; // of the small circles
1521 const centerx = .5;
1522 let centery = .25;
1523 // Top small circle, goes counter-clockwise
1524 fig.add(new go.PathSegment(go.PathSegment.Move, (centerx + radius) * w, (centery) * h));
1525 fig.add(new go.PathSegment(go.PathSegment.Arc, 0, -360, w * centerx, h * centery, radius * w, radius * w).close()); // Right semi-circle
1526 // Left semi-circle
1527 fig = new go.PathFigure(w * 0.5, 0, false);
1528 geo.add(fig);
1529 fig.add(new go.PathSegment(go.PathSegment.Arc, 270, -180, w * 0.5, w * 0.5, w * 0.5, w * 0.5));
1530 centery = .75;
1531 // Bottom small circle
1532 fig = new go.PathFigure((centerx + radius) * w, (centery) * h, true); // Not a subpath
1533 geo.add(fig);
1534 fig.add(new go.PathSegment(go.PathSegment.Arc, 0, 360, w * centerx, h * centery, radius * w, radius * w).close()); // Right semi-circle
1535 geo.defaultStretch = go.GraphObject.Uniform;
1536 return geo;
1537});
1538
1539go.Shape.defineFigureGenerator('Peace', (shape, w, h) => {
1540 const a = 1.0 - 0.1464466094067262; // at 45 degrees
1541 const w2 = 0.5 * w;
1542 const h2 = 0.5 * h;
1543 return new go.Geometry()
1544 .add(new go.PathFigure(w2, 0, false)
1545 .add(new go.PathSegment(go.PathSegment.Arc, 270, 360, w2, h2, w2, h2))
1546 .add(new go.PathSegment(go.PathSegment.Line, w2, h))
1547 .add(new go.PathSegment(go.PathSegment.Move, w2, h2))
1548 .add(new go.PathSegment(go.PathSegment.Line, (1.0 - a) * w, a * h))
1549 .add(new go.PathSegment(go.PathSegment.Move, w2, h2))
1550 .add(new go.PathSegment(go.PathSegment.Line, a * w, a * h)));
1551});
1552
1553go.Shape.defineFigureGenerator('NotAllowed', (shape, w, h) => {
1554 const geo = new go.Geometry();
1555 let cpOffset = KAPPA * .5;
1556 let radius = .5;
1557 const centerx = .5;
1558 const centery = .5;
1559 const fig = new go.PathFigure(centerx * w, (centery - radius) * h);
1560 geo.add(fig);
1561 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery - radius) * h,
1562 (centerx - radius) * w, (centery - cpOffset) * h));
1563 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx - radius) * w, (centery + cpOffset) * h,
1564 (centerx - cpOffset) * w, (centery + radius) * h));
1565 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery + radius) * h,
1566 (centerx + radius) * w, (centery + cpOffset) * h));
1567 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx + radius) * w, (centery - cpOffset) * h,
1568 (centerx + cpOffset) * w, (centery - radius) * h));
1569 // Inner circle, composed of two parts, separated by
1570 // a beam across going from top-right to bottom-left.
1571 radius = .40;
1572 cpOffset = KAPPA * .40;
1573 // First we cut up the top right 90 degree curve into two smaller
1574 // curves.
1575 // Since its clockwise, StartOfArrow is the first of the two points
1576 // on the circle. EndOfArrow is the other one.
1577 const startOfArrowc1 = tempPoint();
1578 const startOfArrowc2 = tempPoint();
1579 const startOfArrow = tempPoint();
1580 const unused = tempPoint();
1581 breakUpBezier(centerx, centery - radius,
1582 centerx + cpOffset, centery - radius,
1583 centerx + radius, centery - cpOffset,
1584 centerx + radius, centery, .42, startOfArrowc1,
1585 startOfArrowc2, startOfArrow, unused, unused);
1586 const endOfArrowc1 = tempPoint();
1587 const endOfArrowc2 = tempPoint();
1588 const endOfArrow = tempPoint();
1589 breakUpBezier(centerx, centery - radius,
1590 centerx + cpOffset, centery - radius,
1591 centerx + radius, centery - cpOffset,
1592 centerx + radius, centery, .58, unused,
1593 unused, endOfArrow, endOfArrowc1, endOfArrowc2);
1594 // Cut up the bottom left 90 degree curve into two smaller curves.
1595 const startOfArrow2c1 = tempPoint();
1596 const startOfArrow2c2 = tempPoint();
1597 const startOfArrow2 = tempPoint();
1598 breakUpBezier(centerx, centery + radius,
1599 centerx - cpOffset, centery + radius,
1600 centerx - radius, centery + cpOffset,
1601 centerx - radius, centery, .42, startOfArrow2c1,
1602 startOfArrow2c2, startOfArrow2, unused, unused);
1603 const endOfArrow2c1 = tempPoint();
1604 const endOfArrow2c2 = tempPoint();
1605 const endOfArrow2 = tempPoint();
1606 breakUpBezier(centerx, centery + radius,
1607 centerx - cpOffset, centery + radius,
1608 centerx - radius, centery + cpOffset,
1609 centerx - radius, centery, .58, unused,
1610 unused, endOfArrow2, endOfArrow2c1, endOfArrow2c2);
1611 fig.add(new go.PathSegment(go.PathSegment.Move, endOfArrow2.x * w, endOfArrow2.y * h));
1612 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, endOfArrow2c1.x * w, endOfArrow2c1.y * h,
1613 endOfArrow2c2.x * w, endOfArrow2c2.y * h));
1614 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
1615 (centerx - cpOffset) * w, (centery - radius) * h));
1616 fig.add(new go.PathSegment(go.PathSegment.Bezier, startOfArrow.x * w, startOfArrow.y * h, startOfArrowc1.x * w, startOfArrowc1.y * h,
1617 startOfArrowc2.x * w, startOfArrowc2.y * h));
1618 fig.add(new go.PathSegment(go.PathSegment.Line, endOfArrow2.x * w, endOfArrow2.y * h).close());
1619 fig.add(new go.PathSegment(go.PathSegment.Move, startOfArrow2.x * w, startOfArrow2.y * h));
1620 fig.add(new go.PathSegment(go.PathSegment.Line, endOfArrow.x * w, endOfArrow.y * h));
1621 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, endOfArrowc1.x * w, endOfArrowc1.y * h,
1622 endOfArrowc2.x * w, endOfArrowc2.y * h));
1623 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
1624 (centerx + cpOffset) * w, (centery + radius) * h));
1625 fig.add(new go.PathSegment(go.PathSegment.Bezier, startOfArrow2.x * w, startOfArrow2.y * h, startOfArrow2c1.x * w, startOfArrow2c1.y * h,
1626 startOfArrow2c2.x * w, startOfArrow2c2.y * h).close());
1627 freePoint(startOfArrowc1);
1628 freePoint(startOfArrowc2);
1629 freePoint(startOfArrow);
1630 freePoint(unused);
1631 freePoint(endOfArrowc1);
1632 freePoint(endOfArrowc2);
1633 freePoint(endOfArrow);
1634 freePoint(startOfArrow2c1);
1635 freePoint(startOfArrow2c2);
1636 freePoint(startOfArrow2);
1637 freePoint(endOfArrow2c1);
1638 freePoint(endOfArrow2c2);
1639 freePoint(endOfArrow2);
1640 geo.defaultStretch = go.GraphObject.Uniform;
1641 return geo;
1642});
1643
1644go.Shape.defineFigureGenerator('Fragile', (shape, w, h) => {
1645 return new go.Geometry()
1646 .add(new go.PathFigure(0, 0, true)
1647 .add(new go.PathSegment(go.PathSegment.Line, .25 * w, 0))
1648 .add(new go.PathSegment(go.PathSegment.Line, .2 * w, .15 * h))
1649 .add(new go.PathSegment(go.PathSegment.Line, .3 * w, .25 * h))
1650 .add(new go.PathSegment(go.PathSegment.Line, .29 * w, .33 * h))
1651 .add(new go.PathSegment(go.PathSegment.Line, .35 * w, .25 * h))
1652 .add(new go.PathSegment(go.PathSegment.Line, .3 * w, .15 * h))
1653 .add(new go.PathSegment(go.PathSegment.Line, .4 * w, 0))
1654 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
1655 // Left Side
1656 .add(new go.PathSegment(go.PathSegment.Bezier, .55 * w, .5 * h, w, .25 * h, .75 * w, .5 * h))
1657 .add(new go.PathSegment(go.PathSegment.Line, .55 * w, .9 * h))
1658 // The base
1659 .add(new go.PathSegment(go.PathSegment.Line, .7 * w, .9 * h))
1660 .add(new go.PathSegment(go.PathSegment.Line, .7 * w, h))
1661 .add(new go.PathSegment(go.PathSegment.Line, .3 * w, h))
1662 .add(new go.PathSegment(go.PathSegment.Line, .3 * w, .9 * h))
1663 // Right side
1664 .add(new go.PathSegment(go.PathSegment.Line, .45 * w, .9 * h))
1665 .add(new go.PathSegment(go.PathSegment.Line, .45 * w, .5 * h))
1666 .add(new go.PathSegment(go.PathSegment.Bezier, 0, 0, .25 * w, .5 * h, 0, .25 * h).close()));
1667});
1668
1669FigureParameter.setFigureParameter('HourGlass', 0, new FigureParameter('Thickness', 30));
1670go.Shape.defineFigureGenerator('HourGlass', (shape, w, h) => {
1671 let param1 = shape ? shape.parameter1 : NaN; // width at middle of hourglass
1672 if (isNaN(param1) || param1 < 0) param1 = 30;
1673 if (param1 > w) param1 = w;
1674 const x1 = (w - param1) / 2;
1675 const x2 = x1 + param1;
1676 return new go.Geometry()
1677 .add(new go.PathFigure(x2, 0.5 * h)
1678 .add(new go.PathSegment(go.PathSegment.Line, w, h))
1679 .add(new go.PathSegment(go.PathSegment.Line, 0, h))
1680 .add(new go.PathSegment(go.PathSegment.Line, x1, 0.5 * h))
1681 .add(new go.PathSegment(go.PathSegment.Line, 0, 0))
1682 .add(new go.PathSegment(go.PathSegment.Line, w, 0).close()));
1683});
1684
1685go.Shape.defineFigureGenerator('Lightning', (shape, w, h) => {
1686 return new go.Geometry()
1687 .add(new go.PathFigure(0, 0.55 * h)
1688 .add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0))
1689 .add(new go.PathSegment(go.PathSegment.Line, 0.3 * w, 0.45 * h))
1690 .add(new go.PathSegment(go.PathSegment.Line, w, 0.45 * h))
1691 .add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, h))
1692 .add(new go.PathSegment(go.PathSegment.Line, 0.7 * w, 0.55 * h).close()));
1693});
1694
1695go.Shape.defineFigureGenerator('GenderMale', (shape, w, h) => {
1696 const geo = new go.Geometry();
1697 let cpOffset = KAPPA * .4;
1698 let radius = .4;
1699 const centerx = .5;
1700 const centery = .5;
1701 const unused = tempPoint();
1702 const mid = tempPoint();
1703 const c1 = tempPoint();
1704 const c2 = tempPoint();
1705 const fig = new go.PathFigure((centerx - radius) * w, centery * h, false);
1706 geo.add(fig);
1707
1708 // Outer circle
1709 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
1710 (centerx - cpOffset) * w, (centery - radius) * h));
1711 breakUpBezier(centerx, centery - radius,
1712 centerx + cpOffset, centery - radius,
1713 centerx + radius, centery - cpOffset,
1714 centerx + radius, centery, .44, c1,
1715 c2, mid, unused, unused);
1716 fig.add(new go.PathSegment(go.PathSegment.Bezier, mid.x * w, mid.y * h, c1.x * w, c1.y * h, c2.x * w, c2.y * h));
1717 const startOfArrow = tempPointAt(mid.x, mid.y);
1718 breakUpBezier(centerx, centery - radius,
1719 centerx + cpOffset, centery - radius,
1720 centerx + radius, centery - cpOffset,
1721 centerx + radius, centery, .56, unused,
1722 unused, mid, c1, c2);
1723 const endOfArrow = tempPointAt(mid.x, mid.y);
1724 fig.add(new go.PathSegment(go.PathSegment.Line, (startOfArrow.x * .1 + .95 * .9) * w,
1725 (startOfArrow.y * .1) * h));
1726 fig.add(new go.PathSegment(go.PathSegment.Line, .85 * w, (startOfArrow.y * .1) * h));
1727 fig.add(new go.PathSegment(go.PathSegment.Line, .85 * w, 0));
1728 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
1729 fig.add(new go.PathSegment(go.PathSegment.Line, w, .15 * h));
1730 fig.add(new go.PathSegment(go.PathSegment.Line, (endOfArrow.x * .1 + .9) * w, .15 * h));
1731 fig.add(new go.PathSegment(go.PathSegment.Line, (endOfArrow.x * .1 + .9) * w,
1732 (endOfArrow.y * .1 + .05 * .9) * h));
1733 fig.add(new go.PathSegment(go.PathSegment.Line, endOfArrow.x * w, endOfArrow.y * h));
1734 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, c1.x * w, c1.y * h, c2.x * w, c2.y * h));
1735 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
1736 (centerx + cpOffset) * w, (centery + radius) * h));
1737 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
1738 (centerx - radius) * w, (centery + cpOffset) * h));
1739 // Inner circle
1740 radius = .35;
1741 cpOffset = KAPPA * .35;
1742 const fig2 = new go.PathFigure(centerx * w, (centery - radius) * h, false);
1743 geo.add(fig2);
1744 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery - radius) * h,
1745 (centerx - radius) * w, (centery - cpOffset) * h));
1746 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx - radius) * w, (centery + cpOffset) * h,
1747 (centerx - cpOffset) * w, (centery + radius) * h));
1748 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery + radius) * h,
1749 (centerx + radius) * w, (centery + cpOffset) * h));
1750 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx + radius) * w, (centery - cpOffset) * h,
1751 (centerx + cpOffset) * w, (centery - radius) * h));
1752 const fig3 = new go.PathFigure((centerx - radius) * w, centery * h, false);
1753 geo.add(fig3);
1754 freePoint(unused);
1755 freePoint(mid);
1756 freePoint(c1);
1757 freePoint(c2);
1758 freePoint(startOfArrow);
1759 freePoint(endOfArrow);
1760 geo.spot1 = new go.Spot(.202, .257);
1761 geo.spot2 = new go.Spot(.792, .739);
1762 geo.defaultStretch = go.GraphObject.Uniform;
1763 return geo;
1764});
1765
1766go.Shape.defineFigureGenerator('GenderFemale', (shape, w, h) => {
1767 const geo = new go.Geometry();
1768 // Outer Circle
1769 let r = .375; // radius
1770 let cx = 0; // offset from Center x
1771 let cy = -.125; // offset from Center y
1772 let d = r * KAPPA;
1773 let fig = new go.PathFigure((.525 + cx) * w, (.5 + r + cy) * h, false);
1774 geo.add(fig);
1775
1776 fig.add(new go.PathSegment(go.PathSegment.Bezier, (1 - .5 + r + cx) * w, (.5 + cy) * h, (.5 + d + cx) * w, (.5 + r + cy) * h,
1777 (.5 + r + cx) * w, (.5 + d + cy) * h));
1778 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 - r + cy) * h, (1 - .5 + r + cx) * w, (.5 - d + cy) * h,
1779 (.5 + d + cx) * w, (.5 - r + cy) * h));
1780 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 - r + cx) * w, (.5 + cy) * h, (.5 - d + cx) * w, (.5 - r + cy) * h,
1781 (.5 - r + cx) * w, (.5 - d + cy) * h));
1782 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.475 + cx) * w, (.5 + r + cy) * h, (.5 - r + cx) * w, (.5 + d + cy) * h,
1783 (.5 - d + cx) * w, (.5 + r + cy) * h));
1784 // Legs
1785 fig.add(new go.PathSegment(go.PathSegment.Line, .475 * w, .85 * h));
1786 fig.add(new go.PathSegment(go.PathSegment.Line, .425 * w, .85 * h));
1787 fig.add(new go.PathSegment(go.PathSegment.Line, .425 * w, .9 * h));
1788 fig.add(new go.PathSegment(go.PathSegment.Line, .475 * w, .9 * h));
1789 fig.add(new go.PathSegment(go.PathSegment.Line, .475 * w, h));
1790 fig.add(new go.PathSegment(go.PathSegment.Line, .525 * w, h));
1791 fig.add(new go.PathSegment(go.PathSegment.Line, .525 * w, .9 * h));
1792 fig.add(new go.PathSegment(go.PathSegment.Line, .575 * w, .9 * h));
1793 fig.add(new go.PathSegment(go.PathSegment.Line, .575 * w, .85 * h));
1794 fig.add(new go.PathSegment(go.PathSegment.Line, .525 * w, .85 * h).close());
1795 // Inner circle
1796 r = .325; // radius
1797 cx = 0; // offset from Center x
1798 cy = -.125; // offset from Center y
1799 d = r * KAPPA;
1800 fig = new go.PathFigure((1 - .5 + r + cx) * w, (.5 + cy) * h, false);
1801 geo.add(fig);
1802
1803 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 + r + cy) * h, (.5 + r + cx) * w, (.5 + d + cy) * h,
1804 (.5 + d + cx) * w, (.5 + r + cy) * h));
1805 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 - r + cx) * w, (.5 + cy) * h, (.5 - d + cx) * w, (.5 + r + cy) * h,
1806 (.5 - r + cx) * w, (.5 + d + cy) * h));
1807 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 + cx) * w, (.5 - r + cy) * h, (.5 - r + cx) * w, (.5 - d + cy) * h,
1808 (.5 - d + cx) * w, (.5 - r + cy) * h));
1809 fig.add(new go.PathSegment(go.PathSegment.Bezier, (1 - .5 + r + cx) * w, (.5 + cy) * h, (.5 + d + cx) * w, (.5 - r + cy) * h,
1810 (1 - .5 + r + cx) * w, (.5 - d + cy) * h));
1811 fig = new go.PathFigure((.525 + cx) * w, (.5 + r + cy) * h, false);
1812 geo.add(fig);
1813 geo.spot1 = new go.Spot(.232, .136);
1814 geo.spot2 = new go.Spot(.682, .611);
1815 geo.defaultStretch = go.GraphObject.Uniform;
1816 return geo;
1817});
1818
1819go.Shape.defineFigureGenerator('LogicImplies', (shape, w, h) => {
1820 let param1 = shape ? shape.parameter1 : NaN;
1821 if (isNaN(param1)) param1 = .2; // Distance the arrow folds from the right
1822 return new go.Geometry()
1823 .add(new go.PathFigure((1 - param1) * w, 0, false)
1824 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h))
1825 .add(new go.PathSegment(go.PathSegment.Line, (1 - param1) * w, h))
1826 .add(new go.PathSegment(go.PathSegment.Move, 0, .5 * h))
1827 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h)))
1828 .setSpots(0, 0, 0.8, 0.5);
1829});
1830
1831go.Shape.defineFigureGenerator('LogicIff', (shape, w, h) => {
1832 let param1 = shape ? shape.parameter1 : NaN;
1833 if (isNaN(param1)) param1 = .2; // Distance the arrow folds from the right
1834 return new go.Geometry()
1835 .add(new go.PathFigure((1 - param1) * w, 0, false)
1836 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h))
1837 .add(new go.PathSegment(go.PathSegment.Line, (1 - param1) * w, h))
1838 .add(new go.PathSegment(go.PathSegment.Move, 0, .5 * h))
1839 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h))
1840 .add(new go.PathSegment(go.PathSegment.Move, param1 * w, 0))
1841 .add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h))
1842 .add(new go.PathSegment(go.PathSegment.Line, param1 * w, h)))
1843 .setSpots(0.2, 0, 0.8, 0.5);
1844});
1845
1846go.Shape.defineFigureGenerator('LogicNot', (shape, w, h) => {
1847 return new go.Geometry()
1848 .add(new go.PathFigure(0, 0, false)
1849 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
1850 .add(new go.PathSegment(go.PathSegment.Line, w, h)));
1851});
1852
1853go.Shape.defineFigureGenerator('LogicAnd', (shape, w, h) => {
1854 return new go.Geometry()
1855 .add(new go.PathFigure(0, h, false)
1856 .add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0))
1857 .add(new go.PathSegment(go.PathSegment.Line, w, h)))
1858 .setSpots(0.25, 0.5, 0.75, 1);
1859});
1860
1861go.Shape.defineFigureGenerator('LogicOr', (shape, w, h) => {
1862 return new go.Geometry()
1863 .add(new go.PathFigure(0, 0, false)
1864 .add(new go.PathSegment(go.PathSegment.Line, .5 * w, h))
1865 .add(new go.PathSegment(go.PathSegment.Line, w, 0)))
1866 .setSpots(0.219, 0, 0.78, 0.409);
1867});
1868
1869go.Shape.defineFigureGenerator('LogicXor', (shape, w, h) => {
1870 const geo = new go.Geometry()
1871 .add(new go.PathFigure(.5 * w, 0, false)
1872 .add(new go.PathSegment(go.PathSegment.Line, .5 * w, h))
1873 .add(new go.PathSegment(go.PathSegment.Move, 0, .5 * h))
1874 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h))
1875 .add(new go.PathSegment(go.PathSegment.Arc, 0, 360, .5 * w, .5 * h, .5 * w, .5 * h)));
1876 geo.defaultStretch = go.GraphObject.Uniform;
1877 return geo;
1878});
1879
1880go.Shape.defineFigureGenerator('LogicTruth', (shape, w, h) => {
1881 return new go.Geometry()
1882 .add(new go.PathFigure(0, 0, false)
1883 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
1884 .add(new go.PathSegment(go.PathSegment.Move, .5 * w, 0))
1885 .add(new go.PathSegment(go.PathSegment.Line, .5 * w, h)));
1886});
1887
1888go.Shape.defineFigureGenerator('LogicFalsity', (shape, w, h) => {
1889 return new go.Geometry()
1890 .add(new go.PathFigure(0, h, false)
1891 .add(new go.PathSegment(go.PathSegment.Line, w, h))
1892 .add(new go.PathSegment(go.PathSegment.Move, .5 * w, h))
1893 .add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0)));
1894});
1895
1896go.Shape.defineFigureGenerator('LogicThereExists', (shape, w, h) => {
1897 return new go.Geometry()
1898 .add(new go.PathFigure(0, 0, false)
1899 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
1900 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h))
1901 .add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h))
1902 .add(new go.PathSegment(go.PathSegment.Move, w, .5 * h))
1903 .add(new go.PathSegment(go.PathSegment.Line, w, h))
1904 .add(new go.PathSegment(go.PathSegment.Line, 0, h)));
1905});
1906
1907go.Shape.defineFigureGenerator('LogicForAll', (shape, w, h) => {
1908 return new go.Geometry()
1909 .add(new go.PathFigure(0, 0, false)
1910 .add(new go.PathSegment(go.PathSegment.Line, .5 * w, h))
1911 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
1912 .add(new go.PathSegment(go.PathSegment.Move, .25 * w, .5 * h))
1913 .add(new go.PathSegment(go.PathSegment.Line, .75 * w, .5 * h)))
1914 .setSpots(0.25, 0, 0.75, 0.5);
1915});
1916
1917go.Shape.defineFigureGenerator('LogicIsDefinedAs', (shape, w, h) => {
1918 return new go.Geometry()
1919 .add(new go.PathFigure(0, 0, false)
1920 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
1921 .add(new go.PathSegment(go.PathSegment.Move, 0, .5 * h))
1922 .add(new go.PathSegment(go.PathSegment.Line, w, .5 * h))
1923 .add(new go.PathSegment(go.PathSegment.Move, 0, h))
1924 .add(new go.PathSegment(go.PathSegment.Line, w, h)))
1925 .setSpots(0.01, 0.01, 0.99, 0.49);
1926});
1927
1928go.Shape.defineFigureGenerator('LogicIntersect', (shape, w, h) => {
1929 const radius = 0.5;
1930 return new go.Geometry()
1931 .add(new go.PathFigure(0, h, false)
1932 .add(new go.PathSegment(go.PathSegment.Line, 0, radius * h))
1933 .add(new go.PathSegment(go.PathSegment.Arc, 180, 180, radius * w, radius * h, radius * w, radius * h))
1934 .add(new go.PathSegment(go.PathSegment.Line, w, h)))
1935 .setSpots(0, 0.5, 1, 1);
1936});
1937
1938go.Shape.defineFigureGenerator('LogicUnion', (shape, w, h) => {
1939 const radius = 0.5;
1940 return new go.Geometry()
1941 .add(new go.PathFigure(w, 0, false)
1942 .add(new go.PathSegment(go.PathSegment.Line, w, radius * h))
1943 .add(new go.PathSegment(go.PathSegment.Arc, 0, 180, radius * w, radius * h, radius * w, radius * h))
1944 .add(new go.PathSegment(go.PathSegment.Line, 0, 0)))
1945 .setSpots(0, 0, 1, 0.5);
1946});
1947
1948FigureParameter.setFigureParameter('Arrow', 0, new FigureParameter('ArrowheadWidth', .3, .01, .99));
1949FigureParameter.setFigureParameter('Arrow', 1, new FigureParameter('TailHeight', .3, .01, .99));
1950go.Shape.defineFigureGenerator('Arrow', (shape, w, h) => {
1951 let param1 = shape ? shape.parameter1 : NaN; // % width of arrowhead
1952 if (isNaN(param1)) param1 = .3;
1953 let param2 = shape ? shape.parameter2 : NaN; // % height of tail
1954 if (isNaN(param2)) param2 = .3;
1955
1956 const x = (1 - param1) * w;
1957 const y1 = (.5 - param2 / 2) * h;
1958 const y2 = (.5 + param2 / 2) * h;
1959
1960 const geo = new go.Geometry();
1961 const fig = new go.PathFigure(0, y1, true);
1962 geo.add(fig);
1963 fig.add(new go.PathSegment(go.PathSegment.Line, x, y1));
1964 fig.add(new go.PathSegment(go.PathSegment.Line, x, 0));
1965 fig.add(new go.PathSegment(go.PathSegment.Line, x, 0));
1966 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
1967 fig.add(new go.PathSegment(go.PathSegment.Line, x, h));
1968 fig.add(new go.PathSegment(go.PathSegment.Line, x, y2));
1969 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y2).close());
1970 geo.spot1 = new go.Spot(0, y1 / h);
1971 const temp = getIntersection(0, y2 / h,
1972 1, y2 / h,
1973 x / w, 1,
1974 1, .5,
1975 tempPoint());
1976 geo.spot2 = new go.Spot(temp.x, temp.y);
1977 freePoint(temp);
1978 return geo;
1979});
1980
1981// Arrow with absolutes instead of scaling
1982FigureParameter.setFigureParameter('Arrow2', 0, new FigureParameter('ArrowheadWidth', 30));
1983FigureParameter.setFigureParameter('Arrow2', 1, new FigureParameter('TailHeight', 30));
1984go.Shape.defineFigureGenerator('Arrow2', (shape, w, h) => {
1985 let param1 = shape ? shape.parameter1 : NaN; // width of arrowhead
1986 if (isNaN(param1)) param1 = 30;
1987 if (param1 > w) param1 = w;
1988 let param2 = shape ? shape.parameter2 : NaN; // height of tail
1989 if (isNaN(param2)) param2 = 30;
1990 param2 = Math.min(param2, h / 2);
1991
1992 const x = w - param1;
1993 const y1 = (h - param2) / 2;
1994 const y2 = y1 + param2;
1995
1996 const geo = new go.Geometry();
1997 const fig = new go.PathFigure(0, y1, true);
1998 geo.add(fig);
1999 fig.add(new go.PathSegment(go.PathSegment.Line, x, y1));
2000 fig.add(new go.PathSegment(go.PathSegment.Line, x, 0));
2001 fig.add(new go.PathSegment(go.PathSegment.Line, x, 0));
2002 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
2003 fig.add(new go.PathSegment(go.PathSegment.Line, x, h));
2004 fig.add(new go.PathSegment(go.PathSegment.Line, x, y2));
2005 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y2).close());
2006 geo.spot1 = new go.Spot(0, y1 / h);
2007 const temp = getIntersection(0, y2 / h,
2008 1, y2 / h,
2009 x / w, 1,
2010 1, .5,
2011 tempPoint());
2012 geo.spot2 = new go.Spot(temp.x, temp.y);
2013 freePoint(temp);
2014 return geo;
2015});
2016
2017go.Shape.defineFigureGenerator('Chevron', (shape, w, h) => {
2018 const geo = new go.Geometry();
2019 const fig = new go.PathFigure(0, 0, true);
2020 geo.add(fig);
2021
2022 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
2023 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
2024 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2025 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2026 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h).close());
2027 return geo;
2028});
2029
2030go.Shape.defineFigureGenerator('DoubleArrow', (shape, w, h) => {
2031 const geo = new go.Geometry();
2032 const fig = new go.PathFigure(0, 0, true);
2033 geo.add(fig);
2034
2035 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 0.214 * h));
2036 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 0));
2037 fig.add(new go.PathSegment(go.PathSegment.Line, 1.0 * w, .5 * h));
2038 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 1.0 * h));
2039 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 0.786 * h));
2040 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 1.0 * h).close());
2041 return geo;
2042});
2043
2044FigureParameter.setFigureParameter('DoubleEndArrow', 0, new FigureParameter('ConnecterHeight', .3, .01, .99));
2045go.Shape.defineFigureGenerator('DoubleEndArrow', (shape, w, h) => {
2046 let param1 = shape ? shape.parameter1 : NaN; // height of midsection
2047 if (isNaN(param1)) param1 = .3;
2048
2049 const y1 = (.5 - param1 / 2) * h;
2050 const y2 = (.5 + param1 / 2) * h;
2051
2052 const geo = new go.Geometry();
2053 const fig = new go.PathFigure(w, .5 * h, true);
2054 geo.add(fig);
2055 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, h));
2056 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2));
2057 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, y2));
2058 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, h));
2059 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h));
2060 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 0));
2061 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, y1));
2062 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1));
2063 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, 0).close());
2064 let temp = getIntersection(0, .5,
2065 .3, 0,
2066 0, y1 / h,
2067 .1, y1 / h,
2068 tempPoint());
2069 geo.spot1 = new go.Spot(temp.x, temp.y);
2070 temp = getIntersection(.7, 1,
2071 1, .5,
2072 0, y2 / h,
2073 1, y2 / h,
2074 temp);
2075 geo.spot2 = new go.Spot(temp.x, temp.y);
2076 freePoint(temp);
2077 return geo;
2078});
2079
2080// DoubleEndArrow with absolutes instead of scaling
2081FigureParameter.setFigureParameter('DoubleEndArrow2', 0, new FigureParameter('ConnecterHeight', 40));
2082FigureParameter.setFigureParameter('DoubleEndArrow2', 1, new FigureParameter('ArrowHeight', 100));
2083go.Shape.defineFigureGenerator('DoubleEndArrow2', (shape, w, h) => {
2084 let param1 = shape ? shape.parameter1 : NaN; // height of midsection
2085 if (isNaN(param1)) param1 = 40;
2086 let param2 = shape ? shape.parameter2 : NaN; // height of arrows
2087 if (isNaN(param2)) param2 = 100;
2088
2089 /*
2090 y1outer
2091 /| |\
2092 / | | \
2093 / y1---- \
2094 / \
2095 \ /
2096 \ y2---- /
2097 \ | | /
2098 \| |/
2099 y2outer
2100 */
2101 let y1 = (h - param1) / 2;
2102 let y2 = y1 + param1;
2103 let y1outer = (h - param2) / 2;
2104 let y2outer = y1outer + param2;
2105 if (param1 > h || param2 > h) {
2106 if (param2 > param1) {
2107 param1 = param1 * h / param2; // use similar ratio
2108 y1 = (h - param1) / 2;
2109 y2 = y1 + param1;
2110 y1outer = 0;
2111 y2outer = h;
2112 } else {
2113 y1 = 0;
2114 y2 = h;
2115 y1outer = 0;
2116 y2outer = h;
2117 }
2118 }
2119 const geo = new go.Geometry();
2120 const fig = new go.PathFigure(w, .5 * h, true);
2121 geo.add(fig);
2122 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2outer));
2123 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2));
2124 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, y2));
2125 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, y2outer));
2126 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h));
2127 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, y1outer));
2128 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, y1));
2129 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1));
2130 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1outer).close());
2131 let temp = getIntersection(0, .5,
2132 .3, y1outer / h,
2133 0, y1 / h,
2134 1, y1 / h,
2135 tempPoint());
2136 geo.spot1 = new go.Spot(temp.x, temp.y);
2137 temp = getIntersection(.7, y2outer / h,
2138 1, .5,
2139 0, y2 / h,
2140 1, y2 / h,
2141 temp);
2142 geo.spot2 = new go.Spot(temp.x, temp.y);
2143 freePoint(temp);
2144
2145 return geo;
2146});
2147
2148FigureParameter.setFigureParameter('IBeamArrow', 0, new FigureParameter('ConnectorHeight', .3, .01, .99));
2149go.Shape.defineFigureGenerator('IBeamArrow', (shape, w, h) => {
2150 let param1 = shape ? shape.parameter1 : NaN; // height of midsection
2151 if (isNaN(param1)) param1 = .3;
2152
2153 const y1 = (.5 - param1 / 2) * h;
2154 const y2 = (.5 + param1 / 2) * h;
2155
2156 const geo = new go.Geometry();
2157 const fig = new go.PathFigure(w, .5 * h, true);
2158 geo.add(fig);
2159 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, h));
2160 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2));
2161 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, y2));
2162 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, h));
2163 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2164 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
2165 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, 0));
2166 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, y1));
2167 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1));
2168 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, 0).close());
2169 geo.spot1 = new go.Spot(0, y1 / h);
2170 const temp = getIntersection(.7, 1,
2171 1, .5,
2172 0, y2 / h,
2173 1, y2 / h,
2174 tempPoint());
2175 geo.spot2 = new go.Spot(temp.x, temp.y);
2176 freePoint(temp);
2177 return geo;
2178});
2179
2180// IBeamArrow with absolutes instead of scaling
2181FigureParameter.setFigureParameter('IBeamArrow2', 0, new FigureParameter('ConnectorHeight', 40));
2182FigureParameter.setFigureParameter('IBeamArrow2', 1, new FigureParameter('BeamArrowHeight', 100));
2183go.Shape.defineFigureGenerator('IBeamArrow2', (shape, w, h) => {
2184 let param1 = shape ? shape.parameter1 : NaN; // height of midsection
2185 if (isNaN(param1)) param1 = 40;
2186 let param2 = shape ? shape.parameter2 : NaN; // height of beam and arrow
2187 if (isNaN(param2)) param2 = 100;
2188
2189 let y1 = (h - param1) / 2;
2190 let y2 = y1 + param1;
2191 let y1outer = (h - param2) / 2;
2192 let y2outer = y1outer + param2;
2193 if (param1 > h || param2 > h) {
2194 if (param2 > param1) {
2195 param1 = param1 * h / param2; // use similar ratio
2196 y1 = (h - param1) / 2;
2197 y2 = y1 + param1;
2198 y1outer = 0;
2199 y2outer = h;
2200 } else {
2201 y1 = 0;
2202 y2 = h;
2203 y1outer = 0;
2204 y2outer = h;
2205 }
2206 }
2207 const geo = new go.Geometry();
2208 const fig = new go.PathFigure(w, .5 * h, true);
2209 geo.add(fig);
2210 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2outer));
2211 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2));
2212 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, y2));
2213 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, y2outer));
2214 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y2outer));
2215 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y1outer));
2216 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, y1outer));
2217 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, y1));
2218 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1));
2219 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1outer).close());
2220 geo.spot1 = new go.Spot(0, y1 / h);
2221 const temp = getIntersection(.7, y2outer / h,
2222 1, .5,
2223 0, y2 / h,
2224 1, y2 / h,
2225 tempPoint());
2226 geo.spot2 = new go.Spot(temp.x, temp.y);
2227 freePoint(temp);
2228 return geo;
2229});
2230
2231FigureParameter.setFigureParameter('Pointer', 0, new FigureParameter('BackPoint', .1, 0, .2));
2232go.Shape.defineFigureGenerator('Pointer', (shape, w, h) => {
2233 let param1 = shape ? shape.parameter1 : NaN; // how much the back of the pointer comes in
2234 if (isNaN(param1)) param1 = .1;
2235
2236 const geo = new go.Geometry();
2237 const fig = new go.PathFigure(w, .5 * h, true);
2238 geo.add(fig);
2239 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2240 fig.add(new go.PathSegment(go.PathSegment.Line, param1 * w, .5 * h));
2241 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0).close());
2242 geo.spot1 = new go.Spot(param1, .35);
2243 const temp = getIntersection(0, .65, 1, .65, 0, 1, 1, .5, tempPoint()); // ?? constant
2244 geo.spot2 = new go.Spot(temp.x, temp.y);
2245 freePoint(temp);
2246 return geo;
2247});
2248
2249FigureParameter.setFigureParameter('RoundedPointer', 0, new FigureParameter('RoundedEdged', .3, 0, .5));
2250go.Shape.defineFigureGenerator('RoundedPointer', (shape, w, h) => {
2251 let param1 = shape ? shape.parameter1 : NaN; // how much the curved back of the pointer comes in
2252 if (isNaN(param1)) param1 = .3;
2253
2254 const geo = new go.Geometry();
2255 const fig = new go.PathFigure(w, .5 * h, true);
2256 geo.add(fig);
2257 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2258 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0, param1 * w, .75 * h,
2259 param1 * w, .25 * h).close());
2260 geo.spot1 = new go.Spot(param1, .35);
2261 const temp = getIntersection(0, .65, 1, .65, 0, 1, 1, .5, tempPoint()); // ?? constant
2262 geo.spot2 = new go.Spot(temp.x, temp.y);
2263 freePoint(temp);
2264 return geo;
2265});
2266
2267FigureParameter.setFigureParameter('SplitEndArrow', 0, new FigureParameter('TailHeight', 0.4, 0.01, .99));
2268go.Shape.defineFigureGenerator('SplitEndArrow', (shape, w, h) => {
2269 let param1 = shape ? shape.parameter1 : NaN; // % height of arrow tail
2270 if (isNaN(param1)) param1 = .4;
2271
2272 const y1 = (.5 - param1 / 2) * h;
2273 const y2 = (.5 + param1 / 2) * h;
2274
2275 const geo = new go.Geometry();
2276 const fig = new go.PathFigure(w, .5 * h, true);
2277 geo.add(fig);
2278 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, h));
2279 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2));
2280 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y2));
2281 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .5 * h));
2282 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y1));
2283 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1));
2284 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, 0).close());
2285 geo.spot1 = new go.Spot(.2, y1 / h);
2286 const temp = getIntersection(.7, 1,
2287 1, .5,
2288 0, y2 / h,
2289 1, y2 / h,
2290 tempPoint());
2291 geo.spot2 = new go.Spot(temp.x, temp.y);
2292 freePoint(temp);
2293 return geo;
2294});
2295
2296// SplitEndArrow with absolutes instead of scaling
2297FigureParameter.setFigureParameter('SplitEndArrow2', 0, new FigureParameter('TailHeight', 40));
2298go.Shape.defineFigureGenerator('SplitEndArrow2', (shape, w, h) => {
2299 let param1 = shape ? shape.parameter1 : NaN; // height of arrow tail
2300 if (isNaN(param1)) param1 = 50;
2301
2302 let y1 = (h - param1) / 2;
2303 let y2 = y1 + param1;
2304 if (param1 > h) {
2305 y1 = 0;
2306 y2 = h;
2307 }
2308 const geo = new go.Geometry();
2309 const fig = new go.PathFigure(w, .5 * h, true);
2310 geo.add(fig);
2311 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, h));
2312 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y2));
2313 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y2));
2314 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .5 * h));
2315 fig.add(new go.PathSegment(go.PathSegment.Line, 0, y1));
2316 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, y1));
2317 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, 0).close());
2318 geo.spot1 = new go.Spot(.2, y1 / h);
2319 const temp = getIntersection(.7, 1,
2320 1, .5,
2321 0, y2 / h,
2322 1, y2 / h,
2323 tempPoint());
2324 geo.spot2 = new go.Spot(temp.x, temp.y);
2325 freePoint(temp);
2326 return geo;
2327});
2328
2329FigureParameter.setFigureParameter('SquareArrow', 0, new FigureParameter('ArrowPoint', .7, .2, .9));
2330go.Shape.defineFigureGenerator('SquareArrow', (shape, w, h) => {
2331 let param1 = shape ? shape.parameter1 : NaN; // pointiness of arrow, lower is more pointy
2332 if (isNaN(param1)) param1 = .7;
2333
2334 const geo = new go.Geometry();
2335 const fig = new go.PathFigure(w, .5 * h, true);
2336 geo.add(fig);
2337 fig.add(new go.PathSegment(go.PathSegment.Line, param1 * w, h));
2338 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2339 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
2340 fig.add(new go.PathSegment(go.PathSegment.Line, param1 * w, 0).close());
2341 geo.spot1 = go.Spot.TopLeft;
2342 geo.spot2 = new go.Spot(param1, 1);
2343 return geo;
2344});
2345
2346go.Shape.defineFigureGenerator('Cone1', (shape, w, h) => {
2347 const geo = new go.Geometry();
2348 const cpxOffset = KAPPA * .5;
2349 const cpyOffset = KAPPA * .1;
2350 const fig = new go.PathFigure(0, .9 * h, true);
2351 geo.add(fig);
2352
2353 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
2354 fig.add(new go.PathSegment(go.PathSegment.Line, w, .9 * h));
2355 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h, w, (.9 + cpyOffset) * h,
2356 (.5 + cpxOffset) * w, h));
2357 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .9 * h, (.5 - cpxOffset) * w, h,
2358 0, (.9 + cpyOffset) * h).close());
2359 geo.spot1 = new go.Spot(.25, .5);
2360 geo.spot2 = new go.Spot(.75, .97);
2361 return geo;
2362});
2363
2364go.Shape.defineFigureGenerator('Cone2', (shape, w, h) => {
2365 const geo = new go.Geometry();
2366 const fig = new go.PathFigure(0, .9 * h, true);
2367 geo.add(fig);
2368
2369 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .9 * h, (1 - .85 / .9) * w, h,
2370 (.85 / .9) * w, h));
2371 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
2372 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .9 * h).close());
2373 const fig2 = new go.PathFigure(0, .9 * h, false);
2374 geo.add(fig2);
2375 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w, .9 * h, (1 - .85 / .9) * w, .8 * h,
2376 (.85 / .9) * w, .8 * h));
2377 geo.spot1 = new go.Spot(.25, .5);
2378 geo.spot2 = new go.Spot(.75, .82);
2379 return geo;
2380});
2381
2382go.Shape.defineFigureGenerator('Cube1', (shape, w, h) => {
2383 const geo = new go.Geometry();
2384 const fig = new go.PathFigure(.5 * w, h, true);
2385 geo.add(fig);
2386
2387 fig.add(new go.PathSegment(go.PathSegment.Line, w, .85 * h));
2388 fig.add(new go.PathSegment(go.PathSegment.Line, w, .15 * h));
2389 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
2390 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .15 * h));
2391 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .85 * h).close());
2392 const fig2 = new go.PathFigure(.5 * w, h, false);
2393 geo.add(fig2);
2394 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .3 * h));
2395 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, .15 * h));
2396 fig2.add(new go.PathSegment(go.PathSegment.Move, .5 * w, .3 * h));
2397 fig2.add(new go.PathSegment(go.PathSegment.Line, w, .15 * h));
2398 geo.spot1 = new go.Spot(0, .3);
2399 geo.spot2 = new go.Spot(.5, .85);
2400 return geo;
2401});
2402
2403go.Shape.defineFigureGenerator('Cube2', (shape, w, h) => {
2404 const geo = new go.Geometry();
2405 const fig = new go.PathFigure(0, .3 * h, true);
2406 geo.add(fig);
2407
2408 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2409 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, h));
2410 fig.add(new go.PathSegment(go.PathSegment.Line, w, .7 * h));
2411 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2412 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 0).close());
2413 const fig2 = new go.PathFigure(0, .3 * h, false);
2414 geo.add(fig2);
2415 fig2.add(new go.PathSegment(go.PathSegment.Line, .7 * w, .3 * h));
2416 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2417 fig2.add(new go.PathSegment(go.PathSegment.Move, .7 * w, .3 * h));
2418 fig2.add(new go.PathSegment(go.PathSegment.Line, .7 * w, h));
2419 geo.spot1 = new go.Spot(0, .3);
2420 geo.spot2 = new go.Spot(.7, 1);
2421 return geo;
2422});
2423
2424go.Shape.defineFigureGenerator('Cylinder1', function(shape, w, h) {
2425 let param1 = shape ? shape.parameter1 : NaN; // half the height of the ellipse
2426 if (isNaN(param1)) param1 = 5; // default value
2427 param1 = Math.min(param1, h / 3);
2428
2429 const geo = new go.Geometry();
2430 const cpxOffset = KAPPA * .5;
2431 const fig = new go.PathFigure(0, param1, true);
2432 geo.add(fig);
2433 // The base (top)
2434 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, 0, 0, KAPPA * param1,
2435 (.5 - cpxOffset) * w, 0));
2436 fig.add(new go.PathSegment(go.PathSegment.Bezier, 1.0 * w, param1, (.5 + cpxOffset) * w, 0,
2437 1.0 * w, KAPPA * param1));
2438 fig.add(new go.PathSegment(go.PathSegment.Line, w, h - param1));
2439 // Bottom curve
2440 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, 1.0 * h, 1.0 * w, h - KAPPA * param1,
2441 (.5 + cpxOffset) * w, 1.0 * h));
2442 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h - param1, (.5 - cpxOffset) * w, 1.0 * h,
2443 0, h - KAPPA * param1));
2444 fig.add(new go.PathSegment(go.PathSegment.Line, 0, param1));
2445
2446 const fig2 = new go.PathFigure(w, param1, false);
2447 geo.add(fig2);
2448 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, 2 * param1, 1.0 * w, 2 * param1 - KAPPA * param1,
2449 (.5 + cpxOffset) * w, 2 * param1));
2450 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0, param1, (.5 - cpxOffset) * w, 2 * param1,
2451 0, 2 * param1 - KAPPA * param1));
2452
2453 geo.spot1 = new go.Spot(0, 0, 0, 2 * param1);
2454 geo.spot2 = new go.Spot(1, 1);
2455 return geo;
2456});
2457
2458go.Shape.defineFigureGenerator('Cylinder2', function(shape, w, h) {
2459 let param1 = shape ? shape.parameter1 : NaN; // half the height of the ellipse
2460 if (isNaN(param1)) param1 = 5; // default value
2461 param1 = Math.min(param1, h / 3);
2462
2463 const geo = new go.Geometry();
2464 const cpxOffset = KAPPA * .5;
2465 const fig = new go.PathFigure(0, h - param1, true);
2466 geo.add(fig);
2467 // The body, starting and ending bottom left
2468 fig.add(new go.PathSegment(go.PathSegment.Line, 0, param1));
2469 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, 0, 0, KAPPA * param1,
2470 (.5 - cpxOffset) * w, 0));
2471 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, param1, (.5 + cpxOffset) * w, 0,
2472 w, KAPPA * param1));
2473 fig.add(new go.PathSegment(go.PathSegment.Line, w, h - param1));
2474 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h, w, h - KAPPA * param1,
2475 (.5 + cpxOffset) * w, h));
2476 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h - param1, (.5 - cpxOffset) * w, h,
2477 0, h - KAPPA * param1));
2478
2479 const fig2 = new go.PathFigure(0, h - param1, false);
2480 geo.add(fig2);
2481 // The base (bottom)
2482 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h - 2 * param1, 0, h - param1 - KAPPA * param1,
2483 (.5 - cpxOffset) * w, h - 2 * param1));
2484 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w, h - param1, (.5 + cpxOffset) * w, h - 2 * param1,
2485 w, h - param1 - KAPPA * param1));
2486
2487 geo.spot1 = new go.Spot(0, 0);
2488 geo.spot2 = new go.Spot(1, 1, 0, -2 * param1);
2489 return geo;
2490});
2491
2492go.Shape.defineFigureGenerator('Cylinder3', function(shape, w, h) {
2493 let param1 = shape ? shape.parameter1 : NaN; // half the width of the ellipse
2494 if (isNaN(param1)) param1 = 5; // default value
2495 param1 = Math.min(param1, w / 3);
2496
2497 const geo = new go.Geometry();
2498 const cpyOffset = KAPPA * .5;
2499 const fig = new go.PathFigure(param1, 0, true);
2500 geo.add(fig);
2501 // The body, starting and ending top left
2502 fig.add(new go.PathSegment(go.PathSegment.Line, w - param1, 0));
2503 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, w - KAPPA * param1, 0,
2504 w, (.5 - cpyOffset) * h));
2505 fig.add(new go.PathSegment(go.PathSegment.Bezier, w - param1, h, w, (.5 + cpyOffset) * h,
2506 w - KAPPA * param1, h));
2507 fig.add(new go.PathSegment(go.PathSegment.Line, param1, h));
2508 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .5 * h, KAPPA * param1, h,
2509 0, (.5 + cpyOffset) * h));
2510 fig.add(new go.PathSegment(go.PathSegment.Bezier, param1, 0, 0, (.5 - cpyOffset) * h,
2511 KAPPA * param1, 0));
2512
2513 const fig2 = new go.PathFigure(param1, 0, false);
2514 geo.add(fig2);
2515 // Cylinder line (left)
2516 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 2 * param1, .5 * h, param1 + KAPPA * param1, 0,
2517 2 * param1, (.5 - cpyOffset) * h));
2518 fig2.add(new go.PathSegment(go.PathSegment.Bezier, param1, h, 2 * param1, (.5 + cpyOffset) * h,
2519 param1 + KAPPA * param1, h));
2520
2521 geo.spot1 = new go.Spot(0, 0, 2 * param1, 0);
2522 geo.spot2 = new go.Spot(1, 1);
2523 return geo;
2524});
2525
2526go.Shape.defineFigureGenerator('Cylinder4', function(shape, w, h) {
2527 let param1 = shape ? shape.parameter1 : NaN; // half the width of the ellipse
2528 if (isNaN(param1)) param1 = 5; // default value
2529 param1 = Math.min(param1, w / 3);
2530
2531 const geo = new go.Geometry();
2532 const cpyOffset = KAPPA * .5;
2533 const fig = new go.PathFigure(w - param1, 0, true);
2534 geo.add(fig);
2535 // The body, starting and ending top right
2536 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, w - KAPPA * param1, 0,
2537 w, (.5 - cpyOffset) * h));
2538 fig.add(new go.PathSegment(go.PathSegment.Bezier, w - param1, h, w, (.5 + cpyOffset) * h,
2539 w - KAPPA * param1, h));
2540 fig.add(new go.PathSegment(go.PathSegment.Line, param1, h));
2541 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .5 * h, KAPPA * param1, h,
2542 0, (.5 + cpyOffset) * h));
2543 fig.add(new go.PathSegment(go.PathSegment.Bezier, param1, 0, 0, (.5 - cpyOffset) * h,
2544 KAPPA * param1, 0));
2545 fig.add(new go.PathSegment(go.PathSegment.Line, w - param1, 0));
2546
2547 const fig2 = new go.PathFigure(w - param1, 0, false);
2548 geo.add(fig2);
2549 // Cylinder line (right)
2550 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w - 2 * param1, .5 * h, w - param1 - KAPPA * param1, 0,
2551 w - 2 * param1, (.5 - cpyOffset) * h));
2552 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w - param1, h, w - 2 * param1, (.5 + cpyOffset) * h,
2553 w - param1 - KAPPA * param1, h));
2554
2555 geo.spot1 = new go.Spot(0, 0);
2556 geo.spot2 = new go.Spot(1, 1, -2 * param1, 0);
2557 return geo;
2558});
2559
2560go.Shape.defineFigureGenerator('Prism1', (shape, w, h) => {
2561 const geo = new go.Geometry();
2562 const fig = new go.PathFigure(.25 * w, .25 * h, true);
2563 geo.add(fig);
2564
2565 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
2566 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
2567 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2568 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
2569 const fig2 = new go.PathFigure(.25 * w, .25 * h, false);
2570 geo.add(fig2);
2571 // Inner prism line
2572 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2573 geo.spot1 = new go.Spot(.408, .172);
2574 geo.spot2 = new go.Spot(.833, .662);
2575 return geo;
2576});
2577
2578go.Shape.defineFigureGenerator('Prism2', (shape, w, h) => {
2579 const geo = new go.Geometry();
2580 const fig = new go.PathFigure(0, .25 * h, true);
2581 geo.add(fig);
2582
2583 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
2584 fig.add(new go.PathSegment(go.PathSegment.Line, w, .25 * h));
2585 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, .75 * h));
2586 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
2587 const fig2 = new go.PathFigure(0, h, false);
2588 geo.add(fig2);
2589 // Inner prism lines
2590 fig2.add(new go.PathSegment(go.PathSegment.Line, .25 * w, .5 * h));
2591 fig2.add(new go.PathSegment(go.PathSegment.Line, w, .25 * h));
2592 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, .25 * h));
2593 fig2.add(new go.PathSegment(go.PathSegment.Line, .25 * w, .5 * h));
2594 geo.spot1 = new go.Spot(.25, .5);
2595 geo.spot2 = new go.Spot(.75, .75);
2596 return geo;
2597});
2598
2599go.Shape.defineFigureGenerator('Pyramid1', (shape, w, h) => {
2600 const geo = new go.Geometry();
2601 const fig = new go.PathFigure(.5 * w, 0, true);
2602 geo.add(fig);
2603
2604 fig.add(new go.PathSegment(go.PathSegment.Line, w, .75 * h));
2605 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2606 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .75 * h).close());
2607 const fig2 = new go.PathFigure(.5 * w, 0, false);
2608 geo.add(fig2);
2609 // Inner pyramind line
2610 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2611 geo.spot1 = new go.Spot(.25, .367);
2612 geo.spot2 = new go.Spot(.75, .875);
2613 return geo;
2614});
2615
2616go.Shape.defineFigureGenerator('Pyramid2', (shape, w, h) => {
2617 const geo = new go.Geometry();
2618 const fig = new go.PathFigure(.5 * w, 0, true);
2619 geo.add(fig);
2620
2621 fig.add(new go.PathSegment(go.PathSegment.Line, w, .85 * h));
2622 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2623 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .85 * h).close());
2624 const fig2 = new go.PathFigure(.5 * w, 0, false);
2625 geo.add(fig2);
2626 // Inner pyramid lines
2627 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .7 * h));
2628 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, .85 * h));
2629 fig2.add(new go.PathSegment(go.PathSegment.Move, .5 * w, .7 * h));
2630 fig2.add(new go.PathSegment(go.PathSegment.Line, w, .85 * h));
2631 geo.spot1 = new go.Spot(.25, .367);
2632 geo.spot2 = new go.Spot(.75, .875);
2633 return geo;
2634});
2635
2636go.Shape.defineFigureGenerator('Actor', (shape, w, h) => {
2637 const geo = new go.Geometry();
2638 const radiusw = .2;
2639 const radiush = .1;
2640 const offsetw = KAPPA * radiusw;
2641 const offseth = KAPPA * radiush;
2642 let centerx = .5;
2643 let centery = .1;
2644 const fig = new go.PathFigure(centerx * w, (centery + radiush) * h, true);
2645 geo.add(fig);
2646
2647 // Head
2648 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radiusw) * w, centery * h, (centerx - offsetw) * w, (centery + radiush) * h,
2649 (centerx - radiusw) * w, (centery + offseth) * h));
2650 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radiush) * h, (centerx - radiusw) * w, (centery - offseth) * h,
2651 (centerx - offsetw) * w, (centery - radiush) * h));
2652 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radiusw) * w, centery * h, (centerx + offsetw) * w, (centery - radiush) * h,
2653 (centerx + radiusw) * w, (centery - offseth) * h));
2654 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radiush) * h, (centerx + radiusw) * w, (centery + offseth) * h,
2655 (centerx + offsetw) * w, (centery + radiush) * h));
2656 let r = .05;
2657 let cpOffset = KAPPA * r;
2658 centerx = .05;
2659 centery = .25;
2660 const fig2 = new go.PathFigure(.5 * w, .2 * h, true);
2661 geo.add(fig2);
2662 // Body
2663 fig2.add(new go.PathSegment(go.PathSegment.Line, .95 * w, .2 * h));
2664 centerx = .95;
2665 centery = .25;
2666 // Right arm
2667 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + r) * w, centery * h, (centerx + cpOffset) * w, (centery - r) * h,
2668 (centerx + r) * w, (centery - cpOffset) * h));
2669 fig2.add(new go.PathSegment(go.PathSegment.Line, w, .6 * h));
2670 fig2.add(new go.PathSegment(go.PathSegment.Line, .85 * w, .6 * h));
2671 fig2.add(new go.PathSegment(go.PathSegment.Line, .85 * w, .35 * h));
2672 r = .025;
2673 cpOffset = KAPPA * r;
2674 centerx = .825;
2675 centery = .35;
2676 // Right under arm
2677 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - r) * h, (centerx + r) * w, (centery - cpOffset) * h,
2678 (centerx + cpOffset) * w, (centery - r) * h));
2679 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - r) * w, centery * h, (centerx - cpOffset) * w, (centery - r) * h,
2680 (centerx - r) * w, (centery - cpOffset) * h));
2681 // Right side/leg
2682 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, h));
2683 fig2.add(new go.PathSegment(go.PathSegment.Line, .55 * w, h));
2684 fig2.add(new go.PathSegment(go.PathSegment.Line, .55 * w, .7 * h));
2685 // Right in between
2686 r = .05;
2687 cpOffset = KAPPA * r;
2688 centerx = .5;
2689 centery = .7;
2690 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - r) * h, (centerx + r) * w, (centery - cpOffset) * h,
2691 (centerx + cpOffset) * w, (centery - r) * h));
2692 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - r) * w, centery * h, (centerx - cpOffset) * w, (centery - r) * h,
2693 (centerx - r) * w, (centery - cpOffset) * h));
2694 // Left side/leg
2695 fig2.add(new go.PathSegment(go.PathSegment.Line, .45 * w, h));
2696 fig2.add(new go.PathSegment(go.PathSegment.Line, .2 * w, h));
2697 fig2.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .35 * h));
2698 r = .025;
2699 cpOffset = KAPPA * r;
2700 centerx = .175;
2701 centery = .35;
2702 // Left under arm
2703 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - r) * h, (centerx + r) * w, (centery - cpOffset) * h,
2704 (centerx + cpOffset) * w, (centery - r) * h));
2705 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - r) * w, centery * h, (centerx - cpOffset) * w, (centery - r) * h,
2706 (centerx - r) * w, (centery - cpOffset) * h));
2707 // Left arm
2708 fig2.add(new go.PathSegment(go.PathSegment.Line, .15 * w, .6 * h));
2709 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, .6 * h));
2710 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, .25 * h));
2711 r = .05;
2712 cpOffset = KAPPA * r;
2713 centerx = .05;
2714 centery = .25;
2715 // Left shoulder
2716 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - r) * h, (centerx - r) * w, (centery - cpOffset) * h,
2717 (centerx - cpOffset) * w, (centery - r) * h));
2718 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .2 * h));
2719 geo.spot1 = new go.Spot(.2, .2);
2720 geo.spot2 = new go.Spot(.8, .65);
2721 return geo;
2722});
2723
2724FigureParameter.setFigureParameter('Card', 0, new FigureParameter('CornerCutoutSize', .2, .1, .9));
2725go.Shape.defineFigureGenerator('Card', (shape, w, h) => {
2726 let param1 = shape ? shape.parameter1 : NaN; // size of corner cutout
2727 if (isNaN(param1)) param1 = .2;
2728
2729 const geo = new go.Geometry();
2730 const fig = new go.PathFigure(w, 0, true);
2731 geo.add(fig);
2732 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
2733 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2734 fig.add(new go.PathSegment(go.PathSegment.Line, 0, param1 * h));
2735 fig.add(new go.PathSegment(go.PathSegment.Line, param1 * w, 0).close());
2736 geo.spot1 = new go.Spot(0, param1);
2737 geo.spot2 = go.Spot.BottomRight;
2738 return geo;
2739});
2740
2741go.Shape.defineFigureGenerator('Collate', (shape, w, h) => {
2742 const geo = new go.Geometry();
2743 const fig = new go.PathFigure(.5 * w, .5 * h, true);
2744 geo.add(fig);
2745
2746 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
2747 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2748 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h));
2749 const fig2 = new go.PathFigure(.5 * w, .5 * h, true);
2750 geo.add(fig2);
2751 fig2.add(new go.PathSegment(go.PathSegment.Line, w, h));
2752 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2753 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h));
2754 geo.spot1 = new go.Spot(.25, 0);
2755 geo.spot2 = new go.Spot(.75, .25);
2756 return geo;
2757});
2758
2759go.Shape.defineFigureGenerator('CreateRequest', (shape, w, h) => {
2760 const geo = new go.Geometry();
2761 let param1 = shape ? shape.parameter1 : NaN;
2762 if (isNaN(param1)) param1 = .1;
2763 const fig = new go.PathFigure(0, 0, true);
2764 geo.add(fig);
2765
2766 // Body
2767 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2768 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
2769 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
2770 const fig2 = new go.PathFigure(0, param1 * h, false);
2771 geo.add(fig2);
2772 // Inside lines
2773 fig2.add(new go.PathSegment(go.PathSegment.Line, w, param1 * h));
2774 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, (1 - param1) * h));
2775 fig2.add(new go.PathSegment(go.PathSegment.Line, w, (1 - param1) * h));
2776 // ??? geo.spot1 = new go.Spot(0, param1);
2777 // ??? geo.spot2 = new go.Spot(1, 1 - param1);
2778 return geo;
2779});
2780
2781go.Shape.defineFigureGenerator('Database', (shape, w, h) => {
2782 const geo = new go.Geometry();
2783 const cpxOffset = KAPPA * .5;
2784 const cpyOffset = KAPPA * .1;
2785 const fig = new go.PathFigure(w, .1 * h, true);
2786 geo.add(fig);
2787
2788 // Body
2789 fig.add(new go.PathSegment(go.PathSegment.Line, w, .9 * h));
2790 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h, w, (.9 + cpyOffset) * h,
2791 (.5 + cpxOffset) * w, h));
2792 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .9 * h, (.5 - cpxOffset) * w, h,
2793 0, (.9 + cpyOffset) * h));
2794 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .1 * h));
2795 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, 0, 0, (.1 - cpyOffset) * h,
2796 (.5 - cpxOffset) * w, 0));
2797 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .1 * h, (.5 + cpxOffset) * w, 0,
2798 w, (.1 - cpyOffset) * h));
2799 const fig2 = new go.PathFigure(w, .1 * h, false);
2800 geo.add(fig2);
2801 // Rings
2802 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .2 * h, w, (.1 + cpyOffset) * h,
2803 (.5 + cpxOffset) * w, .2 * h));
2804 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0, .1 * h, (.5 - cpxOffset) * w, .2 * h,
2805 0, (.1 + cpyOffset) * h));
2806 fig2.add(new go.PathSegment(go.PathSegment.Move, w, .2 * h));
2807 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .3 * h, w, (.2 + cpyOffset) * h,
2808 (.5 + cpxOffset) * w, .3 * h));
2809 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0, .2 * h, (.5 - cpxOffset) * w, .3 * h,
2810 0, (.2 + cpyOffset) * h));
2811 fig2.add(new go.PathSegment(go.PathSegment.Move, w, .3 * h));
2812 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .4 * h, w, (.3 + cpyOffset) * h,
2813 (.5 + cpxOffset) * w, .4 * h));
2814 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0, .3 * h, (.5 - cpxOffset) * w, .4 * h,
2815 0, (.3 + cpyOffset) * h));
2816 geo.spot1 = new go.Spot(0, .4);
2817 geo.spot2 = new go.Spot(1, .9);
2818 return geo;
2819});
2820
2821go.Shape.defineFigureGenerator('DataStorage', (shape, w, h) => {
2822 const geo = new go.Geometry();
2823 const fig = new go.PathFigure(0, 0, true);
2824 geo.add(fig);
2825
2826 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
2827 fig.add(new go.PathSegment(go.PathSegment.Bezier, .75 * w, h, w, 0, w, h));
2828 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
2829 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0, .25 * w, .9 * h, .25 * w, .1 * h).close());
2830 geo.spot1 = new go.Spot(.226, 0);
2831 geo.spot2 = new go.Spot(.81, 1);
2832 return geo;
2833});
2834
2835go.Shape.defineFigureGenerator('DiskStorage', (shape, w, h) => {
2836 const geo = new go.Geometry();
2837 const cpxOffset = KAPPA * .5;
2838 const cpyOffset = KAPPA * .1;
2839 const fig = new go.PathFigure(w, .1 * h, true);
2840 geo.add(fig);
2841
2842 // Body
2843 fig.add(new go.PathSegment(go.PathSegment.Line, w, .9 * h));
2844 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h, w, (.9 + cpyOffset) * h,
2845 (.5 + cpxOffset) * w, h));
2846 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .9 * h, (.5 - cpxOffset) * w, h,
2847 0, (.9 + cpyOffset) * h));
2848 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .1 * h));
2849 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, 0, 0, (.1 - cpyOffset) * h,
2850 (.5 - cpxOffset) * w, 0));
2851 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .1 * h, (.5 + cpxOffset) * w, 0,
2852 w, (.1 - cpyOffset) * h));
2853 const fig2 = new go.PathFigure(w, .1 * h, false);
2854 geo.add(fig2);
2855 // Rings
2856 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .2 * h, w, (.1 + cpyOffset) * h,
2857 (.5 + cpxOffset) * w, .2 * h));
2858 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0, .1 * h, (.5 - cpxOffset) * w, .2 * h,
2859 0, (.1 + cpyOffset) * h));
2860 fig2.add(new go.PathSegment(go.PathSegment.Move, w, .2 * h));
2861 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .3 * h, w, (.2 + cpyOffset) * h,
2862 (.5 + cpxOffset) * w, .3 * h));
2863 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0, .2 * h, (.5 - cpxOffset) * w, .3 * h,
2864 0, (.2 + cpyOffset) * h));
2865 geo.spot1 = new go.Spot(0, .3);
2866 geo.spot2 = new go.Spot(1, .9);
2867 return geo;
2868});
2869
2870go.Shape.defineFigureGenerator('Display', (shape, w, h) => {
2871 const geo = new go.Geometry();
2872 const fig = new go.PathFigure(.25 * w, 0, true);
2873 geo.add(fig);
2874
2875 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
2876 fig.add(new go.PathSegment(go.PathSegment.Bezier, .75 * w, h, w, 0, w, h));
2877 fig.add(new go.PathSegment(go.PathSegment.Line, .25 * w, h));
2878 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h).close());
2879 geo.spot1 = new go.Spot(.25, 0);
2880 geo.spot2 = new go.Spot(.75, 1);
2881 return geo;
2882});
2883
2884go.Shape.defineFigureGenerator('DividedEvent', (shape, w, h) => {
2885 const geo = new go.Geometry();
2886 let param1 = shape ? shape.parameter1 : NaN;
2887 if (isNaN(param1)) param1 = .2;
2888 else if (param1 < .15) param1 = .15; // Minimum
2889 const cpOffset = KAPPA * .2;
2890 const fig = new go.PathFigure(0, .2 * h, true);
2891 geo.add(fig);
2892
2893 fig.add(new go.PathSegment(go.PathSegment.Bezier, .2 * w, 0, 0, (.2 - cpOffset) * h,
2894 (.2 - cpOffset) * w, 0));
2895 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, 0));
2896 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .2 * h, (.8 + cpOffset) * w, 0,
2897 w, (.2 - cpOffset) * h));
2898 fig.add(new go.PathSegment(go.PathSegment.Line, w, .8 * h));
2899 fig.add(new go.PathSegment(go.PathSegment.Bezier, .8 * w, h, w, (.8 + cpOffset) * h,
2900 (.8 + cpOffset) * w, h));
2901 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, h));
2902 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .8 * h, (.2 - cpOffset) * w, h,
2903 0, (.8 + cpOffset) * h));
2904 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .2 * h));
2905 const fig2 = new go.PathFigure(0, param1 * h, false);
2906 geo.add(fig2);
2907 fig2.add(new go.PathSegment(go.PathSegment.Line, w, param1 * h));
2908 // ??? geo.spot1 = new go.Spot(0, param1);
2909 // ??? geo.spot2 = new go.Spot(1, 1 - param1);
2910 return geo;
2911});
2912
2913go.Shape.defineFigureGenerator('DividedProcess', (shape, w, h) => {
2914 const geo = new go.Geometry();
2915 let param1 = shape ? shape.parameter1 : NaN;
2916 if (isNaN(param1) || param1 < .1) param1 = .1; // Minimum
2917 const fig = new go.PathFigure(0, 0, true);
2918 geo.add(fig);
2919
2920 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2921 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
2922 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
2923 const fig2 = new go.PathFigure(0, param1 * h, false);
2924 geo.add(fig2);
2925 fig2.add(new go.PathSegment(go.PathSegment.Line, w, param1 * h));
2926 // ??? geo.spot1 = new go.Spot(0, param1);
2927 // ??? geo.spot2 = go.Spot.BottomRight;
2928 return geo;
2929});
2930
2931go.Shape.defineFigureGenerator('Document', (shape, w, h) => {
2932 const geo = new go.Geometry();
2933 h = h / .8;
2934 const fig = new go.PathFigure(0, .7 * h, true);
2935 geo.add(fig);
2936
2937 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
2938 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2939 fig.add(new go.PathSegment(go.PathSegment.Line, w, .7 * h));
2940 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .7 * h, .5 * w, .4 * h, .5 * w, h).close());
2941 geo.spot1 = go.Spot.TopLeft;
2942 geo.spot2 = new go.Spot(1, .6);
2943 return geo;
2944});
2945
2946go.Shape.defineFigureGenerator('ExternalOrganization', (shape, w, h) => {
2947 const geo = new go.Geometry();
2948 let param1 = shape ? shape.parameter1 : NaN;
2949 if (isNaN(param1) || param1 < .2) param1 = .2; // Minimum
2950 const fig = new go.PathFigure(0, 0, true);
2951 geo.add(fig);
2952
2953 // Body
2954 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
2955 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
2956 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
2957 const fig2 = new go.PathFigure(param1 * w, 0, false);
2958 geo.add(fig2);
2959 // Top left triangle
2960 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, param1 * h));
2961 // Top right triangle
2962 fig2.add(new go.PathSegment(go.PathSegment.Move, w, param1 * h));
2963 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - param1) * w, 0));
2964 // Bottom left triangle
2965 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, (1 - param1) * h));
2966 fig2.add(new go.PathSegment(go.PathSegment.Line, param1 * w, h));
2967 // Bottom right triangle
2968 fig2.add(new go.PathSegment(go.PathSegment.Move, (1 - param1) * w, h));
2969 fig2.add(new go.PathSegment(go.PathSegment.Line, w, (1 - param1) * h));
2970 // ??? geo.spot1 = new go.Spot(param1 / 2, param1 / 2);
2971 // ??? geo.spot2 = new go.Spot(1 - param1 / 2, 1 - param1 / 2);
2972 return geo;
2973});
2974
2975go.Shape.defineFigureGenerator('ExternalProcess', (shape, w, h) => {
2976 const geo = new go.Geometry();
2977 const fig = new go.PathFigure(.5 * w, 0, true);
2978 geo.add(fig);
2979
2980 // Body
2981 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
2982 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
2983 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h).close());
2984 const fig2 = new go.PathFigure(.1 * w, .4 * h, false);
2985 geo.add(fig2);
2986 // Top left triangle
2987 fig2.add(new go.PathSegment(go.PathSegment.Line, .1 * w, .6 * h));
2988 // Top right triangle
2989 fig2.add(new go.PathSegment(go.PathSegment.Move, .9 * w, .6 * h));
2990 fig2.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .4 * h));
2991 // Bottom left triangle
2992 fig2.add(new go.PathSegment(go.PathSegment.Move, .6 * w, .1 * h));
2993 fig2.add(new go.PathSegment(go.PathSegment.Line, .4 * w, .1 * h));
2994 // Bottom right triangle
2995 fig2.add(new go.PathSegment(go.PathSegment.Move, .4 * w, .9 * h));
2996 fig2.add(new go.PathSegment(go.PathSegment.Line, .6 * w, .9 * h));
2997 geo.spot1 = new go.Spot(.25, .25);
2998 geo.spot2 = new go.Spot(.75, .75);
2999 return geo;
3000});
3001
3002go.Shape.defineFigureGenerator('File', (shape, w, h) => {
3003 const geo = new go.Geometry();
3004 const fig = new go.PathFigure(0, 0, true); // starting point
3005 geo.add(fig);
3006 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
3007 fig.add(new go.PathSegment(go.PathSegment.Line, w, .25 * h));
3008 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3009 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3010 const fig2 = new go.PathFigure(.75 * w, 0, false);
3011 geo.add(fig2);
3012 // The Fold
3013 fig2.add(new go.PathSegment(go.PathSegment.Line, .75 * w, .25 * h));
3014 fig2.add(new go.PathSegment(go.PathSegment.Line, w, .25 * h));
3015 geo.spot1 = new go.Spot(0, .25);
3016 geo.spot2 = go.Spot.BottomRight;
3017 return geo;
3018});
3019
3020go.Shape.defineFigureGenerator('Interrupt', (shape, w, h) => {
3021 const geo = new go.Geometry();
3022 const fig = new go.PathFigure(w, .5 * h, true);
3023 geo.add(fig);
3024
3025 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3026 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
3027 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3028 const fig2 = new go.PathFigure(w, .5 * h, false);
3029 geo.add(fig2);
3030 fig2.add(new go.PathSegment(go.PathSegment.Line, w, h));
3031 const fig3 = new go.PathFigure(w, .5 * h, false);
3032 geo.add(fig3);
3033 fig3.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3034 geo.spot1 = new go.Spot(0, .25);
3035 geo.spot2 = new go.Spot(.5, .75);
3036 return geo;
3037});
3038
3039go.Shape.defineFigureGenerator('InternalStorage', (shape, w, h) => {
3040 const geo = new go.Geometry();
3041 let param1 = shape ? shape.parameter1 : NaN;
3042 let param2 = shape ? shape.parameter2 : NaN;
3043 if (isNaN(param1)) param1 = .1; // Distance from left
3044 if (isNaN(param2)) param2 = .1; // Distance from top
3045 const fig = new go.PathFigure(0, 0, true);
3046 geo.add(fig);
3047
3048 // The main body
3049 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3050 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3051 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3052 const fig2 = new go.PathFigure(param1 * w, 0, false);
3053 geo.add(fig2);
3054 // Two lines
3055 fig2.add(new go.PathSegment(go.PathSegment.Line, param1 * w, h));
3056 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, param2 * h));
3057 fig2.add(new go.PathSegment(go.PathSegment.Line, w, param2 * h));
3058 // ??? geo.spot1 = new go.Spot(param1, param2);
3059 // ??? geo.spot2 = go.Spot.BottomRight;
3060 return geo;
3061});
3062
3063go.Shape.defineFigureGenerator('Junction', (shape, w, h) => {
3064 const geo = new go.Geometry();
3065 const dist = (1 / Math.SQRT2);
3066 const small = ((1 - 1 / Math.SQRT2) / 2);
3067 const cpOffset = KAPPA * .5;
3068 const radius = .5;
3069 const fig = new go.PathFigure(w, radius * h, true);
3070 geo.add(fig);
3071
3072 // Circle
3073 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, h, w, (radius + cpOffset) * h,
3074 (radius + cpOffset) * w, h));
3075 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, radius * h, (radius - cpOffset) * w, h,
3076 0, (radius + cpOffset) * h));
3077 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, 0, 0, (radius - cpOffset) * h,
3078 (radius - cpOffset) * w, 0));
3079 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, radius * h, (radius + cpOffset) * w, 0,
3080 w, (radius - cpOffset) * h));
3081 const fig2 = new go.PathFigure((small + dist) * w, (small + dist) * h, false);
3082 geo.add(fig2);
3083 // X
3084 fig2.add(new go.PathSegment(go.PathSegment.Line, small * w, small * h));
3085 fig2.add(new go.PathSegment(go.PathSegment.Move, small * w, (small + dist) * h));
3086 fig2.add(new go.PathSegment(go.PathSegment.Line, (small + dist) * w, small * h));
3087 return geo;
3088});
3089
3090go.Shape.defineFigureGenerator('LinedDocument', (shape, w, h) => {
3091 const geo = new go.Geometry();
3092 h = h / .8;
3093 const fig = new go.PathFigure(0, .7 * h, true);
3094 geo.add(fig);
3095
3096 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
3097 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3098 fig.add(new go.PathSegment(go.PathSegment.Line, w, .7 * h));
3099 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .7 * h, .5 * w, .4 * h, .5 * w, h).close());
3100 const fig2 = new go.PathFigure(.1 * w, 0, false);
3101 geo.add(fig2);
3102 fig2.add(new go.PathSegment(go.PathSegment.Line, .1 * w, .75 * h));
3103 geo.spot1 = new go.Spot(.1, 0);
3104 geo.spot2 = new go.Spot(1, .6);
3105 return geo;
3106});
3107
3108go.Shape.defineFigureGenerator('LoopLimit', (shape, w, h) => {
3109 const geo = new go.Geometry();
3110 const fig = new go.PathFigure(0, h, true);
3111 geo.add(fig);
3112
3113 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .25 * h));
3114 fig.add(new go.PathSegment(go.PathSegment.Line, .25 * w, 0));
3115 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
3116 fig.add(new go.PathSegment(go.PathSegment.Line, w, .25 * h));
3117 fig.add(new go.PathSegment(go.PathSegment.Line, w, h).close());
3118 geo.spot1 = new go.Spot(0, .25);
3119 geo.spot2 = go.Spot.BottomRight;
3120 return geo;
3121});
3122
3123go.Shape.defineFigureGenerator('MagneticTape', (shape, w, h) => {
3124 const geo = new go.Geometry();
3125 const cpOffset = KAPPA * .5;
3126 const radius = .5;
3127 const fig = new go.PathFigure(.5 * w, h, true);
3128 geo.add(fig);
3129
3130 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, radius * h, (radius - cpOffset) * w, h,
3131 0, (radius + cpOffset) * h));
3132 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, 0, 0, (radius - cpOffset) * h,
3133 (radius - cpOffset) * w, 0));
3134 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, radius * h, (radius + cpOffset) * w, 0,
3135 w, (radius - cpOffset) * h));
3136 fig.add(new go.PathSegment(go.PathSegment.Bezier, (radius + .1) * w, .9 * h, w, (radius + cpOffset) * h,
3137 (radius + cpOffset) * w, .9 * h));
3138 fig.add(new go.PathSegment(go.PathSegment.Line, w, .9 * h));
3139 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3140 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
3141 geo.spot1 = new go.Spot(.15, .15);
3142 geo.spot2 = new go.Spot(.85, .8);
3143 return geo;
3144});
3145
3146go.Shape.defineFigureGenerator('ManualInput', (shape, w, h) => {
3147 const geo = new go.Geometry();
3148 const fig = new go.PathFigure(w, 0, true);
3149 geo.add(fig);
3150
3151 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3152 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3153 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .25 * h).close());
3154 geo.spot1 = new go.Spot(0, .25);
3155 geo.spot2 = go.Spot.BottomRight;
3156 return geo;
3157});
3158
3159go.Shape.defineFigureGenerator('MessageFromUser', (shape, w, h) => {
3160 const geo = new go.Geometry();
3161 let param1 = shape ? shape.parameter1 : NaN;
3162 if (isNaN(param1)) param1 = .7; // How far from the right the point is
3163 const fig = new go.PathFigure(0, 0, true);
3164 geo.add(fig);
3165
3166 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3167 fig.add(new go.PathSegment(go.PathSegment.Line, param1 * w, .5 * h));
3168 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3169 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3170 geo.spot1 = go.Spot.TopLeft;
3171 // ??? geo.spot2 = new go.Spot(param1, 1);
3172 return geo;
3173});
3174
3175go.Shape.defineFigureGenerator('MicroformProcessing', (shape, w, h) => {
3176 const geo = new go.Geometry();
3177 let param1 = shape ? shape.parameter1 : NaN;
3178 if (isNaN(param1)) param1 = .25; // How far from the top/bottom the points are
3179 const fig = new go.PathFigure(0, 0, true);
3180 geo.add(fig);
3181
3182 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, param1 * h));
3183 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3184 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3185 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, (1 - param1) * h));
3186 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3187 // ??? geo.spot1 = new go.Spot(0, param1);
3188 // ??? geo.spot2 = new go.Spot(1, 1 - param1);
3189 return geo;
3190});
3191
3192go.Shape.defineFigureGenerator('MicroformRecording', (shape, w, h) => {
3193 const geo = new go.Geometry();
3194 const fig = new go.PathFigure(0, 0, true);
3195 geo.add(fig);
3196
3197 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, .25 * h));
3198 fig.add(new go.PathSegment(go.PathSegment.Line, w, .15 * h));
3199 fig.add(new go.PathSegment(go.PathSegment.Line, w, .85 * h));
3200 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, .75 * h));
3201 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3202 geo.spot1 = new go.Spot(0, .25);
3203 geo.spot2 = new go.Spot(1, .75);
3204 return geo;
3205});
3206
3207go.Shape.defineFigureGenerator('MultiDocument', (shape, w, h) => {
3208 const geo = new go.Geometry();
3209 h = h / .8;
3210 const fig = new go.PathFigure(w, 0, true);
3211 geo.add(fig);
3212
3213 // Outline
3214 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3215 fig.add(new go.PathSegment(go.PathSegment.Bezier, .9 * w, .44 * h, .96 * w, .47 * h, .93 * w, .45 * h));
3216 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .6 * h));
3217 fig.add(new go.PathSegment(go.PathSegment.Bezier, .8 * w, .54 * h, .86 * w, .57 * h, .83 * w, .55 * h));
3218 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .7 * h));
3219 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .7 * h, .4 * w, .4 * h, .4 * w, h));
3220 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .2 * h));
3221 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, .2 * h));
3222 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, .1 * h));
3223 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .1 * h));
3224 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, 0).close());
3225 const fig2 = new go.PathFigure(.1 * w, .2 * h, false);
3226 geo.add(fig2);
3227 // Inside lines
3228 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .2 * h));
3229 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .54 * h));
3230 fig2.add(new go.PathSegment(go.PathSegment.Move, .2 * w, .1 * h));
3231 fig2.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .1 * h));
3232 fig2.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .44 * h));
3233 geo.spot1 = new go.Spot(0, .25);
3234 geo.spot2 = new go.Spot(.8, .77);
3235 return geo;
3236});
3237
3238go.Shape.defineFigureGenerator('MultiProcess', (shape, w, h) => {
3239 const geo = new go.Geometry();
3240 const fig = new go.PathFigure(.1 * w, .1 * h, true);
3241 geo.add(fig);
3242
3243 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .1 * h));
3244 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, 0));
3245 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3246 fig.add(new go.PathSegment(go.PathSegment.Line, w, .8 * h));
3247 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .8 * h));
3248 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .9 * h));
3249 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .9 * h));
3250 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, h));
3251 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3252 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .2 * h));
3253 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, .2 * h).close());
3254 const fig2 = new go.PathFigure(.2 * w, .1 * h, false);
3255 geo.add(fig2);
3256 fig2.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .1 * h));
3257 fig2.add(new go.PathSegment(go.PathSegment.Line, .9 * w, .8 * h));
3258 fig2.add(new go.PathSegment(go.PathSegment.Move, .1 * w, .2 * h));
3259 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .2 * h));
3260 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .9 * h));
3261 geo.spot1 = new go.Spot(0, .2);
3262 geo.spot2 = new go.Spot(.8, 1);
3263 return geo;
3264});
3265
3266go.Shape.defineFigureGenerator('OfflineStorage', (shape, w, h) => {
3267 const geo = new go.Geometry();
3268 let param1 = shape ? shape.parameter1 : NaN;
3269 if (isNaN(param1)) param1 = .1; // Distance between 2 top lines
3270 const l = 1 - param1; // Length of the top line
3271 const fig = new go.PathFigure(0, 0, true);
3272 geo.add(fig);
3273
3274 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3275 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h).close());
3276 const fig2 = new go.PathFigure(.5 * param1 * w, param1 * h, false);
3277 geo.add(fig2);
3278 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - .5 * param1) * w, param1 * h));
3279 // ??? geo.spot1 = new go.Spot(l / 4 + .5 * param1, param1);
3280 // ??? geo.spot2 = new go.Spot(3 * l / 4 + .5 * param1, param1 + .5 * l);
3281 return geo;
3282});
3283
3284go.Shape.defineFigureGenerator('OffPageConnector', (shape, w, h) => {
3285 const geo = new go.Geometry();
3286 const fig = new go.PathFigure(0, 0, true);
3287 geo.add(fig);
3288
3289 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, 0));
3290 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3291 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, h));
3292 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3293 geo.spot1 = go.Spot.TopLeft;
3294 geo.spot2 = new go.Spot(.75, 1);
3295 return geo;
3296});
3297
3298go.Shape.defineFigureGenerator('Or', (shape, w, h) => {
3299 const geo = new go.Geometry();
3300 const cpOffset = KAPPA * .5;
3301 const radius = .5;
3302 const fig = new go.PathFigure(w, radius * h, true);
3303 geo.add(fig);
3304
3305 // Circle
3306 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, h, w, (radius + cpOffset) * h,
3307 (radius + cpOffset) * w, h));
3308 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, radius * h, (radius - cpOffset) * w, h,
3309 0, (radius + cpOffset) * h));
3310 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, 0, 0, (radius - cpOffset) * h,
3311 (radius - cpOffset) * w, 0));
3312 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, radius * h, (radius + cpOffset) * w, 0,
3313 w, (radius - cpOffset) * h));
3314 const fig2 = new go.PathFigure(w, .5 * h, false);
3315 geo.add(fig2);
3316 // +
3317 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h));
3318 fig2.add(new go.PathSegment(go.PathSegment.Move, .5 * w, h));
3319 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
3320 return geo;
3321});
3322
3323go.Shape.defineFigureGenerator('PaperTape', (shape, w, h) => {
3324 const geo = new go.Geometry();
3325 h = h / .8;
3326 const fig = new go.PathFigure(0, .7 * h, true);
3327 geo.add(fig);
3328
3329 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .3 * h));
3330 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .3 * h, .5 * w, .6 * h,
3331 .5 * w, 0));
3332 fig.add(new go.PathSegment(go.PathSegment.Line, w, .7 * h));
3333 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, .7 * h, .5 * w, .4 * h,
3334 .5 * w, h).close());
3335 geo.spot1 = new go.Spot(0, .49);
3336 geo.spot2 = new go.Spot(1, .75);
3337 return geo;
3338});
3339
3340go.Shape.defineFigureGenerator('PrimitiveFromCall', (shape, w, h) => {
3341 const geo = new go.Geometry();
3342 let param1 = shape ? shape.parameter1 : NaN;
3343 let param2 = shape ? shape.parameter2 : NaN;
3344 if (isNaN(param1)) param1 = .1; // Distance of left line from left
3345 if (isNaN(param2)) param2 = .3; // Distance of point from right
3346 const fig = new go.PathFigure(0, 0, true);
3347 geo.add(fig);
3348
3349 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3350 fig.add(new go.PathSegment(go.PathSegment.Line, (1 - param2) * w, .5 * h));
3351 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3352 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3353 // ??? geo.spot1 = new go.Spot(param1, 0);
3354 // ??? geo.spot2 = new go.Spot(1 - param2, 1);
3355 return geo;
3356});
3357
3358go.Shape.defineFigureGenerator('PrimitiveToCall', (shape, w, h) => {
3359 const geo = new go.Geometry();
3360 let param1 = shape ? shape.parameter1 : NaN;
3361 let param2 = shape ? shape.parameter2 : NaN;
3362 if (isNaN(param1)) param1 = .1; // Distance of left line from left
3363 if (isNaN(param2)) param2 = .3; // Distance of top and bottom right corners from right
3364 const fig = new go.PathFigure(0, 0, true);
3365 geo.add(fig);
3366
3367 fig.add(new go.PathSegment(go.PathSegment.Line, (1 - param2) * w, 0));
3368 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3369 fig.add(new go.PathSegment(go.PathSegment.Line, (1 - param2) * w, h));
3370 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3371 // ??? geo.spot1 = new go.Spot(param1, 0);
3372 // ??? geo.spot2 = new go.Spot(1 - param2, 1);
3373 return geo;
3374});
3375
3376go.Shape.defineFigureGenerator('Procedure', (shape, w, h) => {
3377 const geo = new go.Geometry();
3378 let param1 = shape ? shape.parameter1 : NaN;
3379 // Distance of left and right lines from edge
3380 if (isNaN(param1)) param1 = .1;
3381 const fig = new go.PathFigure(0, 0, true);
3382 geo.add(fig);
3383
3384 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3385 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3386 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3387 const fig2 = new go.PathFigure((1 - param1) * w, 0, false);
3388 geo.add(fig2);
3389 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - param1) * w, h));
3390 fig2.add(new go.PathSegment(go.PathSegment.Move, param1 * w, 0));
3391 fig2.add(new go.PathSegment(go.PathSegment.Line, param1 * w, h));
3392 // ??? geo.spot1 = new go.Spot(param1, 0);
3393 // ??? geo.spot2 = new go.Spot(1 - param1, 1);
3394 return geo;
3395});
3396
3397go.Shape.defineFigureGenerator('Process', (shape, w, h) => {
3398 const geo = new go.Geometry();
3399 let param1 = shape ? shape.parameter1 : NaN;
3400 if (isNaN(param1)) param1 = .1; // Distance of left line from left edge
3401 const fig = new go.PathFigure(0, 0, true);
3402 geo.add(fig);
3403
3404 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3405 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3406 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3407 const fig2 = new go.PathFigure(param1 * w, 0, false);
3408 geo.add(fig2);
3409 fig2.add(new go.PathSegment(go.PathSegment.Line, param1 * w, h));
3410 // ??? geo.spot1 = new go.Spot(param1, 0);
3411 geo.spot2 = go.Spot.BottomRight;
3412 return geo;
3413});
3414
3415go.Shape.defineFigureGenerator('Sort', (shape, w, h) => {
3416 const geo = new go.Geometry();
3417 const fig = new go.PathFigure(.5 * w, 0, true);
3418 geo.add(fig);
3419
3420 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3421 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
3422 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .5 * h).close());
3423 const fig2 = new go.PathFigure(0, .5 * h, false);
3424 geo.add(fig2);
3425 fig2.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3426 geo.spot1 = new go.Spot(.25, .25);
3427 geo.spot2 = new go.Spot(.75, .5);
3428 return geo;
3429});
3430
3431go.Shape.defineFigureGenerator('Start', (shape, w, h) => {
3432 const geo = new go.Geometry();
3433 let param1 = shape ? shape.parameter1 : NaN;
3434 if (isNaN(param1)) param1 = 0.25;
3435 const fig = new go.PathFigure(param1 * w, 0, true);
3436 geo.add(fig);
3437
3438 fig.add(new go.PathSegment(go.PathSegment.Arc, 270, 180, .75 * w, 0.5 * h, .25 * w, .5 * h));
3439 fig.add(new go.PathSegment(go.PathSegment.Arc, 90, 180, .25 * w, 0.5 * h, .25 * w, .5 * h));
3440 const fig2 = new go.PathFigure(param1 * w, 0, false);
3441 geo.add(fig2);
3442 fig2.add(new go.PathSegment(go.PathSegment.Line, param1 * w, h));
3443 fig2.add(new go.PathSegment(go.PathSegment.Move, (1 - param1) * w, 0));
3444 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - param1) * w, h));
3445 geo.spot1 = new go.Spot(param1, 0);
3446 geo.spot2 = new go.Spot((1 - param1), 1);
3447 return geo;
3448});
3449
3450go.Shape.defineFigureGenerator('Terminator', (shape, w, h) => {
3451 const geo = new go.Geometry();
3452 const fig = new go.PathFigure(.25 * w, 0, true);
3453 geo.add(fig);
3454
3455 fig.add(new go.PathSegment(go.PathSegment.Arc, 270, 180, .75 * w, 0.5 * h, .25 * w, .5 * h));
3456 fig.add(new go.PathSegment(go.PathSegment.Arc, 90, 180, .25 * w, 0.5 * h, .25 * w, .5 * h));
3457 geo.spot1 = new go.Spot(.23, 0);
3458 geo.spot2 = new go.Spot(.77, 1);
3459 return geo;
3460});
3461
3462go.Shape.defineFigureGenerator('TransmittalTape', (shape, w, h) => {
3463 const geo = new go.Geometry();
3464 let param1 = shape ? shape.parameter1 : NaN;
3465 if (isNaN(param1)) param1 = .1; // Bottom line's distance from the point on the triangle
3466 const fig = new go.PathFigure(0, 0, true);
3467 geo.add(fig);
3468
3469 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3470 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3471 fig.add(new go.PathSegment(go.PathSegment.Line, .75 * w, (1 - param1) * h));
3472 fig.add(new go.PathSegment(go.PathSegment.Line, 0, (1 - param1) * h).close());
3473 geo.spot1 = go.Spot.TopLeft;
3474 // ??? geo.spot2 = new go.Spot(1, 1 - param1);
3475 return geo;
3476});
3477
3478go.Shape.defineFigureGenerator('AndGate', (shape, w, h) => {
3479 const geo = new go.Geometry();
3480 const cpOffset = KAPPA * .5;
3481 const fig = new go.PathFigure(0, 0, true);
3482 geo.add(fig);
3483
3484 // The gate body
3485 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
3486 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, (.5 + cpOffset) * w, 0,
3487 w, (.5 - cpOffset) * h));
3488 fig.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, h, w, (.5 + cpOffset) * h,
3489 (.5 + cpOffset) * w, h));
3490 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3491 geo.spot1 = go.Spot.TopLeft;
3492 geo.spot2 = new go.Spot(.55, 1);
3493 return geo;
3494});
3495
3496go.Shape.defineFigureGenerator('Buffer', (shape, w, h) => {
3497 const geo = new go.Geometry();
3498 const fig = new go.PathFigure(0, 0, true);
3499 geo.add(fig);
3500
3501 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3502 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
3503 geo.spot1 = new go.Spot(0, .25);
3504 geo.spot2 = new go.Spot(.5, .75);
3505 return geo;
3506});
3507
3508go.Shape.defineFigureGenerator('Clock', (shape, w, h) => {
3509 const geo = new go.Geometry();
3510 const cpOffset = KAPPA * .5;
3511 const radius = .5;
3512 const fig = new go.PathFigure(w, radius * h, true);
3513 geo.add(fig);
3514
3515 // Ellipse
3516 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, h, w, (radius + cpOffset) * h,
3517 (radius + cpOffset) * w, h));
3518 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, radius * h, (radius - cpOffset) * w, h,
3519 0, (radius + cpOffset) * h));
3520 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, 0, 0, (radius - cpOffset) * h,
3521 (radius - cpOffset) * w, 0));
3522 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, radius * h, (radius + cpOffset) * w, 0,
3523 w, (radius - cpOffset) * h));
3524 const fig2 = new go.PathFigure(w, radius * h, false);
3525 geo.add(fig2);
3526 fig2.add(new go.PathSegment(go.PathSegment.Line, w, radius * h));
3527 const fig3 = new go.PathFigure(.8 * w, .75 * h, false);
3528 geo.add(fig3);
3529 // Inside clock
3530 // This first line solves a GDI+ graphical error with
3531 // more complex gradient brushes
3532 fig3.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .25 * h));
3533 fig3.add(new go.PathSegment(go.PathSegment.Line, .6 * w, .25 * h));
3534 fig3.add(new go.PathSegment(go.PathSegment.Line, .6 * w, .75 * h));
3535 fig3.add(new go.PathSegment(go.PathSegment.Line, .4 * w, .75 * h));
3536 fig3.add(new go.PathSegment(go.PathSegment.Line, .4 * w, .25 * h));
3537 fig3.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .25 * h));
3538 fig3.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .75 * h));
3539 return geo;
3540});
3541
3542go.Shape.defineFigureGenerator('Ground', (shape, w, h) => {
3543 const geo = new go.Geometry();
3544 const fig = new go.PathFigure(.5 * w, 0, false);
3545 geo.add(fig);
3546
3547 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .4 * h));
3548 fig.add(new go.PathSegment(go.PathSegment.Move, .2 * w, .6 * h));
3549 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .6 * h));
3550 fig.add(new go.PathSegment(go.PathSegment.Move, .3 * w, .8 * h));
3551 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, .8 * h));
3552 fig.add(new go.PathSegment(go.PathSegment.Move, .4 * w, h));
3553 fig.add(new go.PathSegment(go.PathSegment.Line, .6 * w, h));
3554 return geo;
3555});
3556
3557go.Shape.defineFigureGenerator('Inverter', (shape, w, h) => {
3558 const geo = new go.Geometry();
3559 const cpOffset = KAPPA * .1;
3560 const radius = .1;
3561 const centerx = .9;
3562 const centery = .5;
3563 const fig = new go.PathFigure(.8 * w, .5 * h, true);
3564 geo.add(fig);
3565
3566 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3567 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
3568 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .5 * h));
3569 const fig2 = new go.PathFigure((centerx + radius) * w, centery * h, true);
3570 geo.add(fig2);
3571 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
3572 (centerx + cpOffset) * w, (centery + radius) * h));
3573 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
3574 (centerx - radius) * w, (centery + cpOffset) * h));
3575 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
3576 (centerx - cpOffset) * w, (centery - radius) * h));
3577 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
3578 (centerx + radius) * w, (centery - cpOffset) * h));
3579 geo.spot1 = new go.Spot(0, .25);
3580 geo.spot2 = new go.Spot(.4, .75);
3581 return geo;
3582});
3583
3584go.Shape.defineFigureGenerator('NandGate', (shape, w, h) => {
3585 const geo = new go.Geometry();
3586 const cpxOffset = KAPPA * .5;
3587 const cpyOffset = KAPPA * .4;
3588 const cpOffset = KAPPA * .1;
3589 const radius = .1;
3590 const centerx = .9;
3591 const centery = .5;
3592 const fig = new go.PathFigure(.8 * w, .5 * h, true);
3593 geo.add(fig);
3594
3595 // The gate body
3596 fig.add(new go.PathSegment(go.PathSegment.Bezier, .4 * w, h, .8 * w, (.5 + cpyOffset) * h,
3597 (.4 + cpxOffset) * w, h));
3598 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3599 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
3600 fig.add(new go.PathSegment(go.PathSegment.Line, .4 * w, 0));
3601 fig.add(new go.PathSegment(go.PathSegment.Bezier, .8 * w, .5 * h, (.4 + cpxOffset) * w, 0,
3602 .8 * w, (.5 - cpyOffset) * h));
3603 const fig2 = new go.PathFigure((centerx + radius) * w, centery * h, true);
3604 geo.add(fig2);
3605 // Inversion
3606 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
3607 (centerx + cpOffset) * w, (centery + radius) * h));
3608 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
3609 (centerx - radius) * w, (centery + cpOffset) * h));
3610 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
3611 (centerx - cpOffset) * w, (centery - radius) * h));
3612 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, (centery) * h, (centerx + cpOffset) * w, (centery - radius) * h,
3613 (centerx + radius) * w, (centery - cpOffset) * h));
3614 geo.spot1 = new go.Spot(0, .05);
3615 geo.spot2 = new go.Spot(.55, .95);
3616 return geo;
3617});
3618
3619go.Shape.defineFigureGenerator('NorGate', (shape, w, h) => {
3620 const geo = new go.Geometry();
3621 let radius = .5;
3622 let cpOffset = KAPPA * radius;
3623 let centerx = 0;
3624 let centery = .5;
3625 const fig = new go.PathFigure(.8 * w, .5 * h, true);
3626 geo.add(fig);
3627
3628 // Normal
3629 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h, .7 * w, (centery + cpOffset) * h,
3630 (centerx + cpOffset) * w, (centery + radius) * h));
3631 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0, .25 * w, .75 * h,
3632 .25 * w, .25 * h));
3633 fig.add(new go.PathSegment(go.PathSegment.Bezier, .8 * w, .5 * h, (centerx + cpOffset) * w, (centery - radius) * h,
3634 .7 * w, (centery - cpOffset) * h));
3635 radius = .1;
3636 cpOffset = KAPPA * .1;
3637 centerx = .9;
3638 centery = .5;
3639 const fig2 = new go.PathFigure((centerx - radius) * w, centery * h, true);
3640 geo.add(fig2);
3641 // Inversion
3642 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
3643 (centerx - cpOffset) * w, (centery - radius) * h));
3644 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
3645 (centerx + radius) * w, (centery - cpOffset) * h));
3646 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
3647 (centerx + cpOffset) * w, (centery + radius) * h));
3648 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
3649 (centerx - radius) * w, (centery + cpOffset) * h));
3650 geo.spot1 = new go.Spot(.2, .25);
3651 geo.spot2 = new go.Spot(.6, .75);
3652 return geo;
3653});
3654
3655go.Shape.defineFigureGenerator('OrGate', (shape, w, h) => {
3656 const geo = new go.Geometry();
3657 const radius = .5;
3658 const cpOffset = KAPPA * radius;
3659 const centerx = 0;
3660 const centery = .5;
3661 const fig = new go.PathFigure(0, 0, true);
3662 geo.add(fig);
3663
3664 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, (centerx + cpOffset + cpOffset) * w, (centery - radius) * h,
3665 .8 * w, (centery - cpOffset) * h));
3666 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h, .8 * w, (centery + cpOffset) * h,
3667 (centerx + cpOffset + cpOffset) * w, (centery + radius) * h));
3668 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0, .25 * w, .75 * h, .25 * w, .25 * h).close());
3669 geo.spot1 = new go.Spot(.2, .25);
3670 geo.spot2 = new go.Spot(.75, .75);
3671 return geo;
3672});
3673
3674go.Shape.defineFigureGenerator('XnorGate', (shape, w, h) => {
3675 const geo = new go.Geometry();
3676 let radius = .5;
3677 let cpOffset = KAPPA * radius;
3678 let centerx = .2;
3679 let centery = .5;
3680 const fig = new go.PathFigure(.1 * w, 0, false);
3681 geo.add(fig);
3682
3683 // Normal
3684 fig.add(new go.PathSegment(go.PathSegment.Bezier, .1 * w, h, .35 * w, .25 * h, .35 * w, .75 * h));
3685 const fig2 = new go.PathFigure(.8 * w, .5 * h, true);
3686 geo.add(fig2);
3687 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .2 * w, h, .7 * w, (centery + cpOffset) * h,
3688 (centerx + cpOffset) * w, (centery + radius) * h));
3689 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .2 * w, 0, .45 * w, .75 * h, .45 * w, .25 * h));
3690 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .8 * w, .5 * h, (centerx + cpOffset) * w, (centery - radius) * h,
3691 .7 * w, (centery - cpOffset) * h));
3692 radius = .1;
3693 cpOffset = KAPPA * .1;
3694 centerx = .9;
3695 centery = .5;
3696 const fig3 = new go.PathFigure((centerx - radius) * w, centery * h, true);
3697 geo.add(fig3);
3698 // Inversion
3699 fig3.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
3700 (centerx - cpOffset) * w, (centery - radius) * h));
3701 fig3.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
3702 (centerx + radius) * w, (centery - cpOffset) * h));
3703 fig3.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
3704 (centerx + cpOffset) * w, (centery + radius) * h));
3705 fig3.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
3706 (centerx - radius) * w, (centery + cpOffset) * h));
3707 geo.spot1 = new go.Spot(.4, .25);
3708 geo.spot2 = new go.Spot(.65, .75);
3709 return geo;
3710});
3711
3712go.Shape.defineFigureGenerator('XorGate', (shape, w, h) => {
3713 const geo = new go.Geometry();
3714 const radius = .5;
3715 const cpOffset = KAPPA * radius;
3716 const centerx = .2;
3717 const centery = .5;
3718 const fig = new go.PathFigure(.1 * w, 0, false);
3719 geo.add(fig);
3720
3721 fig.add(new go.PathSegment(go.PathSegment.Bezier, .1 * w, h, .35 * w, .25 * h, .35 * w, .75 * h));
3722 const fig2 = new go.PathFigure(.2 * w, 0, true);
3723 geo.add(fig2);
3724 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, (centerx + cpOffset) * w, (centery - radius) * h,
3725 .9 * w, (centery - cpOffset) * h));
3726 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .2 * w, h, .9 * w, (centery + cpOffset) * h,
3727 (centerx + cpOffset) * w, (centery + radius) * h));
3728 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .2 * w, 0, .45 * w, .75 * h, .45 * w, .25 * h).close());
3729 geo.spot1 = new go.Spot(.4, .25);
3730 geo.spot2 = new go.Spot(.8, .75);
3731 return geo;
3732});
3733
3734go.Shape.defineFigureGenerator('Capacitor', (shape, w, h) => {
3735 const geo = new go.Geometry();
3736 const fig = new go.PathFigure(0, 0, false);
3737 geo.add(fig);
3738
3739 // Two vertical lines
3740 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3741 fig.add(new go.PathSegment(go.PathSegment.Move, w, 0));
3742 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3743 return geo;
3744});
3745
3746go.Shape.defineFigureGenerator('Resistor', (shape, w, h) => {
3747 const geo = new go.Geometry();
3748 const fig = new go.PathFigure(0, .5 * h, false);
3749 geo.add(fig);
3750
3751 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, 0));
3752 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, h));
3753 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, 0));
3754 fig.add(new go.PathSegment(go.PathSegment.Line, .4 * w, h));
3755 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
3756 fig.add(new go.PathSegment(go.PathSegment.Line, .6 * w, h));
3757 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, .5 * h));
3758 return geo;
3759});
3760
3761go.Shape.defineFigureGenerator('Inductor', (shape, w, h) => {
3762 const geo = new go.Geometry();
3763 const cpOffset = KAPPA * .1;
3764 const radius = .1;
3765 let centerx = .1;
3766 const centery = .5;
3767 // Up
3768 const fig = new go.PathFigure((centerx - cpOffset * .5) * w, h, false);
3769 geo.add(fig);
3770
3771 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, 0, (centerx - cpOffset) * w, h, (centerx - radius) * w, 0));
3772 // Down up
3773 centerx = .3;
3774 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, h, (centerx + radius) * w, 0, (centerx + cpOffset) * w, h));
3775 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, 0, (centerx - cpOffset) * w, h, (centerx - radius) * w, 0));
3776 // Down up
3777 centerx = .5;
3778 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, h, (centerx + radius) * w, 0, (centerx + cpOffset) * w, h));
3779 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, 0, (centerx - cpOffset) * w, h, (centerx - radius) * w, 0));
3780 // Down up
3781 centerx = .7;
3782 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, h, (centerx + radius) * w, 0, (centerx + cpOffset) * w, h));
3783 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, 0, (centerx - cpOffset) * w, h, (centerx - radius) * w, 0));
3784 // Down up
3785 centerx = .9;
3786 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + cpOffset * .5) * w, h, (centerx + radius) * w, 0, (centerx + cpOffset) * w, h));
3787 return geo;
3788});
3789
3790go.Shape.defineFigureGenerator('ACvoltageSource', (shape, w, h) => {
3791 const geo = new go.Geometry();
3792 const cpOffset = KAPPA * .5;
3793 const radius = .5;
3794 const centerx = .5;
3795 const centery = .5;
3796 const fig = new go.PathFigure((centerx - radius) * w, centery * h, false);
3797 geo.add(fig);
3798
3799 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
3800 (centerx - cpOffset) * w, (centery - radius) * h));
3801 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
3802 (centerx + radius) * w, (centery - cpOffset) * h));
3803 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
3804 (centerx + cpOffset) * w, (centery + radius) * h));
3805 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
3806 (centerx - radius) * w, (centery + cpOffset) * h));
3807 fig.add(new go.PathSegment(go.PathSegment.Move, (centerx - radius + .1) * w, centery * h));
3808 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius - .1) * w, centery * h, centerx * w, (centery - radius) * h,
3809 centerx * w, (centery + radius) * h));
3810 return geo;
3811});
3812
3813go.Shape.defineFigureGenerator('DCvoltageSource', (shape, w, h) => {
3814 const geo = new go.Geometry();
3815 const fig = new go.PathFigure(0, .75 * h, false);
3816 geo.add(fig);
3817
3818 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .25 * h));
3819 fig.add(new go.PathSegment(go.PathSegment.Move, w, 0));
3820 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3821 return geo;
3822});
3823
3824go.Shape.defineFigureGenerator('Diode', (shape, w, h) => {
3825 const geo = new go.Geometry();
3826 const fig = new go.PathFigure(w, 0, false);
3827 geo.add(fig);
3828
3829 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3830 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3831 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
3832 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
3833 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3834 geo.spot1 = new go.Spot(0, .25);
3835 geo.spot2 = new go.Spot(.5, .75);
3836 return geo;
3837});
3838
3839go.Shape.defineFigureGenerator('Wifi', (shape, w, h) => {
3840 const geo = new go.Geometry();
3841 const origw = w;
3842 const origh = h;
3843 w = w * .38;
3844 h = h * .6;
3845 let cpOffset = KAPPA * .8;
3846 let radius = .8;
3847 let centerx = 0;
3848 let centery = .5;
3849 const xOffset = (origw - w) / 2;
3850 const yOffset = (origh - h) / 2;
3851 const fig = new go.PathFigure(centerx * w + xOffset, (centery + radius) * h + yOffset, true);
3852 geo.add(fig);
3853
3854 // Left curves
3855 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w + xOffset,
3856 centery * h + yOffset, (centerx - cpOffset) * w + xOffset,
3857 (centery + radius) * h + yOffset,
3858 (centerx - radius) * w + xOffset,
3859 (centery + cpOffset) * h + yOffset));
3860 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3861 (centery - radius) * h + yOffset, (centerx - radius) * w + xOffset,
3862 (centery - cpOffset) * h + yOffset,
3863 (centerx - cpOffset) * w + xOffset,
3864 (centery - radius) * h + yOffset));
3865 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius + cpOffset * .5) * w + xOffset,
3866 centery * h + yOffset, centerx * w + xOffset,
3867 (centery - radius) * h + yOffset,
3868 (centerx - radius + cpOffset * .5) * w + xOffset,
3869 (centery - cpOffset) * h + yOffset));
3870 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3871 (centery + radius) * h + yOffset, (centerx - radius + cpOffset * .5) * w + xOffset,
3872 (centery + cpOffset) * h + yOffset,
3873 centerx * w + xOffset,
3874 (centery + radius) * h + yOffset).close());
3875 cpOffset = KAPPA * .4;
3876 radius = .4;
3877 centerx = .2;
3878 centery = .5;
3879 const fig2 = new go.PathFigure(centerx * w + xOffset, (centery + radius) * h + yOffset, true);
3880 geo.add(fig2);
3881 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w + xOffset,
3882 centery * h + yOffset, (centerx - cpOffset) * w + xOffset,
3883 (centery + radius) * h + yOffset,
3884 (centerx - radius) * w + xOffset,
3885 (centery + cpOffset) * h + yOffset));
3886 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3887 (centery - radius) * h + yOffset, (centerx - radius) * w + xOffset,
3888 (centery - cpOffset) * h + yOffset,
3889 (centerx - cpOffset) * w + xOffset,
3890 (centery - radius) * h + yOffset));
3891 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius + cpOffset * .5) * w + xOffset,
3892 centery * h + yOffset, centerx * w + xOffset,
3893 (centery - radius) * h + yOffset,
3894 (centerx - radius + cpOffset * .5) * w + xOffset,
3895 (centery - cpOffset) * h + yOffset));
3896 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3897 (centery + radius) * h + yOffset, (centerx - radius + cpOffset * .5) * w + xOffset,
3898 (centery + cpOffset) * h + yOffset,
3899 centerx * w + xOffset,
3900 (centery + radius) * h + yOffset).close());
3901 cpOffset = KAPPA * .2;
3902 radius = .2;
3903 centerx = .5;
3904 centery = .5;
3905 const fig3 = new go.PathFigure((centerx - radius) * w + xOffset, centery * h + yOffset, true);
3906 geo.add(fig3);
3907 // Center circle
3908 fig3.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3909 (centery - radius) * h + yOffset, (centerx - radius) * w + xOffset,
3910 (centery - cpOffset) * h + yOffset,
3911 (centerx - cpOffset) * w + xOffset,
3912 (centery - radius) * h + yOffset));
3913 fig3.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w + xOffset,
3914 centery * h + yOffset, (centerx + cpOffset) * w + xOffset,
3915 (centery - radius) * h + yOffset,
3916 (centerx + radius) * w + xOffset,
3917 (centery - cpOffset) * h + yOffset));
3918 fig3.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3919 (centery + radius) * h + yOffset, (centerx + radius) * w + xOffset,
3920 (centery + cpOffset) * h + yOffset,
3921 (centerx + cpOffset) * w + xOffset,
3922 (centery + radius) * h + yOffset));
3923 fig3.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w + xOffset,
3924 centery * h + yOffset, (centerx - cpOffset) * w + xOffset,
3925 (centery + radius) * h + yOffset,
3926 (centerx - radius) * w + xOffset,
3927 (centery + cpOffset) * h + yOffset));
3928 cpOffset = KAPPA * .4;
3929 radius = .4;
3930 centerx = .8;
3931 centery = .5;
3932 const fig4 = new go.PathFigure(centerx * w + xOffset, (centery - radius) * h + yOffset, true);
3933 geo.add(fig4);
3934 // Right curves
3935 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w + xOffset,
3936 centery * h + yOffset, (centerx + cpOffset) * w + xOffset,
3937 (centery - radius) * h + yOffset,
3938 (centerx + radius) * w + xOffset,
3939 (centery - cpOffset) * h + yOffset));
3940 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3941 (centery + radius) * h + yOffset, (centerx + radius) * w + xOffset,
3942 (centery + cpOffset) * h + yOffset,
3943 (centerx + cpOffset) * w + xOffset,
3944 (centery + radius) * h + yOffset));
3945 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius - cpOffset * .5) * w + xOffset,
3946 centery * h + yOffset, centerx * w + xOffset,
3947 (centery + radius) * h + yOffset,
3948 (centerx + radius - cpOffset * .5) * w + xOffset,
3949 (centery + cpOffset) * h + yOffset));
3950 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3951 (centery - radius) * h + yOffset, (centerx + radius - cpOffset * .5) * w + xOffset,
3952 (centery - cpOffset) * h + yOffset,
3953 centerx * w + xOffset,
3954 (centery - radius) * h + yOffset).close());
3955 cpOffset = KAPPA * .8;
3956 radius = .8;
3957 centerx = 1;
3958 centery = .5;
3959 const fig5 = new go.PathFigure(centerx * w + xOffset, (centery - radius) * h + yOffset, true);
3960 geo.add(fig5);
3961 fig5.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w + xOffset,
3962 centery * h + yOffset, (centerx + cpOffset) * w + xOffset,
3963 (centery - radius) * h + yOffset,
3964 (centerx + radius) * w + xOffset,
3965 (centery - cpOffset) * h + yOffset));
3966 fig5.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3967 (centery + radius) * h + yOffset, (centerx + radius) * w + xOffset,
3968 (centery + cpOffset) * h + yOffset,
3969 (centerx + cpOffset) * w + xOffset,
3970 (centery + radius) * h + yOffset));
3971 fig5.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius - cpOffset * .5) * w + xOffset,
3972 centery * h + yOffset, centerx * w + xOffset,
3973 (centery + radius) * h + yOffset,
3974 (centerx + radius - cpOffset * .5) * w + xOffset,
3975 (centery + cpOffset) * h + yOffset));
3976 fig5.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w + xOffset,
3977 (centery - radius) * h + yOffset, (centerx + radius - cpOffset * .5) * w + xOffset,
3978 (centery - cpOffset) * h + yOffset,
3979 centerx * w + xOffset,
3980 (centery - radius) * h + yOffset).close());
3981 return geo;
3982});
3983
3984go.Shape.defineFigureGenerator('Email', (shape, w, h) => {
3985 const geo = new go.Geometry();
3986 const fig = new go.PathFigure(0, 0, true);
3987 geo.add(fig);
3988
3989 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3990 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
3991 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
3992 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0).close());
3993 const fig2 = new go.PathFigure(0, 0, false);
3994 geo.add(fig2);
3995 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .6 * h));
3996 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0));
3997 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, h));
3998 fig2.add(new go.PathSegment(go.PathSegment.Line, .45 * w, .54 * h));
3999 fig2.add(new go.PathSegment(go.PathSegment.Move, w, h));
4000 fig2.add(new go.PathSegment(go.PathSegment.Line, .55 * w, .54 * h));
4001 return geo;
4002});
4003
4004go.Shape.defineFigureGenerator('Ethernet', (shape, w, h) => {
4005 const geo = new go.Geometry();
4006 const fig = new go.PathFigure(.35 * w, 0, true);
4007 geo.add(fig);
4008 // Boxes above the wire
4009 fig.add(new go.PathSegment(go.PathSegment.Line, .65 * w, 0));
4010 fig.add(new go.PathSegment(go.PathSegment.Line, .65 * w, .4 * h));
4011 fig.add(new go.PathSegment(go.PathSegment.Line, .35 * w, .4 * h));
4012 fig.add(new go.PathSegment(go.PathSegment.Line, .35 * w, 0).close());
4013 const fig2 = new go.PathFigure(.10 * w, h, true, true);
4014 geo.add(fig2);
4015 // Boxes under the wire
4016 fig2.add(new go.PathSegment(go.PathSegment.Line, .40 * w, h));
4017 fig2.add(new go.PathSegment(go.PathSegment.Line, .40 * w, .6 * h));
4018 fig2.add(new go.PathSegment(go.PathSegment.Line, .10 * w, .6 * h));
4019 fig2.add(new go.PathSegment(go.PathSegment.Line, .10 * w, h).close());
4020 const fig3 = new go.PathFigure(.60 * w, h, true, true);
4021 geo.add(fig3);
4022 fig3.add(new go.PathSegment(go.PathSegment.Line, .90 * w, h));
4023 fig3.add(new go.PathSegment(go.PathSegment.Line, .90 * w, .6 * h));
4024 fig3.add(new go.PathSegment(go.PathSegment.Line, .60 * w, .6 * h));
4025 fig3.add(new go.PathSegment(go.PathSegment.Line, .60 * w, h).close());
4026 const fig4 = new go.PathFigure(0, .5 * h, false);
4027 geo.add(fig4);
4028 // Wire
4029 fig4.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
4030 fig4.add(new go.PathSegment(go.PathSegment.Move, .5 * w, .5 * h));
4031 fig4.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .4 * h));
4032 fig4.add(new go.PathSegment(go.PathSegment.Move, .75 * w, .5 * h));
4033 fig4.add(new go.PathSegment(go.PathSegment.Line, .75 * w, .6 * h));
4034 fig4.add(new go.PathSegment(go.PathSegment.Move, .25 * w, .5 * h));
4035 fig4.add(new go.PathSegment(go.PathSegment.Line, .25 * w, .6 * h));
4036 return geo;
4037});
4038
4039go.Shape.defineFigureGenerator('Power', (shape, w, h) => {
4040 const geo = new go.Geometry();
4041 let cpOffset = KAPPA * .4;
4042 let radius = .4;
4043 const centerx = .5;
4044 const centery = .5;
4045 const unused = tempPoint();
4046 const mid = tempPoint();
4047 const c1 = tempPoint();
4048 const c2 = tempPoint();
4049 // Find the 45 degree midpoint for the first bezier
4050 breakUpBezier(centerx, centery - radius,
4051 centerx + cpOffset, centery - radius,
4052 centerx + radius, centery - cpOffset,
4053 centerx + radius, centery, .5, unused,
4054 unused, mid, c1, c2);
4055 const start = tempPointAt(mid.x, mid.y);
4056 let fig = new go.PathFigure(mid.x * w, mid.y * h, true);
4057 geo.add(fig);
4058
4059 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, c1.x * w, c1.y * h, c2.x * w, c2.y * h));
4060 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4061 (centerx + cpOffset) * w, (centery + radius) * h));
4062 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4063 (centerx - radius) * w, (centery + cpOffset) * h));
4064 // Find the 45 degree midpoint of for the fourth bezier
4065 breakUpBezier(centerx - radius, centery,
4066 centerx - radius, centery - cpOffset,
4067 centerx - cpOffset, centery - radius,
4068 centerx, centery - radius, .5, c1,
4069 c2, mid, unused, unused);
4070 fig.add(new go.PathSegment(go.PathSegment.Bezier, mid.x * w, mid.y * h, c1.x * w, c1.y * h,
4071 c2.x * w, c2.y * h));
4072 // now make a smaller circle
4073 cpOffset = KAPPA * .3;
4074 radius = .3;
4075 // Find the 45 degree midpoint for the first bezier
4076 breakUpBezier(centerx - radius, centery,
4077 centerx - radius, centery - cpOffset,
4078 centerx - cpOffset, centery - radius,
4079 centerx, centery - radius, .5, c1,
4080 c2, mid, unused, unused);
4081 fig.add(new go.PathSegment(go.PathSegment.Line, mid.x * w, mid.y * h));
4082 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, c2.x * w, c2.y * h, c1.x * w, c1.y * h));
4083 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx - radius) * w, (centery + cpOffset) * h,
4084 (centerx - cpOffset) * w, (centery + radius) * h));
4085 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery + radius) * h,
4086 (centerx + radius) * w, (centery + cpOffset) * h));
4087 // Find the 45 degree midpoint for the fourth bezier
4088 breakUpBezier(centerx, centery - radius,
4089 centerx + cpOffset, centery - radius,
4090 centerx + radius, centery - cpOffset,
4091 centerx + radius, centery, .5, unused,
4092 unused, mid, c1, c2);
4093 fig.add(new go.PathSegment(go.PathSegment.Bezier, mid.x * w, mid.y * h, c2.x * w, c2.y * h, c1.x * w, c1.y * h).close());
4094 fig = new go.PathFigure(.45 * w, 0, true);
4095 geo.add(fig);
4096 fig.add(new go.PathSegment(go.PathSegment.Line, .45 * w, .5 * h));
4097 fig.add(new go.PathSegment(go.PathSegment.Line, .55 * w, .5 * h));
4098 fig.add(new go.PathSegment(go.PathSegment.Line, .55 * w, 0).close());
4099 freePoint(unused);
4100 freePoint(mid);
4101 freePoint(c1);
4102 freePoint(c2);
4103 freePoint(start);
4104 geo.spot1 = new go.Spot(.25, .45);
4105 geo.spot2 = new go.Spot(.75, .8);
4106 return geo;
4107});
4108
4109go.Shape.defineFigureGenerator('Fallout', (shape, w, h) => {
4110 const geo = new go.Geometry();
4111 const fig = new go.PathFigure(0, h / 2, true);
4112 geo.add(fig);
4113
4114 // Containing circle
4115 fig.add(new go.PathSegment(go.PathSegment.Arc, 180, 360, w / 2, h / 2, w / 2, h / 2));
4116
4117 function drawTriangle(f: go.PathFigure, offsetx: number, offsety: number) {
4118 f.add(new go.PathSegment(go.PathSegment.Move, (.3 + offsetx) * w, (.8 + offsety) * h));
4119 f.add(new go.PathSegment(go.PathSegment.Line, (.5 + offsetx) * w, (.5 + offsety) * h));
4120 f.add(new go.PathSegment(go.PathSegment.Line, (.1 + offsetx) * w, (.5 + offsety) * h));
4121 f.add(new go.PathSegment(go.PathSegment.Line, (.3 + offsetx) * w, (.8 + offsety) * h).close());
4122 }
4123
4124 // Triangles
4125 drawTriangle(fig, 0, 0);
4126 drawTriangle(fig, 0.4, 0);
4127 drawTriangle(fig, 0.2, -0.3);
4128 return geo;
4129});
4130
4131go.Shape.defineFigureGenerator('IrritationHazard', (shape, w, h) => {
4132 const geo = new go.Geometry();
4133 const fig = new go.PathFigure(.2 * w, 0, true);
4134 geo.add(fig);
4135
4136 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .3 * h));
4137 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, 0));
4138 fig.add(new go.PathSegment(go.PathSegment.Line, w, .2 * h));
4139 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, .5 * h));
4140 fig.add(new go.PathSegment(go.PathSegment.Line, w, .8 * h));
4141 fig.add(new go.PathSegment(go.PathSegment.Line, .8 * w, h));
4142 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .7 * h));
4143 fig.add(new go.PathSegment(go.PathSegment.Line, .2 * w, h));
4144 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .8 * h));
4145 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, .5 * h));
4146 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .2 * h).close());
4147 geo.spot1 = new go.Spot(.3, .3);
4148 geo.spot2 = new go.Spot(.7, .7);
4149 return geo;
4150});
4151
4152go.Shape.defineFigureGenerator('ElectricalHazard', (shape, w, h) => {
4153 const geo = new go.Geometry();
4154 const fig = new go.PathFigure(.37 * w, 0, true);
4155 geo.add(fig);
4156
4157 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .11 * h));
4158 fig.add(new go.PathSegment(go.PathSegment.Line, .77 * w, .04 * h));
4159 fig.add(new go.PathSegment(go.PathSegment.Line, .33 * w, .49 * h));
4160 fig.add(new go.PathSegment(go.PathSegment.Line, w, .37 * h));
4161 fig.add(new go.PathSegment(go.PathSegment.Line, .63 * w, .86 * h));
4162 fig.add(new go.PathSegment(go.PathSegment.Line, .77 * w, .91 * h));
4163 fig.add(new go.PathSegment(go.PathSegment.Line, .34 * w, h));
4164 fig.add(new go.PathSegment(go.PathSegment.Line, .34 * w, .78 * h));
4165 fig.add(new go.PathSegment(go.PathSegment.Line, .44 * w, .8 * h));
4166 fig.add(new go.PathSegment(go.PathSegment.Line, .65 * w, .56 * h));
4167 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .68 * h).close());
4168 return geo;
4169});
4170
4171go.Shape.defineFigureGenerator('FireHazard', (shape, w, h) => {
4172 const geo = new go.Geometry();
4173 const fig = new go.PathFigure(.1 * w, h, true);
4174 geo.add(fig);
4175
4176 fig.add(new go.PathSegment(go.PathSegment.Bezier, .29 * w, 0, -.25 * w, .63 * h,
4177 .45 * w, .44 * h));
4178 fig.add(new go.PathSegment(go.PathSegment.Bezier, .51 * w, .42 * h, .48 * w, .17 * h,
4179 .54 * w, .35 * h));
4180 fig.add(new go.PathSegment(go.PathSegment.Bezier, .59 * w, .18 * h, .59 * w, .29 * h,
4181 .58 * w, .28 * h));
4182 fig.add(new go.PathSegment(go.PathSegment.Bezier, .75 * w, .6 * h, .8 * w, .34 * h,
4183 .88 * w, .43 * h));
4184 fig.add(new go.PathSegment(go.PathSegment.Bezier, .88 * w, .31 * h, .87 * w, .48 * h,
4185 .88 * w, .43 * h));
4186 fig.add(new go.PathSegment(go.PathSegment.Bezier, .9 * w, h, 1.17 * w, .76 * h,
4187 .82 * w, .8 * h).close());
4188 geo.spot1 = new go.Spot(.07, .445);
4189 geo.spot2 = new go.Spot(.884, .958);
4190 return geo;
4191});
4192
4193go.Shape.defineFigureGenerator('BpmnActivityLoop', (shape, w, h) => {
4194 const geo = new go.Geometry();
4195 const r = .5;
4196 const cx = 0; // offset from Center x
4197 const cy = 0; // offset from Center y
4198 const d = r * KAPPA;
4199 const mx1 = (.4 * Math.SQRT2 / 2 + .5);
4200 const my1 = (.5 - .5 * Math.SQRT2 / 2);
4201 const x1 = 1;
4202 const y1 = .5;
4203 const x2 = .5;
4204 const y2 = 0;
4205 const fig = new go.PathFigure(mx1 * w, (1 - my1) * h, false);
4206 geo.add(fig);
4207
4208 fig.add(new go.PathSegment(go.PathSegment.Bezier, x1 * w, y1 * h, x1 * w, .7 * h,
4209 x1 * w, y1 * h));
4210 fig.add(new go.PathSegment(go.PathSegment.Bezier, (x2 + cx) * w, (y2 + cx) * h, (.5 + r + cx) * w, (.5 - d + cx) * h,
4211 (.5 + d + cx) * w, (.5 - r + cx) * h));
4212 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.5 - r + cx) * w, (.5 + cy) * h, (.5 - d + cx) * w, (.5 - r + cy) * h,
4213 (.5 - r + cx) * w, (.5 - d + cy) * h));
4214 fig.add(new go.PathSegment(go.PathSegment.Bezier, (.35 + cx) * w, .9 * h, (.5 - r + cx) * w, (.5 + d + cy) * h,
4215 (.5 - d + cx) * w, .9 * h));
4216 // Arrowhead
4217 fig.add(new go.PathSegment(go.PathSegment.Move, (.25 + cx) * w, 0.8 * h));
4218 fig.add(new go.PathSegment(go.PathSegment.Line, (.35 + cx) * w, 0.9 * h));
4219 fig.add(new go.PathSegment(go.PathSegment.Line, (.20 + cx) * w, 0.95 * h));
4220 return geo;
4221});
4222
4223go.Shape.defineFigureGenerator('BpmnActivityParallel', (shape, w, h) => {
4224 const geo = new go.Geometry();
4225 const fig = new go.PathFigure(0, 0, false);
4226 geo.add(fig);
4227
4228 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4229 fig.add(new go.PathSegment(go.PathSegment.Move, .5 * w, 0));
4230 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h));
4231 fig.add(new go.PathSegment(go.PathSegment.Move, w, 0));
4232 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4233 return geo;
4234});
4235
4236go.Shape.defineFigureGenerator('BpmnActivitySequential', (shape, w, h) => {
4237 const geo = new go.Geometry();
4238 const fig = new go.PathFigure(0, 0, false);
4239 geo.add(fig);
4240
4241 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4242 fig.add(new go.PathSegment(go.PathSegment.Move, 0, .5 * h));
4243 fig.add(new go.PathSegment(go.PathSegment.Line, w, .5 * h));
4244 fig.add(new go.PathSegment(go.PathSegment.Move, 0, h));
4245 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4246 return geo;
4247});
4248
4249go.Shape.defineFigureGenerator('BpmnActivityAdHoc', (shape, w, h) => {
4250 const geo = new go.Geometry();
4251 const fig = new go.PathFigure(0, 0, false);
4252 geo.add(fig);
4253
4254 const fig2 = new go.PathFigure(w, h, false);
4255 geo.add(fig2);
4256 const fig3 = new go.PathFigure(0, .5 * h, false);
4257 geo.add(fig3);
4258 fig3.add(new go.PathSegment(go.PathSegment.Bezier, .5 * w, .5 * h, .2 * w, .35 * h,
4259 .3 * w, .35 * h));
4260 fig3.add(new go.PathSegment(go.PathSegment.Bezier, w, .5 * h, .7 * w, .65 * h,
4261 .8 * w, .65 * h));
4262 return geo;
4263});
4264
4265go.Shape.defineFigureGenerator('BpmnActivityCompensation', (shape, w, h) => {
4266 const geo = new go.Geometry();
4267 const fig = new go.PathFigure(0, .5 * h, true);
4268 geo.add(fig);
4269
4270 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
4271 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h));
4272 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4273 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4274 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h));
4275 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h).close());
4276 return geo;
4277});
4278
4279go.Shape.defineFigureGenerator('BpmnTaskMessage', (shape, w, h) => {
4280 const geo = new go.Geometry();
4281 let fig = new go.PathFigure(0, .2 * h, true);
4282 geo.add(fig);
4283
4284 fig.add(new go.PathSegment(go.PathSegment.Line, w, .2 * h));
4285 fig.add(new go.PathSegment(go.PathSegment.Line, w, .8 * h));
4286 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .8 * h));
4287 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .8 * h).close());
4288 fig = new go.PathFigure(0, .2 * h, false);
4289 geo.add(fig);
4290
4291 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h));
4292 fig.add(new go.PathSegment(go.PathSegment.Line, w, .2 * h));
4293 return geo;
4294});
4295
4296go.Shape.defineFigureGenerator('BpmnTaskScript', (shape, w, h) => {
4297 const geo = new go.Geometry();
4298 const fig = new go.PathFigure(.7 * w, h, true);
4299 geo.add(fig);
4300
4301 fig.add(new go.PathSegment(go.PathSegment.Line, .3 * w, h));
4302 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.3 * w, 0, .6 * w, .5 * h,
4303 0, .5 * h));
4304 fig.add(new go.PathSegment(go.PathSegment.Line, .7 * w, 0));
4305 fig.add(new go.PathSegment(go.PathSegment.Bezier, .7 * w, h, .4 * w, .5 * h,
4306 w, .5 * h).close());
4307 const fig2 = new go.PathFigure(.45 * w, .73 * h, false);
4308 geo.add(fig2);
4309 // Lines on script
4310 fig2.add(new go.PathSegment(go.PathSegment.Line, .7 * w, .73 * h));
4311 fig2.add(new go.PathSegment(go.PathSegment.Move, .38 * w, .5 * h));
4312 fig2.add(new go.PathSegment(go.PathSegment.Line, .63 * w, .5 * h));
4313 fig2.add(new go.PathSegment(go.PathSegment.Move, .31 * w, .27 * h));
4314 fig2.add(new go.PathSegment(go.PathSegment.Line, .56 * w, .27 * h));
4315 return geo;
4316});
4317
4318go.Shape.defineFigureGenerator('BpmnTaskUser', (shape, w, h) => {
4319 const geo = new go.Geometry();
4320 const fig = new go.PathFigure(0, 0, false);
4321 geo.add(fig);
4322
4323 const fig2 = new go.PathFigure(.335 * w, (1 - .555) * h, true);
4324 geo.add(fig2);
4325 // Shirt
4326 fig2.add(new go.PathSegment(go.PathSegment.Line, .335 * w, (1 - .405) * h));
4327 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - .335) * w, (1 - .405) * h));
4328 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - .335) * w, (1 - .555) * h));
4329 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w, .68 * h, (1 - .12) * w, .46 * h,
4330 (1 - .02) * w, .54 * h));
4331 fig2.add(new go.PathSegment(go.PathSegment.Line, w, h));
4332 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4333 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, .68 * h));
4334 fig2.add(new go.PathSegment(go.PathSegment.Bezier, .335 * w, (1 - .555) * h, .02 * w, .54 * h,
4335 .12 * w, .46 * h));
4336 // Start of neck
4337 fig2.add(new go.PathSegment(go.PathSegment.Line, .365 * w, (1 - .595) * h));
4338 const radiushead = .5 - .285;
4339 const centerx = .5;
4340 const centery = radiushead;
4341 const alpha2 = Math.PI / 4;
4342 const KAPPA2 = ((4 * (1 - Math.cos(alpha2))) / (3 * Math.sin(alpha2)));
4343 const cpOffset = KAPPA2 * .5;
4344 const radiusw = radiushead;
4345 const radiush = radiushead;
4346 const offsetw = KAPPA2 * radiusw;
4347 const offseth = KAPPA2 * radiush;
4348 // Circle (head)
4349 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radiusw) * w, centery * h, (centerx - ((offsetw + radiusw) / 2)) * w, (centery + ((radiush + offseth) / 2)) * h,
4350 (centerx - radiusw) * w, (centery + offseth) * h));
4351 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radiush) * h, (centerx - radiusw) * w, (centery - offseth) * h,
4352 (centerx - offsetw) * w, (centery - radiush) * h));
4353 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radiusw) * w, centery * h, (centerx + offsetw) * w, (centery - radiush) * h,
4354 (centerx + radiusw) * w, (centery - offseth) * h));
4355 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (1 - .365) * w, (1 - .595) * h, (centerx + radiusw) * w, (centery + offseth) * h,
4356 (centerx + ((offsetw + radiusw) / 2)) * w, (centery + ((radiush + offseth) / 2)) * h));
4357 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - .365) * w, (1 - .595) * h));
4358 // Neckline
4359 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - .335) * w, (1 - .555) * h));
4360 fig2.add(new go.PathSegment(go.PathSegment.Line, (1 - .335) * w, (1 - .405) * h));
4361 fig2.add(new go.PathSegment(go.PathSegment.Line, .335 * w, (1 - .405) * h));
4362 const fig3 = new go.PathFigure(.2 * w, h, false);
4363 geo.add(fig3);
4364 // Arm lines
4365 fig3.add(new go.PathSegment(go.PathSegment.Line, .2 * w, .8 * h));
4366 const fig4 = new go.PathFigure(.8 * w, h, false);
4367 geo.add(fig4);
4368 fig4.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .8 * h));
4369 return geo;
4370});
4371
4372go.Shape.defineFigureGenerator('BpmnEventConditional', (shape, w, h) => {
4373 const geo = new go.Geometry();
4374 const fig = new go.PathFigure(.1 * w, 0, true);
4375 geo.add(fig);
4376
4377 // Body
4378 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, 0));
4379 fig.add(new go.PathSegment(go.PathSegment.Line, .9 * w, h));
4380 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, h).close());
4381 const fig2 = new go.PathFigure(.2 * w, .2 * h, false);
4382 geo.add(fig2);
4383 // Inside lines
4384 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .2 * h));
4385 fig2.add(new go.PathSegment(go.PathSegment.Move, .2 * w, .4 * h));
4386 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .4 * h));
4387 fig2.add(new go.PathSegment(go.PathSegment.Move, .2 * w, .6 * h));
4388 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .6 * h));
4389 fig2.add(new go.PathSegment(go.PathSegment.Move, .2 * w, .8 * h));
4390 fig2.add(new go.PathSegment(go.PathSegment.Line, .8 * w, .8 * h));
4391 return geo;
4392});
4393
4394go.Shape.defineFigureGenerator('BpmnEventError', (shape, w, h) => {
4395 const geo = new go.Geometry();
4396 const fig = new go.PathFigure(0, h, true);
4397 geo.add(fig);
4398
4399 fig.add(new go.PathSegment(go.PathSegment.Line, .33 * w, 0));
4400 fig.add(new go.PathSegment(go.PathSegment.Line, .66 * w, .50 * h));
4401 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4402 fig.add(new go.PathSegment(go.PathSegment.Line, .66 * w, h));
4403 fig.add(new go.PathSegment(go.PathSegment.Line, .33 * w, .50 * h).close());
4404 return geo;
4405});
4406
4407go.Shape.defineFigureGenerator('BpmnEventEscalation', (shape, w, h) => {
4408 const geo = new go.Geometry();
4409 const fig = new go.PathFigure(0, 0, false);
4410 geo.add(fig);
4411 // Set dimensions
4412 const fig2 = new go.PathFigure(w, h, false);
4413 geo.add(fig2);
4414 const fig3 = new go.PathFigure(.1 * w, h, true);
4415 geo.add(fig3);
4416 fig3.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0));
4417 fig3.add(new go.PathSegment(go.PathSegment.Line, .9 * w, h));
4418 fig3.add(new go.PathSegment(go.PathSegment.Line, .5 * w, .5 * h).close());
4419 return geo;
4420});
4421
4422go.Shape.defineFigureGenerator('Caution', (shape, w, h) => {
4423 const geo = new go.Geometry();
4424 const fig = new go.PathFigure(0.05 * w, h, true);
4425 geo.add(fig);
4426 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.1 * w, .8 * h, 0, h, 0, h));
4427 fig.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, .1 * h));
4428 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.55 * w, .1 * h, 0.5 * w, 0, 0.5 * w, 0));
4429 fig.add(new go.PathSegment(go.PathSegment.Line, 0.95 * w, 0.9 * h));
4430 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.9 * w, h, w, h, w, h));
4431 fig.add(new go.PathSegment(go.PathSegment.Line, 0.05 * w, h));
4432 const radius = 0.05;
4433 // Bottom circle of exclamation point
4434 fig.add(new go.PathSegment(go.PathSegment.Move, (0.5 - radius) * w, 0.875 * h));
4435 fig.add(new go.PathSegment(go.PathSegment.Arc, 180, -360, 0.5 * w, 0.875 * h, radius * w, radius * h));
4436 // Upper rectangle of exclamation point
4437 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.75 * h));
4438 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.325 * h, 0.575 * w, 0.725 * h, 0.625 * w, 0.375 * h));
4439 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.75 * h, 0.375 * w, 0.375 * h, 0.425 * w, 0.725 * h));
4440 return geo;
4441});
4442
4443go.Shape.defineFigureGenerator('Recycle', (shape, w, h) => {
4444 const geo = new go.Geometry();
4445 const fig = new go.PathFigure(0.45 * w, 0.95 * h, false);
4446 geo.add(fig);
4447
4448 // Bottom left arrow
4449 fig.add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, 0.95 * h));
4450 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.185 * w, 0.85 * h, 0.17 * w, 0.95 * h, 0.15 * w, 0.9 * h));
4451 fig.add(new go.PathSegment(go.PathSegment.Line, 0.235 * w, 0.75 * h));
4452 fig.add(new go.PathSegment(go.PathSegment.Line, 0.30 * w, 0.625 * h));
4453 fig.add(new go.PathSegment(go.PathSegment.Line, 0.35 * w, 0.65 * h));
4454 fig.add(new go.PathSegment(go.PathSegment.Line, 0.275 * w, 0.45 * h));
4455 fig.add(new go.PathSegment(go.PathSegment.Line, 0.05 * w, 0.45 * h));
4456 fig.add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0.5 * h));
4457 fig.add(new go.PathSegment(go.PathSegment.Line, 0.05 * w, 0.575 * h));
4458 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.1875 * w, 0.95 * h, 0, 0.675 * h, 0, 0.7 * h));
4459 fig.add(new go.PathSegment(go.PathSegment.Move, 0.45 * w, 0.95 * h));
4460 fig.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.775 * h));
4461 fig.add(new go.PathSegment(go.PathSegment.Line, 0.22 * w, 0.775 * h));
4462 const fig2 = new go.PathFigure(0.475 * w, 0.2 * h, false);
4463 geo.add(fig2);
4464 // Top arrow
4465 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0.4 * h));
4466 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.225 * w, 0.3 * h));
4467 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.275 * w, 0.175 * h));
4468 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.325 * w, 0.05 * h));
4469 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0.4 * w, 0.05 * h, 0.35 * w, 0, 0.375 * w, 0));
4470 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.575 * w, 0.375 * h));
4471 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.525 * w, 0.4 * h));
4472 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0.475 * h));
4473 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.85 * w, 0.315 * h));
4474 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.32 * h));
4475 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, 0.05 * h));
4476 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0.575 * w, 0, 0.65 * w, 0.05 * h, 0.625 * w, 0));
4477 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.38 * w, 0.0105 * h));
4478 const fig3 = new go.PathFigure(0.675 * w, 0.575 * h, false);
4479 geo.add(fig3);
4480 // Bottom right arrow
4481 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.875 * w, 0.525 * h));
4482 fig3.add(new go.PathSegment(go.PathSegment.Line, w, 0.775 * h));
4483 fig3.add(new go.PathSegment(go.PathSegment.Bezier, 0.85 * w, 0.95 * h, w, 0.8 * h, w, 0.85 * h));
4484 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, 0.95 * h));
4485 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, h));
4486 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, 0.85 * h));
4487 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, 0.725 * h));
4488 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, 0.775 * h));
4489 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.7 * w, 0.775 * h));
4490 fig3.add(new go.PathSegment(go.PathSegment.Line, w, 0.775 * h));
4491 fig3.add(new go.PathSegment(go.PathSegment.Move, 0.675 * w, 0.575 * h));
4492 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.775 * w, 0.775 * h));
4493 return geo;
4494});
4495
4496go.Shape.defineFigureGenerator('BpmnEventTimer', (shape, w, h) => {
4497 const geo = new go.Geometry();
4498 const radius = .5;
4499 const cpOffset = KAPPA * .5;
4500 const fig = new go.PathFigure(w, radius * h, true);
4501 geo.add(fig);
4502
4503 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, h, w, (radius + cpOffset) * h,
4504 (radius + cpOffset) * w, h));
4505 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, radius * h, (radius - cpOffset) * w, h,
4506 0, (radius + cpOffset) * h));
4507 fig.add(new go.PathSegment(go.PathSegment.Bezier, radius * w, 0, 0, (radius - cpOffset) * h,
4508 (radius - cpOffset) * w, 0));
4509 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, radius * h, (radius + cpOffset) * w, 0,
4510 w, (radius - cpOffset) * h));
4511 const fig2 = new go.PathFigure(radius * w, 0, false);
4512 geo.add(fig2);
4513 // Hour lines
4514 fig2.add(new go.PathSegment(go.PathSegment.Line, radius * w, .15 * h));
4515 fig2.add(new go.PathSegment(go.PathSegment.Move, radius * w, h));
4516 fig2.add(new go.PathSegment(go.PathSegment.Line, radius * w, .85 * h));
4517 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, radius * h));
4518 fig2.add(new go.PathSegment(go.PathSegment.Line, .15 * w, radius * h));
4519 fig2.add(new go.PathSegment(go.PathSegment.Move, w, radius * h));
4520 fig2.add(new go.PathSegment(go.PathSegment.Line, .85 * w, radius * h));
4521 // Clock hands
4522 fig2.add(new go.PathSegment(go.PathSegment.Move, radius * w, radius * h));
4523 fig2.add(new go.PathSegment(go.PathSegment.Line, .58 * w, 0.1 * h));
4524 fig2.add(new go.PathSegment(go.PathSegment.Move, radius * w, radius * h));
4525 fig2.add(new go.PathSegment(go.PathSegment.Line, .78 * w, .54 * h));
4526 return geo;
4527});
4528
4529go.Shape.defineFigureGenerator('Package', (shape, w, h) => {
4530 const geo = new go.Geometry();
4531 const fig = new go.PathFigure(0, 0.15 * h, true);
4532 geo.add(fig);
4533
4534 // Package bottom rectangle
4535 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.15 * h));
4536 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4537 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
4538 const fig2 = new go.PathFigure(0, 0.15 * h, true);
4539 geo.add(fig2);
4540 // Package top flap
4541 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
4542 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0));
4543 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, 0.15 * h).close());
4544 geo.spot1 = new go.Spot(0, 0.1);
4545 geo.spot2 = new go.Spot(1, 1);
4546 return geo;
4547});
4548
4549go.Shape.defineFigureGenerator('Class', (shape, w, h) => {
4550 const geo = new go.Geometry();
4551 const fig = new go.PathFigure(0, 0, true);
4552 geo.add(fig);
4553
4554 // Class box
4555 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4556 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4557 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4558 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0).close());
4559 const fig2 = new go.PathFigure(0, 0.2 * h, false);
4560 geo.add(fig2);
4561 // Top box separater
4562 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0.2 * h).close());
4563 const fig3 = new go.PathFigure(0, 0.5 * h, false);
4564 geo.add(fig3);
4565 // Middle box separater
4566 fig3.add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h).close());
4567 return geo;
4568});
4569
4570go.Shape.defineFigureGenerator('Component', (shape, w, h) => {
4571 const geo = new go.Geometry();
4572 const fig = new go.PathFigure(w, h, true);
4573 geo.add(fig);
4574
4575 // Component Box
4576 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4577 fig.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, 0));
4578 fig.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, h));
4579 fig.add(new go.PathSegment(go.PathSegment.Line, w, h).close());
4580 const fig2 = new go.PathFigure(0, 0.2 * h, true);
4581 geo.add(fig2);
4582 // Component top sub box
4583 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.2 * h));
4584 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.4 * h));
4585 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, 0.4 * h));
4586 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, 0.2 * h).close());
4587 const fig3 = new go.PathFigure(0, 0.6 * h, true);
4588 geo.add(fig3);
4589 // Component bottom sub box
4590 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.6 * h));
4591 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.8 * h));
4592 fig3.add(new go.PathSegment(go.PathSegment.Line, 0, 0.8 * h));
4593 fig3.add(new go.PathSegment(go.PathSegment.Line, 0, 0.6 * h).close());
4594 return geo;
4595});
4596
4597go.Shape.defineFigureGenerator('Boat Shipment', (shape, w, h) => {
4598 const geo = new go.Geometry();
4599 const fig = new go.PathFigure(0.15 * w, 0.6 * h, true);
4600 geo.add(fig);
4601
4602 // Boat shipment flag
4603 fig.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, 0.6 * h));
4604 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.6 * h));
4605 fig.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, h));
4606 fig.add(new go.PathSegment(go.PathSegment.Line, 0.85 * w, h));
4607 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.6 * h));
4608 fig.add(new go.PathSegment(go.PathSegment.Line, 0.85 * w, 0.6 * h));
4609 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0));
4610 fig.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, 0.6 * h));
4611 const fig2 = new go.PathFigure(0.15 * w, 0.6 * h, false);
4612 geo.add(fig2);
4613 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.85 * w, 0.6 * h));
4614 return geo;
4615});
4616
4617go.Shape.defineFigureGenerator('Customer/Supplier', (shape, w, h) => {
4618 const geo = new go.Geometry();
4619 const fig = new go.PathFigure(w, h, true);
4620 geo.add(fig);
4621
4622 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4623 fig.add(new go.PathSegment(go.PathSegment.Line, 0.66 * w, 0.33 * h));
4624 fig.add(new go.PathSegment(go.PathSegment.Line, 0.66 * w, 0));
4625 fig.add(new go.PathSegment(go.PathSegment.Line, 0.33 * w, 0.33 * h));
4626 fig.add(new go.PathSegment(go.PathSegment.Line, 0.33 * w, 0));
4627 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.33 * h));
4628 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4629 fig.add(new go.PathSegment(go.PathSegment.Line, w, h).close());
4630 return geo;
4631});
4632
4633go.Shape.defineFigureGenerator('Workcell', (shape, w, h) => {
4634 const geo = new go.Geometry();
4635 const fig = new go.PathFigure(0, h, true);
4636 geo.add(fig);
4637
4638 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
4639 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4640 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4641 fig.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, h));
4642 fig.add(new go.PathSegment(go.PathSegment.Line, 0.65 * w, 0.4 * h));
4643 fig.add(new go.PathSegment(go.PathSegment.Line, 0.35 * w, 0.4 * h));
4644 fig.add(new go.PathSegment(go.PathSegment.Line, 0.35 * w, h));
4645 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
4646 return geo;
4647});
4648
4649go.Shape.defineFigureGenerator('Supermarket', (shape, w, h) => {
4650 const geo = new go.Geometry();
4651 const fig = new go.PathFigure(0, 0, false);
4652 geo.add(fig);
4653
4654 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4655 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.33 * h));
4656 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.33 * h));
4657 fig.add(new go.PathSegment(go.PathSegment.Move, w, 0.33 * h));
4658 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.66 * h));
4659 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.66 * h));
4660 fig.add(new go.PathSegment(go.PathSegment.Move, w, 0.66 * h));
4661 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4662 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4663 return geo;
4664});
4665
4666go.Shape.defineFigureGenerator('TruckShipment', (shape, w, h) => {
4667 const geo = new go.Geometry();
4668 const fig = new go.PathFigure(0, 0, true);
4669 geo.add(fig);
4670
4671 // Left rectangle
4672 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0));
4673 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.8 * h));
4674 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.8 * h));
4675 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0).close());
4676 const fig2 = new go.PathFigure(w, 0.8 * h, true);
4677 geo.add(fig2);
4678 // Right rectangle
4679 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0.4 * h));
4680 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.4 * h));
4681 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.8 * h));
4682 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0.8 * h).close());
4683 let radius = .1;
4684 let cpOffset = KAPPA * .1;
4685 let centerx = .2;
4686 let centery = .9;
4687 const fig3 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4688 geo.add(fig3);
4689 // Left wheel
4690 fig3.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4691 (centerx - cpOffset) * w, (centery - radius) * h));
4692 fig3.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4693 (centerx + radius) * w, (centery - cpOffset) * h));
4694 fig3.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4695 (centerx + cpOffset) * w, (centery + radius) * h));
4696 fig3.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4697 (centerx - radius) * w, (centery + cpOffset) * h).close());
4698 radius = .1;
4699 cpOffset = KAPPA * .1;
4700 centerx = .8;
4701 centery = .9;
4702 const fig4 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4703 geo.add(fig4);
4704 // Right wheel
4705 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4706 (centerx - cpOffset) * w, (centery - radius) * h));
4707 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4708 (centerx + radius) * w, (centery - cpOffset) * h));
4709 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4710 (centerx + cpOffset) * w, (centery + radius) * h));
4711 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4712 (centerx - radius) * w, (centery + cpOffset) * h).close());
4713 return geo;
4714});
4715
4716go.Shape.defineFigureGenerator('KanbanPost', (shape, w, h) => {
4717 const geo = new go.Geometry();
4718 const fig = new go.PathFigure(0.2 * w, 0, false);
4719 geo.add(fig);
4720
4721 fig.add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, .5 * h));
4722 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.5 * h));
4723 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0));
4724 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.5 * h));
4725 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h));
4726 fig.add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, h));
4727 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, h));
4728 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, h));
4729 return geo;
4730});
4731
4732go.Shape.defineFigureGenerator('Forklift', (shape, w, h) => {
4733 const geo = new go.Geometry();
4734 const fig = new go.PathFigure(0, 0, true);
4735 geo.add(fig);
4736
4737 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.5 * h));
4738 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.5 * h));
4739 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0));
4740 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
4741 const fig2 = new go.PathFigure(0, 0.5 * h, true);
4742 geo.add(fig2);
4743 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, 0.8 * h));
4744 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.8 * h));
4745 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.5 * h));
4746 fig2.add(new go.PathSegment(go.PathSegment.Line, 0, 0.5 * h));
4747 const fig3 = new go.PathFigure(0.50 * w, 0.8 * h, true);
4748 geo.add(fig3);
4749 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.50 * w, 0.1 * h));
4750 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, 0.1 * h));
4751 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, 0.8 * h));
4752 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.50 * w, 0.8 * h));
4753 const fig4 = new go.PathFigure(0.5 * w, 0.7 * h, false);
4754 geo.add(fig4);
4755 fig4.add(new go.PathSegment(go.PathSegment.Line, w, 0.7 * h));
4756 let radius = .1;
4757 let cpOffset = KAPPA * .1;
4758 let centerx = .1;
4759 let centery = .9;
4760 const fig5 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4761 geo.add(fig5);
4762 fig5.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4763 (centerx - cpOffset) * w, (centery - radius) * h));
4764 fig5.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4765 (centerx + radius) * w, (centery - cpOffset) * h));
4766 fig5.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4767 (centerx + cpOffset) * w, (centery + radius) * h));
4768 fig5.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4769 (centerx - radius) * w, (centery + cpOffset) * h));
4770 radius = .1;
4771 cpOffset = KAPPA * .1;
4772 centerx = .4;
4773 centery = .9;
4774 const fig6 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4775 geo.add(fig6);
4776 fig6.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4777 (centerx - cpOffset) * w, (centery - radius) * h));
4778 fig6.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4779 (centerx + radius) * w, (centery - cpOffset) * h));
4780 fig6.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4781 (centerx + cpOffset) * w, (centery + radius) * h));
4782 fig6.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4783 (centerx - radius) * w, (centery + cpOffset) * h));
4784 return geo;
4785});
4786
4787go.Shape.defineFigureGenerator('RailShipment', (shape, w, h) => {
4788 const geo = new go.Geometry();
4789 const fig = new go.PathFigure(0.1 * w, 0.4 * h, true);
4790 geo.add(fig);
4791
4792 // Left cart
4793 fig.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.4 * h));
4794 fig.add(new go.PathSegment(go.PathSegment.Line, 0.45 * w, 0.9 * h));
4795 fig.add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0.9 * h));
4796 fig.add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0.4 * h).close());
4797 const fig2 = new go.PathFigure(0.45 * w, 0.7 * h, false);
4798 geo.add(fig2);
4799 // Line connecting carts
4800 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, 0.7 * h));
4801 const fig3 = new go.PathFigure(0.55 * w, 0.4 * h, true);
4802 geo.add(fig3);
4803 // Right cart
4804 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.4 * h));
4805 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.9 * h));
4806 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, 0.9 * h));
4807 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, 0.4 * h).close());
4808 let radius = .05;
4809 let cpOffset = KAPPA * .05;
4810 let centerx = .175;
4811 let centery = .95;
4812 const fig4 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4813 geo.add(fig4);
4814 // Wheels
4815 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4816 (centerx - cpOffset) * w, (centery - radius) * h));
4817 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4818 (centerx + radius) * w, (centery - cpOffset) * h));
4819 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4820 (centerx + cpOffset) * w, (centery + radius) * h));
4821 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4822 (centerx - radius) * w, (centery + cpOffset) * h));
4823 radius = .05;
4824 cpOffset = KAPPA * .05;
4825 centerx = .375;
4826 centery = .95;
4827 const fig5 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4828 geo.add(fig5);
4829 fig5.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4830 (centerx - cpOffset) * w, (centery - radius) * h));
4831 fig5.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4832 (centerx + radius) * w, (centery - cpOffset) * h));
4833 fig5.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4834 (centerx + cpOffset) * w, (centery + radius) * h));
4835 fig5.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4836 (centerx - radius) * w, (centery + cpOffset) * h));
4837 radius = .05;
4838 cpOffset = KAPPA * .05;
4839 centerx = .625;
4840 centery = .95;
4841 const fig6 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4842 geo.add(fig6);
4843 fig6.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4844 (centerx - cpOffset) * w, (centery - radius) * h));
4845 fig6.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4846 (centerx + radius) * w, (centery - cpOffset) * h));
4847 fig6.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4848 (centerx + cpOffset) * w, (centery + radius) * h));
4849 fig6.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4850 (centerx - radius) * w, (centery + cpOffset) * h));
4851 radius = .05;
4852 cpOffset = KAPPA * .05;
4853 centerx = .825;
4854 centery = .95;
4855 const fig7 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4856 geo.add(fig7);
4857 fig7.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4858 (centerx - cpOffset) * w, (centery - radius) * h));
4859 fig7.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4860 (centerx + radius) * w, (centery - cpOffset) * h));
4861 fig7.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4862 (centerx + cpOffset) * w, (centery + radius) * h));
4863 fig7.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4864 (centerx - radius) * w, (centery + cpOffset) * h).close());
4865 const fig8 = new go.PathFigure(0, h, false);
4866 geo.add(fig8);
4867 fig8.add(new go.PathSegment(go.PathSegment.Line, w, h).close());
4868 return geo;
4869});
4870
4871go.Shape.defineFigureGenerator('Warehouse', (shape, w, h) => {
4872 const geo = new go.Geometry();
4873 const fig = new go.PathFigure(0, 0, true);
4874 geo.add(fig);
4875
4876 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4877 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4878 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4879 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0).close());
4880 const fig2 = new go.PathFigure(0, 0.2 * h, false);
4881 geo.add(fig2);
4882 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0.2 * h).close());
4883 const fig3 = new go.PathFigure(0.15 * w, h, true);
4884 geo.add(fig3);
4885 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, 0.5 * h));
4886 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.40 * w, 0.5 * h));
4887 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.40 * w, h));
4888 fig3.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, h).close());
4889 const radius = .05;
4890 const cpOffset = KAPPA * .05;
4891 const centerx = .35;
4892 const centery = .775;
4893 const fig4 = new go.PathFigure((centerx - radius) * w, centery * h, true);
4894 geo.add(fig4);
4895 // Door handle
4896 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
4897 (centerx - cpOffset) * w, (centery - radius) * h));
4898 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
4899 (centerx + radius) * w, (centery - cpOffset) * h));
4900 fig4.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
4901 (centerx + cpOffset) * w, (centery + radius) * h));
4902 fig4.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
4903 (centerx - radius) * w, (centery + cpOffset) * h).close());
4904 return geo;
4905});
4906
4907go.Shape.defineFigureGenerator('ControlCenter', (shape, w, h) => {
4908 const geo = new go.Geometry();
4909 const fig = new go.PathFigure(0, h, true);
4910 geo.add(fig);
4911
4912 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.8 * h));
4913 fig.add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0.8 * h));
4914 fig.add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0));
4915 fig.add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0));
4916 fig.add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.8 * h));
4917 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.8 * h));
4918 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4919 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4920 fig.add(new go.PathSegment(go.PathSegment.Move, 0.1 * w, 0.8 * h));
4921 fig.add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.8 * h).close());
4922 return geo;
4923});
4924
4925go.Shape.defineFigureGenerator('Bluetooth', (shape, w, h) => {
4926 const geo = new go.Geometry();
4927 const fig = new go.PathFigure(0, 0.75 * h, false);
4928 geo.add(fig);
4929
4930 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.75 * h));
4931 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.25 * h));
4932 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0));
4933 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h));
4934 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.75 * h));
4935 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.25 * h));
4936 return geo;
4937});
4938
4939go.Shape.defineFigureGenerator('Bookmark', (shape, w, h) => {
4940 const geo = new go.Geometry();
4941 const fig = new go.PathFigure(0, 0, true);
4942 geo.add(fig);
4943
4944 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4945 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.6 * h));
4946 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4947 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4948 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
4949 fig.add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.2 * h));
4950 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.2 * h));
4951 fig.add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.4 * h));
4952 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.4 * h));
4953 return geo;
4954});
4955
4956go.Shape.defineFigureGenerator('Bookmark', (shape, w, h) => {
4957 const geo = new go.Geometry();
4958 const fig = new go.PathFigure(0, 0, true);
4959 geo.add(fig);
4960
4961 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
4962 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.6 * h));
4963 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
4964 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
4965 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0));
4966 fig.add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.2 * h));
4967 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.2 * h));
4968 fig.add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.4 * h));
4969 fig.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.4 * h));
4970 return geo;
4971});
4972
4973go.Shape.defineFigureGenerator('Globe', (shape, w, h) => {
4974 const geo = new go.Geometry();
4975 const fig = new go.PathFigure(0.5 * w, 0, false);
4976 geo.add(fig);
4977
4978 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h));
4979 fig.add(new go.PathSegment(go.PathSegment.Move, 0, 0.5 * h));
4980 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h));
4981 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0));
4982 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, 0.5 * h, 0.75 * w, 0, w, 0.25 * h));
4983 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, h, w, 0.75 * h, 0.75 * w, h));
4984 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0.5 * h, 0.25 * w, h, 0, 0.75 * h));
4985 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0, 0, 0.25 * h, 0.25 * w, 0));
4986 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, h, 0.15 * w, 0.25 * h, 0.15 * w, 0.75 * h));
4987 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0, 0.85 * w, 0.75 * h, 0.85 * w, 0.25 * h));
4988 fig.add(new go.PathSegment(go.PathSegment.Move, 0.1675 * w, 0.15 * h));
4989 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.8325 * w, 0.15 * h, 0.35 * w, 0.3 * h, 0.65 * w, 0.3 * h));
4990 fig.add(new go.PathSegment(go.PathSegment.Move, 0.1675 * w, 0.85 * h));
4991 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.8325 * w, 0.85 * h, 0.35 * w, 0.7 * h, 0.65 * w, 0.7 * h));
4992 return geo;
4993});
4994
4995go.Shape.defineFigureGenerator('Wave', (shape, w, h) => {
4996 const geo = new go.Geometry();
4997 const fig = new go.PathFigure(0, 0.25 * h, false);
4998 geo.add(fig);
4999
5000 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.3 * w, 0.25 * h, 0.10 * w, 0, 0.2 * w, 0));
5001 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.7 * w, 0.25 * h, 0.425 * w, 0.5 * h, 0.575 * w, 0.5 * h));
5002 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, 0.25 * h, 0.8 * w, 0, 0.9 * w, 0));
5003 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.75 * h));
5004 fig.add(new go.PathSegment(go.PathSegment.Move, 0, 0.25 * h));
5005 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.75 * h));
5006 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.3 * w, 0.75 * h, 0.10 * w, 0.5 * h, 0.2 * w, 0.5 * h));
5007 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.7 * w, 0.75 * h, 0.425 * w, h, 0.575 * w, h));
5008 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, 0.75 * h, 0.8 * w, 0.5 * h, 0.9 * w, 0.5 * h));
5009 return geo;
5010});
5011
5012go.Shape.defineFigureGenerator('Operator', (shape, w, h) => {
5013 const geo = new go.Geometry();
5014 const radius = .3;
5015 const cpOffset = KAPPA * .3;
5016 const centerx = .5;
5017 const centery = .7;
5018 const fig = new go.PathFigure((centerx - radius) * w, centery * h, true);
5019 geo.add(fig);
5020
5021 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
5022 (centerx - cpOffset) * w, (centery - radius) * h));
5023 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
5024 (centerx + radius) * w, (centery - cpOffset) * h));
5025 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
5026 (centerx + cpOffset) * w, (centery + radius) * h));
5027 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
5028 (centerx - radius) * w, (centery + cpOffset) * h));
5029 const fig2 = new go.PathFigure(0, 0.7 * h, false);
5030 geo.add(fig2);
5031 fig2.add(new go.PathSegment(go.PathSegment.Bezier, w, 0.7 * h, 0, 0, w, 0));
5032 return geo;
5033});
5034
5035go.Shape.defineFigureGenerator('TripleFanBlades', (shape, w, h) => {
5036 const geo = new go.Geometry();
5037 const fig = new go.PathFigure(0.5 * w, 0, true);
5038 geo.add(fig);
5039
5040 // Top blade
5041 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.65 * h, 0.65 * w, 0.3 * h, 0.65 * w, 0.5 * h));
5042 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0, 0.35 * w, 0.5 * h, 0.35 * w, 0.3 * h));
5043 // Bottom left blade
5044 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.65 * h));
5045 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h, 0.3 * w, 0.6 * h, 0.1 * w, 0.8 * h));
5046 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.65 * h, 0.2 * w, h, 0.35 * w, 0.95 * h));
5047 // Bottom right blade
5048 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.65 * h));
5049 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, h, 0.7 * w, 0.6 * h, 0.9 * w, 0.8 * h));
5050 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.65 * h, 0.8 * w, h, 0.65 * w, 0.95 * h));
5051 return geo;
5052});
5053
5054go.Shape.defineFigureGenerator('CentrifugalPump', (shape, w, h) => {
5055 const geo = new go.Geometry();
5056 const fig = new go.PathFigure(w, 0, true);
5057 geo.add(fig);
5058
5059 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0));
5060 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0.5 * h, 0, 0.075 * h, 0, 0.5 * h));
5061 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.4 * w, h, 0, h, 0.4 * w, h));
5062 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.8 * w, 0.4 * h, 0.8 * w, h, 0.85 * w, 0.6 * h));
5063 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.4 * h));
5064 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0));
5065 return geo;
5066});
5067
5068go.Shape.defineFigureGenerator('Battery', (shape, w, h) => {
5069 const geo = new go.Geometry();
5070 const fig = new go.PathFigure(0, h, true);
5071 geo.add(fig);
5072
5073 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.1 * h));
5074 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.1 * h));
5075 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
5076 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
5077 fig.add(new go.PathSegment(go.PathSegment.Move, 0.4 * w, 0.1 * h));
5078 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0));
5079 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0));
5080 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.1 * h));
5081 const fig2 = new go.PathFigure(0, 0.6 * h, false);
5082 geo.add(fig2);
5083 fig2.add(new go.PathSegment(go.PathSegment.Move, 0, 0.4 * h));
5084 fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0.4 * h));
5085 return geo;
5086});
5087
5088go.Shape.defineFigureGenerator('Delete', (shape, w, h) => {
5089 const geo = new go.Geometry();
5090 const radius = .5;
5091 const cpOffset = KAPPA * .5;
5092 const centerx = .5;
5093 const centery = .5;
5094 const fig = new go.PathFigure((centerx - radius) * w, centery * h, true);
5095 geo.add(fig);
5096
5097 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
5098 (centerx - cpOffset) * w, (centery - radius) * h));
5099 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
5100 (centerx + radius) * w, (centery - cpOffset) * h));
5101 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
5102 (centerx + cpOffset) * w, (centery + radius) * h));
5103 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
5104 (centerx - radius) * w, (centery + cpOffset) * h));
5105 const fig2 = new go.PathFigure(0.15 * w, 0.5 * h, false);
5106 geo.add(fig2);
5107 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.85 * w, 0.5 * h));
5108 return geo;
5109});
5110
5111go.Shape.defineFigureGenerator('Flag', (shape, w, h) => {
5112 const geo = new go.Geometry();
5113 const fig = new go.PathFigure(0, 0.1 * h, true);
5114 geo.add(fig);
5115
5116 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
5117 fig.add(new go.PathSegment(go.PathSegment.Move, 0, 0.1 * h));
5118 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.1 * h, 0.15 * w, 0, 0.35 * w, 0));
5119 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, 0.1 * h, 0.65 * w, 0.2 * h, 0.85 * w, 0.2 * h));
5120 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h));
5121 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.5 * h, 0.85 * w, 0.6 * h, 0.65 * w, 0.6 * h));
5122 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0.5 * h, 0.35 * w, 0.4 * h, 0.15 * w, 0.4 * h).close());
5123 return geo;
5124});
5125
5126go.Shape.defineFigureGenerator('Help', (shape, w, h) => {
5127 const geo = new go.Geometry();
5128 let radius = .5;
5129 let cpOffset = KAPPA * .5;
5130 let centerx = .5;
5131 let centery = .5;
5132 const fig = new go.PathFigure((centerx - radius) * w, centery * h, false);
5133 geo.add(fig);
5134
5135 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
5136 (centerx - cpOffset) * w, (centery - radius) * h));
5137 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
5138 (centerx + radius) * w, (centery - cpOffset) * h));
5139 fig.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
5140 (centerx + cpOffset) * w, (centery + radius) * h));
5141 fig.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
5142 (centerx - radius) * w, (centery + cpOffset) * h).close());
5143 radius = .05;
5144 cpOffset = KAPPA * .05;
5145 centerx = .5;
5146 centery = .8;
5147 const fig2 = new go.PathFigure((centerx - radius) * w, centery * h, false);
5148 geo.add(fig2);
5149 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery - radius) * h, (centerx - radius) * w, (centery - cpOffset) * h,
5150 (centerx - cpOffset) * w, (centery - radius) * h));
5151 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx + radius) * w, centery * h, (centerx + cpOffset) * w, (centery - radius) * h,
5152 (centerx + radius) * w, (centery - cpOffset) * h));
5153 fig2.add(new go.PathSegment(go.PathSegment.Bezier, centerx * w, (centery + radius) * h, (centerx + radius) * w, (centery + cpOffset) * h,
5154 (centerx + cpOffset) * w, (centery + radius) * h));
5155 fig2.add(new go.PathSegment(go.PathSegment.Bezier, (centerx - radius) * w, centery * h, (centerx - cpOffset) * w, (centery + radius) * h,
5156 (centerx - radius) * w, (centery + cpOffset) * h).close());
5157 fig2.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.7 * h));
5158 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.5 * h));
5159 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0.2 * h, 0.75 * w, 0.475 * h, 0.75 * w, 0.225 * h));
5160 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0.3 * w, 0.35 * h, 0.4 * w, 0.2 * h, 0.3 * w, 0.25 * h));
5161 return geo;
5162});
5163
5164go.Shape.defineFigureGenerator('Location', (shape, w, h) => {
5165 return new go.Geometry()
5166 .add(new go.PathFigure(0.5 * w, h, true)
5167 .add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0.5 * h))
5168 .add(new go.PathSegment(go.PathSegment.Bezier, 0.5 * w, 0, .975 * w, 0.025 * h, 0.5 * w, 0))
5169 .add(new go.PathSegment(go.PathSegment.Bezier, 0.25 * w, 0.5 * h, 0.5 * w, 0, 0.025 * w, 0.025 * h).close())
5170 .add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.2 * h))
5171 .add(new go.PathSegment(go.PathSegment.Arc, 270, 360, 0.5 * w, 0.3 * h, 0.1 * w, 0.1 * h).close()));
5172});
5173
5174go.Shape.defineFigureGenerator('Lock', (shape, w, h) => {
5175 const geo = new go.Geometry();
5176 const fig = new go.PathFigure(0, 0.5 * h, true);
5177 geo.add(fig);
5178
5179 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
5180 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
5181 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h));
5182 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.5 * h));
5183 const fig2 = new go.PathFigure(0.2 * w, 0.5 * h, false);
5184 geo.add(fig2);
5185 fig2.add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.5 * h));
5186 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, 0.3 * h));
5187 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0.8 * w, 0.3 * h, 0.25 * w, 0, 0.75 * w, 0));
5188 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.5 * h));
5189 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.3 * h));
5190 return geo;
5191});
5192
5193go.Shape.defineFigureGenerator('Unlocked', (shape, w, h) => {
5194 const geo = new go.Geometry();
5195 const fig = new go.PathFigure(0, 0.5 * h, true);
5196 geo.add(fig);
5197
5198 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h));
5199 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
5200 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.5 * h));
5201 fig.add(new go.PathSegment(go.PathSegment.Line, 0, 0.5 * h));
5202 const fig2 = new go.PathFigure(0.2 * w, 0.5 * h, false);
5203 geo.add(fig2);
5204 fig2.add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.5 * h));
5205 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, 0.3 * h));
5206 fig2.add(new go.PathSegment(go.PathSegment.Bezier, 0.8 * w, 0.3 * h, 0.25 * w, 0, 0.75 * w, 0));
5207 fig2.add(new go.PathSegment(go.PathSegment.Line, 0.8 * w, 0.35 * h));
5208 return geo;
5209});
5210
5211go.Shape.defineFigureGenerator('Gear', (shape, w, h) => {
5212 return new go.Geometry()
5213 .add(new go.PathFigure(0.9375 * w, 0.56246875 * h, true)
5214 .add(new go.PathSegment(go.PathSegment.Line, 0.9375 * w, 0.4375 * h))
5215 .add(new go.PathSegment(go.PathSegment.Line, 0.80621875 * w, 0.4375 * h))
5216 .add(new go.PathSegment(go.PathSegment.Bezier, 0.763 * w, 0.3316875 * h, 0.79840625 * w, 0.39915625 * h, 0.7834375 * w, 0.3635 * h))
5217 .add(new go.PathSegment(go.PathSegment.Line, 0.8566875 * w, 0.23796875 * h))
5218 .add(new go.PathSegment(go.PathSegment.Line, 0.76825 * w, 0.14959375 * h))
5219 .add(new go.PathSegment(go.PathSegment.Line, 0.67596875 * w, 0.24184375 * h))
5220 .add(new go.PathSegment(go.PathSegment.Bezier, 0.5625 * w, 0.19378125 * h, 0.64228125 * w, 0.2188125 * h, 0.603875 * w, 0.2021875 * h))
5221 .add(new go.PathSegment(go.PathSegment.Line, 0.5625 * w, 0.0625 * h))
5222 .add(new go.PathSegment(go.PathSegment.Line, 0.4375 * w, 0.0625 * h))
5223 .add(new go.PathSegment(go.PathSegment.Line, 0.4375 * w, 0.19378125 * h))
5224 .add(new go.PathSegment(go.PathSegment.Bezier, 0.32775 * w, 0.239375 * h, 0.39759375 * w, 0.20190625 * h, 0.36053125 * w, 0.2176875 * h))
5225 .add(new go.PathSegment(go.PathSegment.Line, 0.2379375 * w, 0.14959375 * h))
5226 .add(new go.PathSegment(go.PathSegment.Line, 0.14953125 * w, 0.2379375 * h))
5227 .add(new go.PathSegment(go.PathSegment.Line, 0.23934375 * w, 0.3278125 * h))
5228 .add(new go.PathSegment(go.PathSegment.Bezier, 0.19378125 * w, 0.4375 * h, 0.21765625 * w, 0.36059375 * h, 0.201875 * w, 0.397625 * h))
5229 .add(new go.PathSegment(go.PathSegment.Line, 0.0625 * w, 0.4375 * h))
5230 .add(new go.PathSegment(go.PathSegment.Line, 0.0625 * w, 0.5625 * h))
5231 .add(new go.PathSegment(go.PathSegment.Line, 0.1938125 * w, 0.5625 * h))
5232 .add(new go.PathSegment(go.PathSegment.Bezier, 0.241875 * w, 0.67596875 * h, 0.20221875 * w, 0.603875 * h, 0.21884375 * w, 0.64228125 * h))
5233 .add(new go.PathSegment(go.PathSegment.Line, 0.1495625 * w, 0.76825 * h))
5234 .add(new go.PathSegment(go.PathSegment.Line, 0.238 * w, 0.8566875 * h))
5235 .add(new go.PathSegment(go.PathSegment.Line, 0.3316875 * w, 0.76296875 * h))
5236 .add(new go.PathSegment(go.PathSegment.Bezier, 0.43753125 * w, 0.80621875 * h, 0.36353125 * w, 0.78340625 * h, 0.3991875 * w, 0.79840625 * h))
5237 .add(new go.PathSegment(go.PathSegment.Line, 0.43753125 * w, 0.9375 * h))
5238 .add(new go.PathSegment(go.PathSegment.Line, 0.5625 * w, 0.9375 * h))
5239 .add(new go.PathSegment(go.PathSegment.Line, 0.5625 * w, 0.80621875 * h))
5240 .add(new go.PathSegment(go.PathSegment.Bezier, 0.67225 * w, 0.760625 * h, 0.602375 * w, 0.79809375 * h, 0.63946875 * w, 0.78234375 * h))
5241 .add(new go.PathSegment(go.PathSegment.Line, 0.76828125 * w, 0.8566875 * h))
5242 .add(new go.PathSegment(go.PathSegment.Line, 0.85671875 * w, 0.76825 * h))
5243 .add(new go.PathSegment(go.PathSegment.Line, 0.76065625 * w, 0.67221875 * h))
5244 .add(new go.PathSegment(go.PathSegment.Bezier, 0.80621875 * w, 0.56246875 * h, 0.78234375 * w, 0.63940625 * h, 0.798125 * w, 0.602375 * h))
5245 .add(new go.PathSegment(go.PathSegment.Line, 0.9375 * w, 0.56246875 * h).close())
5246
5247 .add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.6 * h))
5248 .add(new go.PathSegment(go.PathSegment.Arc, 90, 360, 0.5 * w, 0.5 * h, 0.1 * w, 0.1 * h).close()));
5249});
5250
5251go.Shape.defineFigureGenerator('Hand', function(shape, w, h) {
5252 const geo = new go.Geometry();
5253 const fig = new go.PathFigure(0, 0.5 * h, true);
5254 geo.add(fig);
5255
5256 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.1 * w, 0.3 * h, 0, 0.375 * h, 0.05 * w, 0.325 * h));
5257 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.45 * w, 0.075 * h, 0.3 * w, 0.225 * h, 0.4 * w, 0.175 * h));
5258 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.525 * w, 0.075 * h, 0.46 * w, 0.05 * h, 0.525 * w, 0.05 * h));
5259 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.3 * w, 0.4 * h, 0.525 * w, 0.275 * h, 0.475 * w, 0.325 * h));
5260 fig.add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.4 * h));
5261 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.9 * w, 0.55 * h, w, 0.4 * h, w, 0.55 * h));
5262 fig.add(new go.PathSegment(go.PathSegment.Line, 0.425 * w, 0.55 * h));
5263 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.55 * h));
5264 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.6 * w, 0.7 * h, 0.675 * w, 0.55 * h, 0.675 * w, 0.7 * h));
5265 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0.7 * h));
5266 fig.add(new go.PathSegment(go.PathSegment.Line, 0.575 * w, 0.7 * h));
5267 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.575 * w, 0.85 * h, 0.65 * w, 0.7 * h, 0.65 * w, 0.85 * h));
5268 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0.85 * h));
5269 fig.add(new go.PathSegment(go.PathSegment.Line, 0.525 * w, 0.85 * h));
5270 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.535 * w, h, 0.61 * w, 0.85 * h, 0.61 * w, h));
5271 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, 0.9 * h, 0.435 * w, h, 0, h).close());
5272 return geo;
5273});
5274
5275go.Shape.defineFigureGenerator('Map', (shape, w, h) => {
5276 const geo = new go.Geometry();
5277 const fig = new go.PathFigure(0, 0.2 * h, true);
5278 geo.add(fig);
5279
5280 fig.add(new go.PathSegment(go.PathSegment.Line, 0.25 * w, 0));
5281 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.2 * h));
5282 fig.add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0));
5283 fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.2 * h));
5284 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
5285 fig.add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0.8 * h));
5286 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h));
5287 fig.add(new go.PathSegment(go.PathSegment.Line, 0.25 * w, 0.8 * h));
5288 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
5289 fig.add(new go.PathSegment(go.PathSegment.Move, 0.25 * w, 0));
5290 fig.add(new go.PathSegment(go.PathSegment.Line, 0.25 * w, 0.8 * h));
5291 fig.add(new go.PathSegment(go.PathSegment.Move, 0.5 * w, 0.2 * h));
5292 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, h));
5293 fig.add(new go.PathSegment(go.PathSegment.Move, 0.75 * w, 0));
5294 fig.add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0.8 * h));
5295 return geo;
5296});
5297
5298go.Shape.defineFigureGenerator('Eject', (shape, w, h) => {
5299 const geo = new go.Geometry();
5300 const fig = new go.PathFigure(0, h, true);
5301 geo.add(fig);
5302
5303 // bottam rectangle section
5304 fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
5305 fig.add(new go.PathSegment(go.PathSegment.Line, w, h * .7));
5306 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * .7).close());
5307 const fig2 = new go.PathFigure(0, (h * .6), true);
5308 geo.add(fig2);
5309 fig2.add(new go.PathSegment(go.PathSegment.Line, w, (.6 * h)));
5310 fig2.add(new go.PathSegment(go.PathSegment.Line, .5 * w, 0).close());
5311 return geo;
5312});
5313
5314go.Shape.defineFigureGenerator('Pencil', (shape, w, h) => {
5315 return new go.Geometry()
5316 .add(new go.PathFigure(0, 0, true)
5317 .add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, 0.1 * h))
5318 .add(new go.PathSegment(go.PathSegment.Line, w, 0.9 * h))
5319 .add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, h))
5320 .add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0.2 * h).close()));
5321});
5322
5323go.Shape.defineFigureGenerator('Building', (shape, w, h) => {
5324 const geo = new go.Geometry();
5325 const fig = new go.PathFigure(w * 1, h * 1, false);
5326 geo.add(fig);
5327
5328 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * 1)); // bottom part
5329 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * .85));
5330 fig.add(new go.PathSegment(go.PathSegment.Line, .046 * w, h * .85));
5331 fig.add(new go.PathSegment(go.PathSegment.Line, .046 * w, h * .45));
5332 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * .45));
5333 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * .30));
5334 fig.add(new go.PathSegment(go.PathSegment.Line, .046 * w, h * .30));
5335 fig.add(new go.PathSegment(go.PathSegment.Line, .5 * w, h * 0));
5336 fig.add(new go.PathSegment(go.PathSegment.Line, (1 - .046) * w, h * .30));
5337 fig.add(new go.PathSegment(go.PathSegment.Line, w, h * .30));
5338 fig.add(new go.PathSegment(go.PathSegment.Line, w, h * .45));
5339 fig.add(new go.PathSegment(go.PathSegment.Line, (1 - .046) * w, h * .45));
5340 fig.add(new go.PathSegment(go.PathSegment.Line, (1 - .046) * w, h * .85));
5341 fig.add(new go.PathSegment(go.PathSegment.Line, w, h * .85).close());
5342 const fig2 = new go.PathFigure(.126 * w, .85 * h, false); // is filled in our not
5343 geo.add(fig2);
5344 fig2.add(new go.PathSegment(go.PathSegment.Line, .126 * w, .45 * h));
5345 fig2.add(new go.PathSegment(go.PathSegment.Line, .322 * w, .45 * h));
5346 fig2.add(new go.PathSegment(go.PathSegment.Line, .322 * w, .85 * h).close());
5347 const fig3 = new go.PathFigure(.402 * w, .85 * h, false); // is filled in our not
5348 geo.add(fig3);
5349 fig3.add(new go.PathSegment(go.PathSegment.Line, .402 * w, .45 * h));
5350 fig3.add(new go.PathSegment(go.PathSegment.Line, .598 * w, .45 * h));
5351 fig3.add(new go.PathSegment(go.PathSegment.Line, .598 * w, .85 * h).close());
5352 const fig4 = new go.PathFigure(.678 * w, .85 * h, false); // is filled in our not
5353 geo.add(fig4);
5354 fig4.add(new go.PathSegment(go.PathSegment.Line, .678 * w, .45 * h));
5355 fig4.add(new go.PathSegment(go.PathSegment.Line, .874 * w, .45 * h));
5356 fig4.add(new go.PathSegment(go.PathSegment.Line, .874 * w, .85 * h).close());
5357 // the top inner triangle
5358 const fig5 = new go.PathFigure(.5 * w, .1 * h, false); // is filled in our not
5359 geo.add(fig5);
5360 fig5.add(new go.PathSegment(go.PathSegment.Line, (.046 + .15) * w, .30 * h));
5361 fig5.add(new go.PathSegment(go.PathSegment.Line, (1 - (.046 + .15)) * w, .30 * h).close());
5362 return geo;
5363});
5364
5365go.Shape.defineFigureGenerator('Staircase', (shape, w, h) => {
5366 const geo = new go.Geometry();
5367 const fig = new go.PathFigure(0, h * 1, true);
5368 geo.add(fig);
5369
5370 // Bottom part
5371 fig.add(new go.PathSegment(go.PathSegment.Line, w * .20, h * 1)); // bottom left part
5372 fig.add(new go.PathSegment(go.PathSegment.Line, w * .20, h * .80));
5373 fig.add(new go.PathSegment(go.PathSegment.Line, w * .40, h * .80));
5374 fig.add(new go.PathSegment(go.PathSegment.Line, w * .40, h * .60));
5375 fig.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * .60));
5376 fig.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * .40));
5377 fig.add(new go.PathSegment(go.PathSegment.Line, w * .80, h * .40));
5378 fig.add(new go.PathSegment(go.PathSegment.Line, w * .80, h * .20));
5379 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .20));
5380 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .15));
5381 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * .15));
5382 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * .35));
5383 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, h * .35));
5384 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, h * .55));
5385 fig.add(new go.PathSegment(go.PathSegment.Line, w * .35, h * .55));
5386 fig.add(new go.PathSegment(go.PathSegment.Line, w * .35, h * .75));
5387 fig.add(new go.PathSegment(go.PathSegment.Line, w * .15, h * .75));
5388 fig.add(new go.PathSegment(go.PathSegment.Line, w * .15, h * .95));
5389 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * .95).close());
5390 return geo;
5391});
5392
5393go.Shape.defineFigureGenerator('5Bars', (shape, w, h) => {
5394 const geo = new go.Geometry();
5395 const fig = new go.PathFigure(0, h * 1, true); // bottom left
5396 geo.add(fig);
5397
5398 // Width of each bar is .184
5399 // space in between each bar is .2
5400 fig.add(new go.PathSegment(go.PathSegment.Line, w * .184, h * 1)); // bottom left part
5401 fig.add(new go.PathSegment(go.PathSegment.Line, w * .184, h * (1 - .184)).close());
5402 const fig3 = new go.PathFigure(w * .204, h, true); // is filled in our not
5403 geo.add(fig3);
5404 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .204, h * (1 - .184)));
5405 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .388, h * (1 - (.184 * 2))));
5406 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .388, h * 1).close());
5407 const fig4 = new go.PathFigure(w * .408, h, true); // is filled in our not
5408 geo.add(fig4);
5409 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .408, h * (1 - (.184 * 2))));
5410 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .592, h * (1 - (.184 * 3))));
5411 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .592, h * 1).close());
5412 const fig5 = new go.PathFigure(w * .612, h, true); // is filled in our not
5413 geo.add(fig5);
5414 fig5.add(new go.PathSegment(go.PathSegment.Line, w * .612, h * (1 - (.184 * 3))));
5415 fig5.add(new go.PathSegment(go.PathSegment.Line, w * .796, h * (1 - (.184 * 4))));
5416 fig5.add(new go.PathSegment(go.PathSegment.Line, w * .796, h * 1).close());
5417 const fig6 = new go.PathFigure(w * .816, h, true); // is filled in our not
5418 geo.add(fig6);
5419 fig6.add(new go.PathSegment(go.PathSegment.Line, w * .816, h * (1 - (.184 * 4))));
5420 fig6.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * (1 - (.184 * 5))));
5421 fig6.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1).close());
5422 return geo;
5423});
5424
5425// desktop
5426go.Shape.defineFigureGenerator('PC', (shape, w, h) => {
5427 const geo = new go.Geometry();
5428 const fig = new go.PathFigure(0, 0, true); // top right
5429 geo.add(fig);
5430
5431 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * 1));
5432 fig.add(new go.PathSegment(go.PathSegment.Line, w * .3, h * 1));
5433 fig.add(new go.PathSegment(go.PathSegment.Line, w * .3, 0).close());
5434 // Drive looking rectangle 1
5435 const fig2 = new go.PathFigure(w * .055, .07 * h, true); // is filled in our not
5436 geo.add(fig2);
5437 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .245, h * .07));
5438 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .245, h * .1));
5439 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .055, h * .1).close());
5440 // Drive looking rectangle 2
5441 const fig3 = new go.PathFigure(w * .055, .13 * h, true); // is filled in our not
5442 geo.add(fig3);
5443 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .245, h * .13));
5444 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .245, h * .16));
5445 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .055, h * .16).close());
5446 // Drive/cd rom looking rectangle 3
5447 const fig4 = new go.PathFigure(w * .055, .18 * h, true); // is filled in our not
5448 geo.add(fig4);
5449 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .245, h * .18));
5450 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .245, h * .21));
5451 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .055, h * .21).close());
5452 const fig5 = new go.PathFigure(w * 1, 0, true); // is filled in our not
5453 geo.add(fig5);
5454 fig5.add(new go.PathSegment(go.PathSegment.Line, w * .4, 0));
5455 fig5.add(new go.PathSegment(go.PathSegment.Line, w * .4, h * .65));
5456 fig5.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .65).close());
5457 return geo;
5458});
5459
5460go.Shape.defineFigureGenerator('Plane', (shape, w, h) => {
5461 const geo = new go.Geometry();
5462 const fig = new go.PathFigure(0.55 * w, h, true);
5463 geo.add(fig);
5464
5465 fig.add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.6 * h));
5466 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0.7 * h));
5467 fig.add(new go.PathSegment(go.PathSegment.Line, .1 * w, 0.475 * h));
5468 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.35 * w, 0.525 * h, 0, 0.4 * h, 0.225 * w, 0.45 * h));
5469 fig.add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0.475 * h));
5470 fig.add(new go.PathSegment(go.PathSegment.Line, 0.15 * w, 0.35 * h));
5471 fig.add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, 0.325 * h));
5472 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.325 * h));
5473 fig.add(new go.PathSegment(go.PathSegment.Line, 0.85 * w, 0.1 * h));
5474 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0.9 * w, 0.2 * h, 0.975 * w, 0, w, .08 * h));
5475 fig.add(new go.PathSegment(go.PathSegment.Line, 0.7 * w, 0.45 * h));
5476 fig.add(new go.PathSegment(go.PathSegment.Line, 0.6 * w, 0.95 * h));
5477 fig.add(new go.PathSegment(go.PathSegment.Line, 0.55 * w, h).close());
5478 return geo;
5479});
5480
5481go.Shape.defineFigureGenerator('Key', (shape, w, h) => {
5482 const geo = new go.Geometry();
5483 const fig = new go.PathFigure(w * 1, h * .5, true);
5484 geo.add(fig);
5485 fig.add(new go.PathSegment(go.PathSegment.Line, w * .90, .40 * h));
5486 fig.add(new go.PathSegment(go.PathSegment.Line, w * .50, .40 * h));
5487 fig.add(new go.PathSegment(go.PathSegment.Line, w * .50, .35 * h));
5488 fig.add(new go.PathSegment(go.PathSegment.Line, w * .45, .35 * h));
5489 fig.add(new go.PathSegment(go.PathSegment.Line, w * .30, .20 * h));
5490 fig.add(new go.PathSegment(go.PathSegment.Line, w * .15, .20 * h));
5491 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .35 * h));
5492 fig.add(new go.PathSegment(go.PathSegment.Line, 0, .65 * h));
5493 fig.add(new go.PathSegment(go.PathSegment.Line, w * .15, .80 * h));
5494 fig.add(new go.PathSegment(go.PathSegment.Line, w * .30, .80 * h));
5495 fig.add(new go.PathSegment(go.PathSegment.Line, w * .45, .65 * h));
5496 fig.add(new go.PathSegment(go.PathSegment.Line, w * .50, .65 * h));
5497 fig.add(new go.PathSegment(go.PathSegment.Line, w * .50, .6 * h));
5498 fig.add(new go.PathSegment(go.PathSegment.Line, w * .60, .6 * h));
5499 fig.add(new go.PathSegment(go.PathSegment.Line, w * .65, .55 * h));
5500 fig.add(new go.PathSegment(go.PathSegment.Line, w * .70, .6 * h));
5501 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, .55 * h));
5502 fig.add(new go.PathSegment(go.PathSegment.Line, w * .80, .6 * h));
5503 fig.add(new go.PathSegment(go.PathSegment.Line, w * .85, .575 * h));
5504 fig.add(new go.PathSegment(go.PathSegment.Line, w * .9, 0.60 * h).close());
5505 fig.add(new go.PathSegment(go.PathSegment.Move, 0.17 * w, 0.425 * h));
5506 fig.add(new go.PathSegment(go.PathSegment.Arc, 270, 360, 0.17 * w, 0.5 * h, 0.075 * w, 0.075 * h).close());
5507 return geo;
5508});
5509
5510// movie like logo
5511go.Shape.defineFigureGenerator('FilmTape', (shape, w, h) => {
5512 const geo = new go.Geometry();
5513 const fig = new go.PathFigure(0, 0, false);
5514 geo.add(fig);
5515
5516 fig.add(new go.PathSegment(go.PathSegment.Arc, 270, 180, w * 0, w * 0.3, w * 0.055)); // left semi-circle
5517 fig.add(new go.PathSegment(go.PathSegment.Line, 0, h * 1));
5518 fig.add(new go.PathSegment(go.PathSegment.Line, w * .08, h * 1));
5519 fig.add(new go.PathSegment(go.PathSegment.Line, w * .08, h * .95));
5520 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 1), h * .95));
5521 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 1), h * 1));
5522 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 2), h * 1));
5523 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 2), h * .95));
5524 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 3), h * .95));
5525 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 3), h * 1));
5526 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 4), h * 1));
5527 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 4), h * .95));
5528 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 5), h * .95));
5529 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 5), h * 1));
5530 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 6), h * 1));
5531 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 6), h * .95));
5532 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 7), h * .95));
5533 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 7), h * 1));
5534 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 8), h * 1));
5535 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 8), h * .95));
5536 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 9), h * .95));
5537 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 9), h * 1));
5538 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 10), h * 1));
5539 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 10), h * .95));
5540 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 11), h * .95));
5541 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 11), h * 1));
5542 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 12), h * 1));
5543 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 12), h * .95));
5544 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 13), h * .95));
5545 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 13), h * 1));
5546 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 14), h * 1));
5547 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 14), h * .95));
5548 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 15), h * .95));
5549 fig.add(new go.PathSegment(go.PathSegment.Line, w * (.08 + .056 * 15), h * 1));
5550 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1));
5551 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1));
5552 const fig2 = new go.PathFigure(0, 0, false); // is filled in our not
5553 geo.add(fig2);
5554 fig2.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 0));
5555 fig2.add(new go.PathSegment(go.PathSegment.Arc, 270, -180, w * 1, w * 0.3, w * 0.055)); // right semi circle
5556 fig2.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1));
5557 // Each of the little square boxes on the tape
5558 const fig3 = new go.PathFigure(w * .11, h * .1, false); // is filled in our not
5559 geo.add(fig3);
5560 fig3.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 1) + (.028 * 0)), h * .1));
5561 fig3.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 1) + (.028 * 0)), h * .8));
5562 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .11, h * .8).close());
5563 const fig4 = new go.PathFigure(w * (.11 + (.24133333 * 1) + (.028 * 1)), h * .1, false); // is filled in our not
5564 geo.add(fig4);
5565 fig4.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 2) + (.028 * 1)), h * .1));
5566 fig4.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 2) + (.028 * 1)), h * .8));
5567 fig4.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 1) + (.028 * 1)), h * .8).close());
5568 const fig5 = new go.PathFigure(w * (.11 + (.24133333 * 2) + (.028 * 2)), h * .1, false); // is filled in our not
5569 geo.add(fig5);
5570 fig5.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 3) + (.028 * 2)), h * .1));
5571 fig5.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 3) + (.028 * 2)), h * .8));
5572 fig5.add(new go.PathSegment(go.PathSegment.Line, w * (.11 + (.24133333 * 2) + (.028 * 2)), h * .8).close());
5573 return geo;
5574});
5575
5576go.Shape.defineFigureGenerator('FloppyDisk', (shape, w, h) => {
5577 const geo = new go.Geometry();
5578 const roundValue = 8;
5579 const cpOffset = roundValue * KAPPA;
5580 const fig = new go.PathFigure(roundValue, 0, false);
5581 geo.add(fig);
5582
5583 fig.add(new go.PathSegment(go.PathSegment.Line, w * .86, 0));
5584 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .14));
5585 fig.add(new go.PathSegment(go.PathSegment.Line, w, h - roundValue));
5586 fig.add(new go.PathSegment(go.PathSegment.Bezier, w - roundValue, h, w, h - cpOffset, w - cpOffset, h));
5587 fig.add(new go.PathSegment(go.PathSegment.Line, roundValue, h));
5588 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h - roundValue, cpOffset, h, 0, h - cpOffset));
5589 fig.add(new go.PathSegment(go.PathSegment.Line, 0, roundValue));
5590 fig.add(new go.PathSegment(go.PathSegment.Bezier, roundValue, 0, 0, cpOffset, cpOffset, 0).close());
5591 // interior slightly rectangle
5592 const fig2 = new go.PathFigure(w * .83, 0, false);
5593 geo.add(fig2);
5594 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .83, h * .3));
5595 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .17, h * .3));
5596 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .17, h * 0).close());
5597 const fig3 = new go.PathFigure(w * .83, h * 1, false);
5598 geo.add(fig3);
5599 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .83, h * .5));
5600 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .17, h * .5));
5601 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .17, h * 1).close());
5602 const fig4 = new go.PathFigure(w * .78, h * .05, false);
5603 geo.add(fig4);
5604 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * .05));
5605 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * .25));
5606 fig4.add(new go.PathSegment(go.PathSegment.Line, w * .78, h * .25).close());
5607 return geo;
5608});
5609
5610go.Shape.defineFigureGenerator('SpeechBubble', (shape, w, h) => {
5611 let param1 = shape ? shape.parameter1 : NaN;
5612 if (isNaN(param1) || param1 < 0) param1 = 15; // default corner
5613 param1 = Math.min(param1, w / 3);
5614 param1 = Math.min(param1, h / 3);
5615
5616 const cpOffset = param1 * KAPPA;
5617 const bubbleH = h * .8; // leave some room at bottom for pointer
5618
5619 const geo = new go.Geometry();
5620 const fig = new go.PathFigure(param1, 0, true);
5621 geo.add(fig);
5622 fig.add(new go.PathSegment(go.PathSegment.Line, w - param1, 0));
5623 fig.add(new go.PathSegment(go.PathSegment.Bezier, w, param1, w - cpOffset, 0, w, cpOffset));
5624 fig.add(new go.PathSegment(go.PathSegment.Line, w, bubbleH - param1));
5625 fig.add(new go.PathSegment(go.PathSegment.Bezier, w - param1, bubbleH, w, bubbleH - cpOffset, w - cpOffset, bubbleH));
5626 fig.add(new go.PathSegment(go.PathSegment.Line, w * .70, bubbleH));
5627 fig.add(new go.PathSegment(go.PathSegment.Line, w * .70, h));
5628 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, bubbleH));
5629 fig.add(new go.PathSegment(go.PathSegment.Line, param1, bubbleH));
5630 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, bubbleH - param1, cpOffset, bubbleH, 0, bubbleH - cpOffset));
5631 fig.add(new go.PathSegment(go.PathSegment.Line, 0, param1));
5632 fig.add(new go.PathSegment(go.PathSegment.Bezier, param1, 0, 0, cpOffset, cpOffset, 0).close());
5633 if (cpOffset > 1) {
5634 geo.spot1 = new go.Spot(0, 0, cpOffset, cpOffset);
5635 geo.spot2 = new go.Spot(1, .8, -cpOffset, -cpOffset);
5636 } else {
5637 geo.spot1 = go.Spot.TopLeft;
5638 geo.spot2 = new go.Spot(1, .8);
5639 }
5640 return geo;
5641});
5642
5643go.Shape.defineFigureGenerator('Repeat', (shape, w, h) => {
5644 const geo = new go.Geometry();
5645 const fig = new go.PathFigure(w * 0, h * .45, true);
5646 geo.add(fig);
5647
5648 fig.add(new go.PathSegment(go.PathSegment.Line, w * .25, h * 0));
5649 fig.add(new go.PathSegment(go.PathSegment.Line, w * .50, h * .45));
5650 fig.add(new go.PathSegment(go.PathSegment.Line, w * .30, h * .45));
5651 fig.add(new go.PathSegment(go.PathSegment.Line, w * .30, h * .90));
5652 fig.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * .90));
5653 fig.add(new go.PathSegment(go.PathSegment.Line, w * .65, h * 1));
5654 fig.add(new go.PathSegment(go.PathSegment.Line, w * .20, h * 1));
5655 fig.add(new go.PathSegment(go.PathSegment.Line, w * .20, h * .45).close());
5656 const fig2 = new go.PathFigure(w * 1, h * .55, true); // is filled in our not
5657 geo.add(fig2);
5658 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * 1));
5659 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .50, h * .55));
5660 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .70, h * .55));
5661 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .70, h * .10));
5662 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .40, h * .10));
5663 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .35, h * 0));
5664 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .80, h * 0));
5665 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .80, h * .55).close());
5666 return geo;
5667});
5668
5669go.Shape.defineFigureGenerator('Windows', (shape, w, h) => {
5670 return new go.Geometry()
5671 .add(new go.PathFigure(0, 0, true)
5672 .add(new go.PathSegment(go.PathSegment.Line, w, 0))
5673 .add(new go.PathSegment(go.PathSegment.Line, w, h))
5674 .add(new go.PathSegment(go.PathSegment.Line, 0, h).close())
5675 .add(new go.PathSegment(go.PathSegment.Move, 0.4 * w, 0.4 * h))
5676 .add(new go.PathSegment(go.PathSegment.Line, 0.4 * w, 0.8 * h))
5677 .add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.8 * h))
5678 .add(new go.PathSegment(go.PathSegment.Line, 0.9 * w, 0.4 * h).close())
5679 .add(new go.PathSegment(go.PathSegment.Move, 0.2 * w, 0.1 * h))
5680 .add(new go.PathSegment(go.PathSegment.Line, 0.2 * w, 0.6 * h))
5681 .add(new go.PathSegment(go.PathSegment.Line, 0.7 * w, 0.6 * h))
5682 .add(new go.PathSegment(go.PathSegment.Line, 0.7 * w, 0.1 * h).close())
5683 .add(new go.PathSegment(go.PathSegment.Move, 0.1 * w, 0.6 * h))
5684 .add(new go.PathSegment(go.PathSegment.Line, 0.1 * w, 0.9 * h))
5685 .add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.9 * h))
5686 .add(new go.PathSegment(go.PathSegment.Line, 0.5 * w, 0.6 * h).close()));
5687});
5688
5689go.Shape.defineFigureGenerator('Terminal', (shape, w, h) => {
5690 const geo = new go.Geometry();
5691 const fig = new go.PathFigure(w * 0, h * .10, false);
5692 geo.add(fig);
5693
5694 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .10));
5695 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .90));
5696 fig.add(new go.PathSegment(go.PathSegment.Line, w * 0, h * .90).close());
5697 const fig2 = new go.PathFigure(w * .10, h * .20, true); // is filled in our not
5698 geo.add(fig2);
5699 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .10, h * .25));
5700 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .22, h * .285)); // midpoint
5701 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .10, h * .32));
5702 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .10, h * .37));
5703 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .275, h * .32));
5704 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .275, h * .25).close());
5705 const fig3 = new go.PathFigure(w * .28, h * .37, true); // is filled in our not
5706 geo.add(fig3);
5707 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .45, h * .37));
5708 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .45, h * .41));
5709 fig3.add(new go.PathSegment(go.PathSegment.Line, w * .28, h * .41).close());
5710 return geo;
5711});
5712
5713go.Shape.defineFigureGenerator('Beaker', (shape, w, h) => {
5714 const geo = new go.Geometry();
5715 const param1 = 15;
5716 const cpOffset = param1 * KAPPA;
5717 const fig = new go.PathFigure(w * .62, h * .475, true);
5718 geo.add(fig);
5719
5720 fig.add(new go.PathSegment(go.PathSegment.Line, w, h - param1));
5721 fig.add(new go.PathSegment(go.PathSegment.Bezier, w - param1, h, w, h - cpOffset, w - cpOffset, h));
5722 fig.add(new go.PathSegment(go.PathSegment.Line, param1, h));
5723 fig.add(new go.PathSegment(go.PathSegment.Bezier, 0, h - param1, cpOffset, h, 0, h - cpOffset));
5724 fig.add(new go.PathSegment(go.PathSegment.Line, w * .38, h * .475));
5725 fig.add(new go.PathSegment(go.PathSegment.Line, w * .38, h * .03));
5726 fig.add(new go.PathSegment(go.PathSegment.Line, w * .36, h * 0));
5727 fig.add(new go.PathSegment(go.PathSegment.Line, w * .64, h * 0));
5728 fig.add(new go.PathSegment(go.PathSegment.Line, w * .62, h * .03).close());
5729 if (cpOffset > 1) {
5730 geo.spot1 = new go.Spot(0, 0, cpOffset, cpOffset);
5731 geo.spot2 = new go.Spot(1, 1, -cpOffset, -cpOffset);
5732 } else {
5733 geo.spot1 = go.Spot.TopLeft;
5734 geo.spot2 = go.Spot.BottomRight;
5735 }
5736 return geo;
5737});
5738
5739go.Shape.defineFigureGenerator('Download', (shape, w, h) => {
5740 const geo = new go.Geometry();
5741 const fig = new go.PathFigure(w * 0, h * 1, true);
5742 geo.add(fig);
5743
5744 const third = .1 / .3; // just to keep values consistent
5745 // outer frame
5746 // starts bottom left
5747 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1));
5748 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * (1 - third)));
5749 fig.add(new go.PathSegment(go.PathSegment.Line, w * .8, h * 0));
5750 fig.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * 0));
5751 fig.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * .055));
5752 fig.add(new go.PathSegment(go.PathSegment.Line, w * .755, h * .055));
5753 fig.add(new go.PathSegment(go.PathSegment.Line, w * .93, h * (1 - third)));
5754 fig.add(new go.PathSegment(go.PathSegment.Line, w * .64, h * (1 - third)));
5755 fig.add(new go.PathSegment(go.PathSegment.Line, w * .61, h * .75));
5756 fig.add(new go.PathSegment(go.PathSegment.Line, w * .5, h * .75));
5757 fig.add(new go.PathSegment(go.PathSegment.Line, w * .39, h * .75));
5758 fig.add(new go.PathSegment(go.PathSegment.Line, w * .36, h * (1 - third)));
5759 fig.add(new go.PathSegment(go.PathSegment.Line, w * .07, h * (1 - third)));
5760 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .755), h * (.055)));
5761 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .66), h * (.055)));
5762 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .66), h * (0)));
5763 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .8), h * (0)));
5764 fig.add(new go.PathSegment(go.PathSegment.Line, w * 0, h * (1 - third)).close());
5765 // arrow pointing down
5766 const fig2 = new go.PathFigure(w * .40, h * 0, true);
5767 geo.add(fig2);
5768 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .40, h * .44));
5769 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .26, h * .44));
5770 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .5, h * .66));
5771 fig2.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .26), h * .44));
5772 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * .44));
5773 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * 0).close());
5774 return geo;
5775});
5776
5777go.Shape.defineFigureGenerator('Bin', (shape, w, h) => {
5778 const geo = new go.Geometry();
5779 const fig = new go.PathFigure(w * 0, h * 1, true);
5780 geo.add(fig);
5781
5782 const third = .1 / .3; // just to keep values consistent
5783 // outer frame
5784 // starts bottom left
5785 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1));
5786 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * (1 - third)));
5787 fig.add(new go.PathSegment(go.PathSegment.Line, w * .8, h * 0));
5788 fig.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * 0));
5789 fig.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * .055));
5790 fig.add(new go.PathSegment(go.PathSegment.Line, w * .755, h * .055));
5791 fig.add(new go.PathSegment(go.PathSegment.Line, w * .93, h * (1 - third)));
5792 fig.add(new go.PathSegment(go.PathSegment.Line, w * .64, h * (1 - third)));
5793 fig.add(new go.PathSegment(go.PathSegment.Line, w * .61, h * .75));
5794 fig.add(new go.PathSegment(go.PathSegment.Line, w * .5, h * .75));
5795 fig.add(new go.PathSegment(go.PathSegment.Line, w * .39, h * .75));
5796 fig.add(new go.PathSegment(go.PathSegment.Line, w * .36, h * (1 - third)));
5797 fig.add(new go.PathSegment(go.PathSegment.Line, w * .07, h * (1 - third)));
5798 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .755), h * (.055)));
5799 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .66), h * (.055)));
5800 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .66), h * (0)));
5801 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .8), h * (0)));
5802 fig.add(new go.PathSegment(go.PathSegment.Line, w * 0, h * (1 - third)).close());
5803 return geo;
5804});
5805
5806go.Shape.defineFigureGenerator('Upload', (shape, w, h) => {
5807 const geo = new go.Geometry();
5808 const fig = new go.PathFigure(w * 0, h * 1, true);
5809 geo.add(fig);
5810
5811 const third = .1 / .3; // just to keep values consistent
5812 // outer frame
5813 // starts bottom left
5814 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * 1));
5815 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * (1 - third)));
5816 fig.add(new go.PathSegment(go.PathSegment.Line, w * .8, h * 0));
5817 fig.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * 0));
5818 fig.add(new go.PathSegment(go.PathSegment.Line, w * .66, h * .055));
5819 fig.add(new go.PathSegment(go.PathSegment.Line, w * .755, h * .055));
5820 fig.add(new go.PathSegment(go.PathSegment.Line, w * .93, h * (1 - third)));
5821 fig.add(new go.PathSegment(go.PathSegment.Line, w * .64, h * (1 - third)));
5822 fig.add(new go.PathSegment(go.PathSegment.Line, w * .61, h * .75));
5823 fig.add(new go.PathSegment(go.PathSegment.Line, w * .5, h * .75));
5824 fig.add(new go.PathSegment(go.PathSegment.Line, w * .39, h * .75));
5825 fig.add(new go.PathSegment(go.PathSegment.Line, w * .36, h * (1 - third)));
5826 fig.add(new go.PathSegment(go.PathSegment.Line, w * .07, h * (1 - third)));
5827 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .755), h * (.055)));
5828 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .66), h * (.055)));
5829 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .66), h * (0)));
5830 fig.add(new go.PathSegment(go.PathSegment.Line, w * (1 - .8), h * (0)));
5831 fig.add(new go.PathSegment(go.PathSegment.Line, w * 0, h * (1 - third)).close());
5832 const fig2 = new go.PathFigure(w * .5, h * 0, true);
5833 geo.add(fig2);
5834 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .26, h * .25));
5835 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .40, h * .25));
5836 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .40, h * .63));
5837 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * .63));
5838 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .60, h * .25));
5839 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .74, h * .25).close());
5840
5841 return geo;
5842});
5843
5844go.Shape.defineFigureGenerator('EmptyDrink', (shape, w, h) => {
5845 const geo = new go.Geometry();
5846 const fig = new go.PathFigure(w * .15, h * 0, false);
5847 geo.add(fig);
5848
5849 fig.add(new go.PathSegment(go.PathSegment.Line, w * .85, h * 0));
5850 fig.add(new go.PathSegment(go.PathSegment.Line, w * .70, h * 1));
5851 fig.add(new go.PathSegment(go.PathSegment.Line, w * .30, h * 1).close());
5852 return geo;
5853});
5854
5855go.Shape.defineFigureGenerator('Drink', (shape, w, h) => {
5856 const geo = new go.Geometry();
5857 const fig = new go.PathFigure(w * .15, h * 0, false);
5858 geo.add(fig);
5859
5860 fig.add(new go.PathSegment(go.PathSegment.Line, w * .85, h * 0));
5861 fig.add(new go.PathSegment(go.PathSegment.Line, w * .70, h * 1));
5862 fig.add(new go.PathSegment(go.PathSegment.Line, w * .30, h * 1).close());
5863 const fig2 = new go.PathFigure(w * .235, h * .28, true);
5864 geo.add(fig2);
5865 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .765, h * .28));
5866 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .655, h * .97));
5867 fig2.add(new go.PathSegment(go.PathSegment.Line, w * .345, h * .97).close());
5868
5869 return geo;
5870});
5871
5872go.Shape.defineFigureGenerator('4Arrows', (shape, w, h) => {
5873 const geo = new go.Geometry();
5874 const fig = new go.PathFigure(w * .5, h * 0, true);
5875 geo.add(fig);
5876
5877 fig.add(new go.PathSegment(go.PathSegment.Line, w * .65, h * .25));
5878 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, h * .25));
5879 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, h * .45));
5880 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * .45));
5881 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * .35));
5882 fig.add(new go.PathSegment(go.PathSegment.Line, w * 1, h * .5));
5883 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * .65));
5884 fig.add(new go.PathSegment(go.PathSegment.Line, w * .75, h * .55));
5885 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, h * .55));
5886 fig.add(new go.PathSegment(go.PathSegment.Line, w * .55, h * .75));
5887 fig.add(new go.PathSegment(go.PathSegment.Line, w * .65, h * .75));
5888 fig.add(new go.PathSegment(go.PathSegment.Line, w * .5, h * 1));
5889 fig.add(new go.PathSegment(go.PathSegment.Line, w * .35, h * .75));
5890 fig.add(new go.PathSegment(go.PathSegment.Line, w * .45, h * .75));
5891 fig.add(new go.PathSegment(go.PathSegment.Line, w * .45, h * .55));
5892 fig.add(new go.PathSegment(go.PathSegment.Line, w * .25, h * .55));
5893 fig.add(new go.PathSegment(go.PathSegment.Line, w * .25, h * .65));
5894 fig.add(new go.PathSegment(go.PathSegment.Line, w * 0, h * .5));
5895 fig.add(new go.PathSegment(go.PathSegment.Line, w * .25, h * .35));
5896 fig.add(new go.PathSegment(go.PathSegment.Line, w * .25, h * .45));
5897 fig.add(new go.PathSegment(go.PathSegment.Line, w * .45, h * .45));
5898 fig.add(new go.PathSegment(go.PathSegment.Line, w * .45, h * .25));
5899 fig.add(new go.PathSegment(go.PathSegment.Line, w * .35, h * .25).close());
5900 return geo;
5901});
5902
5903go.Shape.defineFigureGenerator('Connector', 'Ellipse');
5904go.Shape.defineFigureGenerator('Alternative', 'TriangleUp');
5905go.Shape.defineFigureGenerator('Merge', 'TriangleUp');
5906go.Shape.defineFigureGenerator('Decision', 'Diamond');
5907go.Shape.defineFigureGenerator('DataTransmissions', 'Hexagon');
5908go.Shape.defineFigureGenerator('Gate', 'Crescent');
5909go.Shape.defineFigureGenerator('Delay', 'HalfEllipse');
5910go.Shape.defineFigureGenerator('Input', 'Parallelogram1');
5911go.Shape.defineFigureGenerator('ManualLoop', 'ManualOperation');
5912go.Shape.defineFigureGenerator('ISOProcess', 'Chevron');
5913go.Shape.defineFigureGenerator('MessageToUser', 'SquareArrow');
5914go.Shape.defineFigureGenerator('MagneticData', 'Cylinder1');
5915go.Shape.defineFigureGenerator('DirectData', 'Cylinder4');
5916go.Shape.defineFigureGenerator('StoredData', 'DataStorage');
5917go.Shape.defineFigureGenerator('SequentialData', 'MagneticTape');
5918go.Shape.defineFigureGenerator('Subroutine', 'Procedure');