jsxgraph 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- JSXGraph 1.4.2
2
+ JSXGraph 1.4.3
3
3
 
4
4
  Copyright 2008-2022
5
5
  Matthias Ehmann,
@@ -1,5 +1,5 @@
1
1
  /*
2
- JSXGraph 1.4.2
2
+ JSXGraph 1.4.3
3
3
 
4
4
  Copyright 2008-2022
5
5
  Matthias Ehmann,
@@ -14,21 +14,31 @@
14
14
  //
15
15
 
16
16
  /**
17
- * JXG namespace.
17
+ * JSXGraph in the namespace JXG.
18
18
  */
19
- declare module JXG {
19
+ declare namespace JXG {
20
+
20
21
  /**
21
- *
22
+ * Store a reference to every board in this central list.
23
+ * This will at some point replace JXG.JSXGraph.boards.
22
24
  */
23
- export type CoordType = 1 | 2
25
+ export const boards: unknown;
26
+
24
27
  /**
25
- * User coordinates relative to the coordinates system defined by the bounding box.
28
+ *
26
29
  */
27
- export const COORDS_BY_USER: 0x0001;
30
+ export type CoordType = 1 | 2
31
+
28
32
  /**
29
33
  * Screen coordinates in pixel relative to the upper left corner of the div element.
30
34
  */
31
35
  export const COORDS_BY_SCREEN: 0x0002;
36
+
37
+ /**
38
+ * User coordinates relative to the coordinates system defined by the bounding box.
39
+ */
40
+ export const COORDS_BY_USER: 0x0001;
41
+
32
42
  /**
33
43
  * A composition is a simple container that manages none or more GeometryElements.
34
44
  */
@@ -147,6 +157,11 @@ declare module JXG {
147
157
  isReal(): boolean;
148
158
  }
149
159
 
160
+ /**
161
+ * Associative array that keeps track of all constructable elements registered via JXG.registerElement.
162
+ */
163
+ export const elements: { [elementType: string]: unknown };
164
+
150
165
  /**
151
166
  * A JessieCode object provides an interface to the parser and stores all variables and objects used within a JessieCode script.
152
167
  * The optional argument code is interpreted after initializing.
@@ -235,6 +250,12 @@ declare module JXG {
235
250
  export function cloneAndCopy<S extends object, T extends object>(obj: S, obj2: T): S | T;
236
251
  export function cmpArrays(a1: unknown[], a2: unknown[]): boolean;
237
252
  export function coordsArrayToMatrix(coords: unknown[], split: boolean): unknown[];
253
+ /**
254
+ * Generates an attributes object that is filled with default values from the Options object and overwritten by the user specified attributes.
255
+ * @param attributes user specified attributes
256
+ * @param options defaults options
257
+ * @param s variable number of strings, e.g. 'slider', subtype 'point1'.
258
+ */
238
259
  export function copyAttributes<T>(attributes: T, options: JXGSettings, ...s: string[]): T;
239
260
  export function createEvalFunction<T>(board: Board, param: T[], n: number): (k: number) => T;
240
261
  export function createFunction(term: string | number | Function, board: Board, variableName: string, evalGeonext?: boolean): Function;
@@ -285,6 +306,22 @@ declare module JXG {
285
306
  export function escapeHTML(str: string): string;
286
307
  export function evalSlider(s: unknown): number;
287
308
  export function evaluate(val: unknown): unknown;
309
+ /**
310
+ * Checks if a given variable is neither undefined nor null. You should not use this together with global variables!
311
+ * @param v A variable of any type.
312
+ * @param checkEmptyString If set to true, it is also checked whether v is not equal to ''. Default: false.
313
+ * @returns True, if v is neither undefined nor null.
314
+ */
315
+ export function exists(v: unknown, checkEmptyString?: boolean): boolean;
316
+ /**
317
+ * Copy all properties of the extension object to object.
318
+ * @param obj
319
+ * @param extension
320
+ * @param onlyOwn Only consider properties that belong to extension itself, not any inherited properties. Default: false.
321
+ * @param toLower If true the keys are convert to lower case. This is needed for visProp, see JXG#copyAttributes. Default: false.
322
+ */
323
+ export function extend(obj: object, extension: object, onlyOwn?: boolean, toLower?: boolean): void;
324
+ export function extendConstants(obj: object, constants: object, onlyOwn?: boolean, toUpper?: boolean): void;
288
325
  export function filterElements<T>(list: T[], filter: object | Function): T[];
289
326
  export function getBoardByContainerId(s: string): Board | null;
290
327
  export function getCSSTrasform(cPos: number[], obj: Element): number[];
@@ -330,7 +367,12 @@ declare module JXG {
330
367
  export function merge<U, V>(obj1: U, obj2: V): U | V;
331
368
  export function normalizePointFace(s: string): 'x' | 'o' | '[]' | '+' | '<>' | '^' | 'v' | '<' | '>';
332
369
  export function providePoints(board: Board, parents: unknown[], attrClass: string, attrArray: unknown[]): JXG.Point[] | false;
333
- export function registerElement(element: string, creator: Function): void;
370
+ /**
371
+ * This registers a new construction element to JSXGraph for the construction via the JXG.Board.create interface.
372
+ * @param element The elements name. This is case-insensitive, existing elements with the same name will be overwritten.
373
+ * @param creator The factory function that creates the GeometryElement.
374
+ */
375
+ export function registerElement(element: string, creator: ((board: Board, parents: unknown[], attributes: Record<string, unknown>) => GeometryElement | Composition | Array<GeometryElement>)): void;
334
376
  export function registerReader(reader: Function, ext: unknown[]): void;
335
377
  export function removeAllEvents(obj: unknown, type: string, owner: unknown): void;
336
378
  export function removeElementFromArray<T>(ar: T[], el: T): T;
@@ -412,16 +454,34 @@ declare module JXG {
412
454
  */
413
455
  name: string;
414
456
 
457
+ /**
458
+ * Controls if updates are necessary.
459
+ */
415
460
  needsUpdate: boolean;
416
461
 
462
+ /**
463
+ * Stores all Intersection Objects which in this moment are not real and so hide this element.
464
+ */
417
465
  notExistingParents: unknown;
418
466
 
467
+ /**
468
+ * Counts the number of objects drawn as part of the trace of the element.
469
+ */
419
470
  numTraces: number;
420
471
 
421
- parents: unknown;
472
+ /**
473
+ * Ids of elements on which this element depends directly are stored here.
474
+ */
475
+ parents: string[];
422
476
 
477
+ /**
478
+ * Quadratic form representation of circles (and conics)
479
+ */
423
480
  quadraticform: unknown[];
424
481
 
482
+ /**
483
+ * Stores the SVG (or VML) rendering node for the element.
484
+ */
425
485
  rendNode: HTMLElement;
426
486
 
427
487
  /**
@@ -429,18 +489,41 @@ declare module JXG {
429
489
  */
430
490
  stdform: [C: number, A: number, B: number];
431
491
 
492
+ /**
493
+ * Subs contains the subelements, created during the create method.
494
+ */
432
495
  subs: unknown;
433
496
 
497
+ /**
498
+ * Stores variables for symbolic computations.
499
+ */
434
500
  symbolic: unknown;
435
501
 
502
+ /**
503
+ * Keeps track of all objects drawn as part of the trace of the element.
504
+ */
436
505
  traces: unknown;
437
506
 
507
+ /**
508
+ * Stores the transformations which are applied during update in an array
509
+ */
438
510
  transformations: unknown[];
439
511
 
512
+ /**
513
+ * Type of the element.
514
+ */
440
515
  type: number;
441
516
 
517
+ /**
518
+ * An associative array containing all visual properties.
519
+ */
442
520
  visProp: { [name: string]: unknown };
443
521
 
522
+ /**
523
+ * An associative array containing visual properties which are calculated from the attribute values (i.e. visProp) and from other constraints.
524
+ * An example: if an intersection point does not have real coordinates, visPropCalc.visible is set to false.
525
+ * Additionally, the user can control visibility with the attribute "visible", even by supplying a functions as value.
526
+ */
444
527
  visPropCalc: { [name: string]: unknown };
445
528
 
446
529
  /**
@@ -493,14 +576,24 @@ declare module JXG {
493
576
  */
494
577
  hideElement(): void;
495
578
 
579
+ /**
580
+ * Unregister an event handler.
581
+ * For a list of possible events see documentation of the elements and objects implementing the EventEmitter interface.
582
+ * @param event
583
+ * @param handler
584
+ * @returns Reference to the object.
585
+ */
586
+ off(event: string, handler: (e: Event) => void): this;
587
+
496
588
  /**
497
589
  * Register a new event handler.
498
590
  * For a list of possible events see documentation of the elements and objects implementing the EventEmitter interface.
499
591
  * @param event
500
592
  * @param handler
501
593
  * @param context The context the handler will be called in, default is the element itself.
594
+ * @returns Reference to the object.
502
595
  */
503
- on(event: string, handler: (e: Event) => void, context?: unknown): void;
596
+ on(event: string, handler: (e: Event) => void, context?: unknown): this;
504
597
 
505
598
  /**
506
599
  * Sets an arbitrary number of attributes.
@@ -1494,11 +1587,11 @@ declare module JXG {
1494
1587
  }
1495
1588
 
1496
1589
  /**
1497
- *
1590
+ * In this class all group management is done.
1498
1591
  */
1499
1592
  export class Group extends GeometryElement {
1500
1593
  /**
1501
- *
1594
+ * Creates a new instance of Group.
1502
1595
  * @param board
1503
1596
  * @param id Unique identifier for this object. If null or an empty string is given, an unique id will be generated by Board.
1504
1597
  * @param name Not necessarily unique name, displayed on the board. If null or an empty string is given, an unique name will be generated.
@@ -1580,7 +1673,7 @@ declare module JXG {
1580
1673
  * Sets the rotation points of the group. Dragging at one of these points results into a rotation of the whole group around the rotation center of the group {@see JXG.Group#setRotationCenter}.
1581
1674
  * @param objects
1582
1675
  */
1583
- setRotationPoints(objects: Point[]): this;
1676
+ setRotationPoints(objects: Point | Point[]): this;
1584
1677
  /**
1585
1678
  * Sets the center of scaling for the group. This is either a point or the centroid of the group.
1586
1679
  * @param object
@@ -1591,12 +1684,12 @@ declare module JXG {
1591
1684
  * @param objects Array of JXG.Point or arbitrary number of JXG.Point elements.
1592
1685
  * @param direction Restricts the directions to be scaled. Possible values are 'x', 'y', 'xy'. Default value is 'xy'. By default, all points of the group are translation points.
1593
1686
  */
1594
- setScalePoints(objects: Point[], direction?: 'x' | 'y' | 'xy'): this;
1687
+ setScalePoints(objects: Point | Point[], direction?: 'x' | 'y' | 'xy'): this;
1595
1688
  /**
1596
1689
  * Sets the translation points of the group. Dragging at one of these points results into a translation of the whole group.
1597
1690
  * @param objects Array of JXG.Point or arbitrary number of JXG.Point elements. By default, all points of the group are translation points.
1598
1691
  */
1599
- setTranslationPoints(objects: Point[]): this;
1692
+ setTranslationPoints(objects: Point | Point[]): this;
1600
1693
  /**
1601
1694
  * Releases all elements of this group.
1602
1695
  */
@@ -2321,7 +2414,7 @@ declare module JXG {
2321
2414
  */
2322
2415
  postLabel?: string | StringFunction | number | NumberFunction | null;
2323
2416
  /**
2324
- *
2417
+ *
2325
2418
  */
2326
2419
  showInfobox?: boolean;
2327
2420
  /**
@@ -2468,54 +2561,127 @@ declare module JXG {
2468
2561
  L(): number;
2469
2562
  setAttribute(attributes: LineAttributes): this;
2470
2563
  }
2564
+ /**
2565
+ *
2566
+ */
2471
2567
  export interface LineAttributes extends GeometryElementAttributes {
2472
2568
  /**
2473
2569
  * Determines whether the line has an arrow at the first defining point.
2570
+ *
2571
+ * type=7 is the default for curves if firstArrow: true
2572
+ *
2573
+ * Default Value: false
2474
2574
  */
2475
- firstArrow?: boolean | { type?: number; highlightSize?: number; size?: number };
2575
+ firstArrow?: boolean | { type?: 1 | 2 | 3 | 4 | 5 | 6 | 7; highlightSize?: number; size?: number };
2576
+ /**
2577
+ * Attributes for the line label.
2578
+ */
2579
+ label?: LabelOptions;
2476
2580
  /**
2477
2581
  * Determines whether the line has an arrow at the second defining point.
2582
+ *
2583
+ * type=7 is the default for curves if lastArrow: true
2584
+ *
2585
+ * Default Value: false
2478
2586
  */
2479
- lastArrow?: boolean | { type?: number; highlightSize?: number; size?: number };
2587
+ lastArrow?: boolean | { type?: 1 | 2 | 3 | 4 | 5 | 6 | 7; highlightSize?: number; size?: number };
2480
2588
  /**
2589
+ * Line endings (linecap) of a straight line.
2481
2590
  *
2591
+ * Not available for VML renderer.
2592
+ *
2593
+ * Default Value: 'butt'
2594
+ */
2595
+ lineCap?: 'butt' | 'round' | 'square';
2596
+ /**
2597
+ * Attributes for first defining point of the line.
2482
2598
  */
2483
2599
  point1?: PointAttributes;
2484
2600
  /**
2485
- *
2601
+ * Attributes for second defining point of the line.
2486
2602
  */
2487
2603
  point2?: PointAttributes;
2604
+ /**
2605
+ * Defines together with Point#snapSizeY the grid the point snaps on to.
2606
+ * The point will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction.
2607
+ * If this value is equal to or less than 0, it will use the grid displayed by the major ticks of the default ticks of the default x axes of the board.
2608
+ *
2609
+ * Default Value: 1
2610
+ */
2611
+ snapSizeX?: number;
2612
+ /**
2613
+ * Defines together with Point#snapSizeX the grid the point snaps on to.
2614
+ * The point will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction.
2615
+ * If this value is equal to or less than 0, it will use the grid displayed by the major ticks of the default ticks of the default y axes of the board.
2616
+ *
2617
+ * Default Value: 1
2618
+ */
2619
+ snapSizeY?: number;
2620
+ /**
2621
+ * If set to true, the point will snap to a grid defined by Point#snapSizeX and Point#snapSizeY.
2622
+ *
2623
+ * Default Value: false
2624
+ */
2625
+ snapToGrid?: boolean;
2488
2626
  /**
2489
2627
  * Determines whether the line is drawn beyond the first defining point.
2628
+ *
2629
+ * If true, line stretches infinitely in direction of its first point. Otherwise it ends at point1.
2630
+ *
2631
+ * Default Value: true
2490
2632
  */
2491
2633
  straightFirst?: boolean;
2492
2634
  /**
2493
2635
  * Determines whether the line is drawn beyond the second defining point.
2636
+ *
2637
+ * If true, line stretches infinitely in direction of its second point. Otherwise it ends at point2.
2638
+ *
2639
+ * Default Value: true
2494
2640
  */
2495
2641
  straightLast?: boolean;
2642
+ /**
2643
+ * Attributes for ticks of the line.
2644
+ */
2645
+ ticks?: TicksOptions;
2646
+ /**
2647
+ * If set to true and Line#firstArrow is set to true, the arrow head will just touch the circle line of the start point of the line.
2648
+ *
2649
+ * Default Value: false
2650
+ */
2651
+ touchFirstPoint?: boolean;
2652
+ /**
2653
+ * If set to true and Line#lastArrow is set to true, the arrow head will just touch the circle line of the start point of the line.
2654
+ *
2655
+ * Default Value: false
2656
+ */
2657
+ touchLastPoint?: boolean;
2496
2658
  }
2497
2659
 
2498
2660
  export interface LineOptions extends GeometryElementAttributes {
2499
2661
  /**
2500
2662
  * Determines whether the line has an arrow at the first defining point.
2501
2663
  */
2502
- firstArrow?: boolean | { type?: number; highlightSize?: number; size?: number };
2664
+ firstArrow?: boolean | { type?: 1 | 2 | 3 | 4 | 5 | 6 | 7; highlightSize?: number; size?: number };
2503
2665
  /**
2504
2666
  *
2505
2667
  */
2506
2668
  fixed?: boolean;
2507
- /**
2508
- * Determines whether the line has an arrow at the second defining point.
2509
- */
2510
- lastArrow?: boolean | { type?: number; highlightSize?: number; size?: number };
2511
2669
  /**
2512
2670
  *
2513
2671
  */
2514
2672
  label?: LabelOptions;
2515
2673
  /**
2674
+ * Determines whether the line has an arrow at the second defining point.
2675
+ */
2676
+ lastArrow?: boolean | { type?: 1 | 2 | 3 | 4 | 5 | 6 | 7; highlightSize?: number; size?: number };
2677
+ /**
2678
+ * Line endings (linecap) of a straight line.
2679
+ *
2680
+ * Not available for VML renderer.
2516
2681
  *
2682
+ * Default Value: 'butt'
2517
2683
  */
2518
- lineCap?: 'butt';
2684
+ lineCap?: 'butt' | 'round' | 'square';
2519
2685
  /**
2520
2686
  *
2521
2687
  */
@@ -2936,18 +3102,70 @@ declare module JXG {
2936
3102
  numberPoints?: number;
2937
3103
  }
2938
3104
 
3105
+ export type TransformationType = 'generic' | 'reflect' | 'rotate' | 'scale' | 'shear' | 'translate'
3106
+
3107
+ /**
3108
+ * A transformation consists of a 3x3 matrix, i.e. it is a projective transformation.
3109
+ */
2939
3110
  export class Transformation extends GeometryElement {
2940
- constructor(board: Board, type: 'translate' | 'scale' | 'reflect' | 'rotate' | 'shear' | 'generic', params: unknown);
2941
- apply(p: GeometryElement): unknown[];
3111
+ /**
3112
+ * @param board The board the new circle is drawn on.
3113
+ * @param type Can be 'translate', 'scale', 'reflect', 'rotate', 'shear', 'generic'
3114
+ * @param params The parameters depend on the transformation type.
3115
+ */
3116
+ constructor(board: Board, type: TransformationType, params: unknown);
3117
+ /**
3118
+ * Transform a GeometryElement: First, the transformation matrix is updated, then do the matrix-vector-multiplication.
3119
+ * @param p element which is transformed
3120
+ */
3121
+ private apply(p: GeometryElement): unknown[];
3122
+ /**
3123
+ * Applies a transformation once to a GeometryElement or an array of elements.
3124
+ * If it is a free point, then it can be dragged around later and will overwrite the transformed coordinates.
3125
+ * @param p
3126
+ */
2942
3127
  applyOnce(p: GeometryElement | GeometryElement[]): void;
2943
- bindTo(element: GeometryElement | Point[]): void;
3128
+ /**
3129
+ * Binds a transformation to a GeometryElement or an array of elements.
3130
+ * In every update of the GeometryElement(s), the transformation is executed.
3131
+ * That means, in order to immediately apply the transformation, a call of board.update() has to follow.
3132
+ * @param p JXG.Object or array of JXG.Object to which the transformation is bound to.
3133
+ */
3134
+ bindTo(p: GeometryElement | Point[]): void;
3135
+ /**
3136
+ * Combine two transformations to one transformation.
3137
+ * This only works if both of transformation matrices consist solely of numbers, and do not contain functions.
3138
+ * Multiplies the transformation with a transformation t from the left. i.e. (this) = (t) join (this)
3139
+ * @param t Transformation which is the left multiplicand
3140
+ * @returns the transformation object.
3141
+ */
2944
3142
  melt(t: Transformation): Transformation;
2945
- setAttribute(attributes: TransformationAttributes): this;
2946
- setMatrix(board: Board, type: 'translate' | 'scale' | 'reflect' | 'rotate' | 'shear' | 'generic', params: unknown[], x: unknown, y: unknown, scale_x: unknown, scale_y: unknown): void;
3143
+ /**
3144
+ * Empty method. Unused.
3145
+ * @param term Key-value pairs of the attributes.
3146
+ */
3147
+ setAttribute(term: TransformationAttributes): this;
3148
+ /**
3149
+ * Set the transformation matrix for different types of standard transforms.
3150
+ * @param board
3151
+ * @param type Transformation type, possible values are 'translate', 'scale', 'reflect', 'rotate', 'shear', 'generic'.
3152
+ * @param params Parameters for the various transformation types.
3153
+ * @param x Shift vector (number or function) in case of 'translate'.
3154
+ * @param y Shift vector (number or function) in case of 'translate'.
3155
+ * @param scale_x Scale vector (number or function) in case of 'scale'.
3156
+ * @param scale_y Scale vector (number or function) in case of 'scale'.
3157
+ */
3158
+ setMatrix(board: Board, type: TransformationType, params: unknown[], x: NumberOrFunction, y: NumberOrFunction, scale_x: NumberOrFunction, scale_y: NumberOrFunction): void;
3159
+ /**
3160
+ * Updates the numerical data for the transformation, i.e. the entry of the subobject matrix.
3161
+ */
2947
3162
  update(): this;
2948
3163
  }
3164
+ /**
3165
+ *
3166
+ */
2949
3167
  export interface TransformationAttributes {
2950
- type: 'generic' | 'rotate' | 'scale' | 'translate';
3168
+ type: TransformationType;
2951
3169
  }
2952
3170
 
2953
3171
  /**
@@ -3615,6 +3833,13 @@ declare module JXG {
3615
3833
  clickLeftArrow(): this;
3616
3834
  clickRightArrow(): this;
3617
3835
  clickUpArrow(): this;
3836
+ /**
3837
+ * Creates a new geometric element of type elementType.
3838
+ * @param elementType Type of the element to be constructed given as a string e.g. 'point' or 'circle'.
3839
+ * @param parents
3840
+ * @param attributes
3841
+ */
3842
+ create<T extends GeometryElement | Composition | Array<GeometryElement>>(elementType: string, parents: unknown[], attributes?: Record<string, unknown>): T;
3618
3843
  /**
3619
3844
  *
3620
3845
  * @param elementType 'angle'
@@ -3801,6 +4026,13 @@ declare module JXG {
3801
4026
  * @param attributes
3802
4027
  */
3803
4028
  create(elementType: 'image', parents: unknown[], attributes?: ImageAttributes): Image;
4029
+ /**
4030
+ *
4031
+ * @param elementType 'inequality'
4032
+ * @param parents
4033
+ * @param attributes
4034
+ */
4035
+ create(elementType: 'inequality', parents: unknown[], attributes?: InequalityAttributes): Inequality;
3804
4036
  /**
3805
4037
  *
3806
4038
  * @param elementType 'input'
@@ -5266,3 +5498,10 @@ declare module JXG {
5266
5498
  rungeKutta(butcher: unknown, x0: number[], I: number[], N: number, f: unknown): number[][];
5267
5499
  }
5268
5500
  }
5501
+
5502
+ /**
5503
+ * JSXGraph in the module "jsxgraph".
5504
+ */
5505
+ declare module "jsxgraph" {
5506
+ export = JXG;
5507
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- JSXGraph 1.4.2
2
+ JSXGraph 1.4.3
3
3
 
4
4
  Copyright 2008-2022
5
5
  Matthias Ehmann,