p5 2.0.0 → 2.0.1
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.
- package/{src → dist}/accessibility/color_namer.js +48 -3
- package/{src → dist}/accessibility/describe.js +2 -2
- package/{src → dist}/accessibility/gridOutput.js +2 -2
- package/dist/accessibility/index.js +60 -0
- package/{src → dist}/accessibility/outputs.js +2 -2
- package/{src → dist}/accessibility/textOutput.js +2 -2
- package/dist/app.js +120 -0
- package/{src → dist}/color/color_conversion.js +48 -10
- package/{src → dist}/color/color_spaces/hsb.js +3 -1
- package/dist/color/creating_reading.js +3 -0
- package/dist/color/index.js +13 -0
- package/dist/color/p5.Color.culori.js +1 -0
- package/dist/color/p5.Color.js +3 -0
- package/{src → dist}/color/setting.js +9 -6
- package/{src/core/constants.js → dist/constants-C-g_eAdC.js} +266 -130
- package/{src → dist}/core/States.js +3 -1
- package/dist/core/constants.js +1 -0
- package/{src → dist}/core/environment.js +7 -6
- package/{src → dist}/core/friendly_errors/browser_errors.js +1 -1
- package/{src → dist}/core/friendly_errors/fes_core.js +14 -44
- package/{src → dist}/core/friendly_errors/file_errors.js +6 -3
- package/dist/core/friendly_errors/index.js +23 -0
- package/dist/core/friendly_errors/param_validator.js +5455 -0
- package/{src → dist}/core/friendly_errors/sketch_reader.js +50 -4
- package/{src → dist}/core/friendly_errors/sketch_verifier.js +6 -6
- package/{src → dist}/core/friendly_errors/stacktrace.js +3 -5
- package/{src → dist}/core/friendly_errors/validate_params.js +50 -41
- package/{src → dist}/core/helpers.js +9 -6
- package/dist/core/init.js +105 -0
- package/dist/core/internationalization.js +302 -0
- package/dist/core/legacy.js +73 -0
- package/dist/core/main.js +44 -0
- package/dist/core/noop.js +3 -0
- package/dist/core/p5.Graphics.js +40 -0
- package/dist/core/p5.Renderer.js +11 -0
- package/dist/core/p5.Renderer2D.js +44 -0
- package/dist/core/reference.js +1 -0
- package/dist/core/rendering.js +40 -0
- package/{src → dist}/core/structure.js +3 -3
- package/{src → dist}/core/transform.js +2 -2
- package/{src/color/creating_reading.js → dist/creating_reading-D4AAKRbx.js} +841 -13
- package/{src → dist}/data/index.js +3 -1
- package/{src → dist}/data/local_storage.js +2 -8
- package/{src → dist}/dom/dom.js +11 -5
- package/dist/dom/index.js +18 -0
- package/{src → dist}/dom/p5.Element.js +14 -12
- package/{src → dist}/dom/p5.File.js +4 -4
- package/{src → dist}/dom/p5.MediaElement.js +10 -4
- package/{src → dist}/events/acceleration.js +2 -2
- package/{src → dist}/events/index.js +3 -1
- package/{src → dist}/events/keyboard.js +14 -11
- package/{src → dist}/events/pointer.js +16 -17
- package/dist/image/const.js +9 -0
- package/{src → dist}/image/filterRenderer2D.js +57 -37
- package/{src → dist}/image/filters.js +1 -3
- package/dist/image/image.js +40 -0
- package/dist/image/index.js +51 -0
- package/dist/image/loading_displaying.js +40 -0
- package/dist/image/p5.Image.js +11 -0
- package/{src → dist}/image/pixels.js +4 -3
- package/{src → dist}/io/csv.js +72 -70
- package/dist/io/files.js +40 -0
- package/dist/io/index.js +51 -0
- package/{src → dist}/io/p5.Table.js +6 -6
- package/{src → dist}/io/p5.TableRow.js +3 -4
- package/{src → dist}/io/p5.XML.js +2 -5
- package/{src → dist}/io/utilities.js +1 -1
- package/{src/core/p5.Renderer2D.js → dist/main-s72KWcUy.js} +735 -57
- package/{src → dist}/math/Matrices/Matrix.js +10 -8
- package/{src → dist}/math/Matrices/MatrixInterface.js +5 -3
- package/{src → dist}/math/Matrices/MatrixNumjs.js +12 -26
- package/{src → dist}/math/calculation.js +2 -2
- package/{src → dist}/math/index.js +6 -3
- package/{src → dist}/math/math.js +2 -2
- package/{src → dist}/math/noise.js +2 -2
- package/{src → dist}/math/p5.Matrix.js +7 -4
- package/{src → dist}/math/p5.Vector.js +6 -6
- package/{src → dist}/math/random.js +2 -2
- package/{src → dist}/math/trigonometry.js +16 -15
- package/{src/image/p5.Image.js → dist/p5.Renderer-CwAYZOC2.js} +390 -19
- package/dist/rendering--aAe5aq3.js +24925 -0
- package/{src → dist}/shape/2d_primitives.js +18 -17
- package/{src → dist}/shape/attributes.js +18 -17
- package/{src → dist}/shape/curves.js +2 -2
- package/{src → dist}/shape/custom_shapes.js +44 -64
- package/{src → dist}/shape/index.js +10 -2
- package/{src → dist}/shape/vertex.js +2 -3
- package/dist/type/index.js +25 -0
- package/{src → dist}/type/lib/Typr.js +76 -94
- package/{src → dist}/type/p5.Font.js +37 -61
- package/{src → dist}/type/textCore.js +34 -57
- package/{src → dist}/type/unicodeRanges.js +3 -1
- package/{src → dist}/utilities/conversion.js +2 -2
- package/{src → dist}/utilities/index.js +3 -1
- package/{src → dist}/utilities/time_date.js +6 -7
- package/{src → dist}/utilities/utility_functions.js +2 -2
- package/dist/webgl/3d_primitives.js +40 -0
- package/{src → dist}/webgl/GeometryBufferCache.js +3 -1
- package/{src → dist}/webgl/GeometryBuilder.js +12 -8
- package/{src → dist}/webgl/ShaderGenerator.js +79 -82
- package/{src → dist}/webgl/ShapeBuilder.js +26 -23
- package/dist/webgl/index.js +76 -0
- package/{src → dist}/webgl/interaction.js +7 -6
- package/dist/webgl/light.js +40 -0
- package/{src → dist}/webgl/loading.js +45 -12
- package/dist/webgl/material.js +40 -0
- package/dist/webgl/p5.Camera.js +40 -0
- package/{src → dist}/webgl/p5.DataArray.js +3 -5
- package/dist/webgl/p5.Framebuffer.js +40 -0
- package/{src → dist}/webgl/p5.Geometry.js +12 -15
- package/{src → dist}/webgl/p5.Quat.js +5 -4
- package/{src → dist}/webgl/p5.RenderBuffer.js +2 -3
- package/dist/webgl/p5.RendererGL.js +40 -0
- package/dist/webgl/p5.Shader.js +40 -0
- package/dist/webgl/p5.Texture.js +40 -0
- package/{src → dist}/webgl/text.js +51 -9
- package/lib/p5.esm.js +102 -48
- package/lib/p5.js +102 -48
- package/lib/p5.min.js +1 -1
- package/package.json +17 -16
- package/translations/dev.js +6 -6
- package/translations/index.js +1 -1
- package/src/README.md +0 -27
- package/src/accessibility/index.js +0 -13
- package/src/app.js +0 -61
- package/src/color/index.js +0 -9
- package/src/color/p5.Color.culori.js +0 -66
- package/src/color/p5.Color.js +0 -851
- package/src/core/README.md +0 -91
- package/src/core/friendly_errors/index.js +0 -13
- package/src/core/friendly_errors/param_validator.js +0 -561
- package/src/core/init.js +0 -58
- package/src/core/internationalization.js +0 -195
- package/src/core/legacy.js +0 -29
- package/src/core/main.js +0 -689
- package/src/core/noop.js +0 -1
- package/src/core/p5.Graphics.js +0 -696
- package/src/core/p5.Renderer.js +0 -408
- package/src/core/reference.js +0 -2060
- package/src/core/rendering.js +0 -697
- package/src/dom/index.js +0 -11
- package/src/image/const.js +0 -6
- package/src/image/image.js +0 -731
- package/src/image/index.js +0 -15
- package/src/image/loading_displaying.js +0 -1431
- package/src/io/files.js +0 -2210
- package/src/io/index.js +0 -11
- package/src/math/README.md +0 -40
- package/src/type/index.js +0 -9
- package/src/webgl/3d_primitives.js +0 -2741
- package/src/webgl/index.js +0 -37
- package/src/webgl/light.js +0 -1851
- package/src/webgl/material.js +0 -3854
- package/src/webgl/p5.Camera.js +0 -4010
- package/src/webgl/p5.Framebuffer.js +0 -1865
- package/src/webgl/p5.RendererGL.js +0 -2867
- package/src/webgl/p5.Shader.js +0 -1505
- package/src/webgl/p5.Texture.js +0 -541
- package/src/webgl/shaders/basic.frag +0 -6
- package/src/webgl/shaders/filters/base.frag +0 -22
- package/src/webgl/shaders/filters/base.vert +0 -19
- package/src/webgl/shaders/filters/blur.frag +0 -60
- package/src/webgl/shaders/filters/default.vert +0 -18
- package/src/webgl/shaders/filters/dilate.frag +0 -39
- package/src/webgl/shaders/filters/erode.frag +0 -39
- package/src/webgl/shaders/filters/gray.frag +0 -16
- package/src/webgl/shaders/filters/invert.frag +0 -15
- package/src/webgl/shaders/filters/opaque.frag +0 -12
- package/src/webgl/shaders/filters/posterize.frag +0 -29
- package/src/webgl/shaders/filters/threshold.frag +0 -23
- package/src/webgl/shaders/font.frag +0 -216
- package/src/webgl/shaders/font.vert +0 -44
- package/src/webgl/shaders/imageLight.vert +0 -33
- package/src/webgl/shaders/imageLightDiffused.frag +0 -82
- package/src/webgl/shaders/imageLightSpecular.frag +0 -134
- package/src/webgl/shaders/light.vert +0 -37
- package/src/webgl/shaders/light_texture.frag +0 -26
- package/src/webgl/shaders/lighting.glsl +0 -227
- package/src/webgl/shaders/line.frag +0 -74
- package/src/webgl/shaders/line.vert +0 -294
- package/src/webgl/shaders/normal.frag +0 -6
- package/src/webgl/shaders/normal.vert +0 -72
- package/src/webgl/shaders/phong.frag +0 -84
- package/src/webgl/shaders/phong.vert +0 -87
- package/src/webgl/shaders/point.frag +0 -29
- package/src/webgl/shaders/point.vert +0 -19
- package/src/webgl/shaders/sphereMapping.frag +0 -26
- package/src/webgl/shaders/webgl2Compatibility.glsl +0 -34
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { Vector } from '../p5.Vector.js';
|
|
2
|
+
import { MatrixInterface } from './MatrixInterface.js';
|
|
3
|
+
import '../../constants-C-g_eAdC.js';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* @module Math
|
|
3
7
|
*/
|
|
4
8
|
|
|
5
|
-
import { Vector } from "../p5.Vector";
|
|
6
|
-
import { MatrixInterface } from "./MatrixInterface";
|
|
7
9
|
|
|
8
10
|
const isPerfectSquare = (arr) => {
|
|
9
11
|
const sqDimention = Math.sqrt(Array.from(arr).length);
|
|
@@ -13,14 +15,14 @@ const isPerfectSquare = (arr) => {
|
|
|
13
15
|
return true;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
let GLMAT_ARRAY_TYPE = Array;
|
|
19
|
+
let isMatrixArray = (x) => Array.isArray(x);
|
|
18
20
|
if (typeof Float32Array !== "undefined") {
|
|
19
21
|
GLMAT_ARRAY_TYPE = Float32Array;
|
|
20
22
|
isMatrixArray = (x) => Array.isArray(x) || x instanceof Float32Array;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
class Matrix extends MatrixInterface {
|
|
24
26
|
matrix;
|
|
25
27
|
#sqDimention;
|
|
26
28
|
|
|
@@ -570,9 +572,7 @@ export class Matrix extends MatrixInterface {
|
|
|
570
572
|
_src = multMatrix;
|
|
571
573
|
} else if (isPerfectSquare(arguments)) {
|
|
572
574
|
_src = Array.from(arguments);
|
|
573
|
-
} else
|
|
574
|
-
return; // nothing to do.
|
|
575
|
-
}
|
|
575
|
+
} else ;
|
|
576
576
|
if (this.#sqDimention === 4 && _src.length === 16) {
|
|
577
577
|
return this.#mult4x4(_src);
|
|
578
578
|
} else if (this.#sqDimention === 3 && _src.length === 9) {
|
|
@@ -2122,3 +2122,5 @@ export class Matrix extends MatrixInterface {
|
|
|
2122
2122
|
// 0.0,0.0,0.0,1.0
|
|
2123
2123
|
//];
|
|
2124
2124
|
}
|
|
2125
|
+
|
|
2126
|
+
export { GLMAT_ARRAY_TYPE, Matrix, isMatrixArray };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
let GLMAT_ARRAY_TYPE = Array;
|
|
2
|
+
let isMatrixArray = (x) => Array.isArray(x);
|
|
3
3
|
if (typeof Float32Array !== "undefined") {
|
|
4
4
|
GLMAT_ARRAY_TYPE = Float32Array;
|
|
5
5
|
isMatrixArray = (x) => Array.isArray(x) || x instanceof Float32Array;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
class MatrixInterface {
|
|
8
8
|
// Private field to store the matrix
|
|
9
9
|
#matrix = null;
|
|
10
10
|
constructor(...args) {
|
|
@@ -51,3 +51,5 @@ export class MatrixInterface {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
export { GLMAT_ARRAY_TYPE, MatrixInterface, isMatrixArray };
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import nj from
|
|
2
|
-
import { Vector } from
|
|
3
|
-
import { MatrixInterface } from
|
|
1
|
+
import nj from '@d4c/numjs/build/module/numjs.min.js';
|
|
2
|
+
import { Vector } from '../p5.Vector.js';
|
|
3
|
+
import { MatrixInterface } from './MatrixInterface.js';
|
|
4
|
+
import '../../constants-C-g_eAdC.js';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* @requires constants
|
|
7
|
-
* @todo see methods below needing further implementation.
|
|
8
|
-
* future consideration: implement SIMD optimizations
|
|
9
|
-
* when browser compatibility becomes available
|
|
10
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/
|
|
11
|
-
* Reference/Global_Objects/SIMD
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
let GLMAT_ARRAY_TYPE = Array;
|
|
15
6
|
let isMatrixArray = (x) => Array.isArray(x);
|
|
16
7
|
if (typeof Float32Array !== "undefined") {
|
|
17
|
-
GLMAT_ARRAY_TYPE = Float32Array;
|
|
18
8
|
isMatrixArray = (x) => Array.isArray(x) || x instanceof Float32Array;
|
|
19
9
|
}
|
|
20
10
|
|
|
@@ -46,10 +36,10 @@ if (typeof Float32Array !== "undefined") {
|
|
|
46
36
|
* </div>
|
|
47
37
|
*/
|
|
48
38
|
// const matrixEngine = "numjs";
|
|
49
|
-
|
|
39
|
+
class MatrixNumjs extends MatrixInterface{
|
|
50
40
|
constructor(...args) {
|
|
51
41
|
// This is default behavior when object
|
|
52
|
-
super(...args)
|
|
42
|
+
super(...args);
|
|
53
43
|
|
|
54
44
|
if (args[0] === 3) {
|
|
55
45
|
this._mat3 = Array.isArray(args[1]) ? nj.array(args[1]) : nj.identity(3);
|
|
@@ -137,7 +127,7 @@ export class MatrixNumjs extends MatrixInterface{
|
|
|
137
127
|
* @return {MatrixNumjs} the copy of the MatrixNumjs object
|
|
138
128
|
*/
|
|
139
129
|
get() {
|
|
140
|
-
|
|
130
|
+
new MatrixNumjs(this.mat4);
|
|
141
131
|
return new MatrixNumjs(this.mat4);
|
|
142
132
|
}
|
|
143
133
|
|
|
@@ -354,9 +344,7 @@ export class MatrixNumjs extends MatrixInterface{
|
|
|
354
344
|
* @todo finish implementation
|
|
355
345
|
*/
|
|
356
346
|
inverseTranspose({ mat4 }) {
|
|
357
|
-
if (this._mat3 === undefined) {
|
|
358
|
-
// p5._friendlyError("sorry, this function only works with mat3");
|
|
359
|
-
} else {
|
|
347
|
+
if (this._mat3 === undefined) ; else {
|
|
360
348
|
//convert mat4 -> mat3
|
|
361
349
|
this._mat3 = this._mat3.flatten();
|
|
362
350
|
this._mat3.set(0, mat4[0]);
|
|
@@ -528,7 +516,7 @@ export class MatrixNumjs extends MatrixInterface{
|
|
|
528
516
|
x = x[0]; // must be last
|
|
529
517
|
}
|
|
530
518
|
this._mat4 = this._mat4.flatten();
|
|
531
|
-
|
|
519
|
+
nj.array([x, y, z, 1]);
|
|
532
520
|
this._mat4.set(0, x * this._mat4.get(0));
|
|
533
521
|
this._mat4.set(1, x * this._mat4.get(1));
|
|
534
522
|
this._mat4.set(2, x * this._mat4.get(2));
|
|
@@ -811,12 +799,9 @@ export class MatrixNumjs extends MatrixInterface{
|
|
|
811
799
|
* @chainable
|
|
812
800
|
*/
|
|
813
801
|
mult3x3(multMatrix) {
|
|
814
|
-
let _src;
|
|
815
802
|
let tempMatrix = multMatrix;
|
|
816
|
-
if (multMatrix === this || multMatrix === this._mat3) {
|
|
817
|
-
|
|
818
|
-
} else if (multMatrix instanceof MatrixNumjs) {
|
|
819
|
-
_src = multMatrix.mat3;
|
|
803
|
+
if (multMatrix === this || multMatrix === this._mat3) ; else if (multMatrix instanceof MatrixNumjs) {
|
|
804
|
+
multMatrix.mat3;
|
|
820
805
|
} else if (isMatrixArray(multMatrix)) {
|
|
821
806
|
multMatrix._mat3 = nj.array(arguments);
|
|
822
807
|
} else if (arguments.length === 9) {
|
|
@@ -964,3 +949,4 @@ export class MatrixNumjs extends MatrixInterface{
|
|
|
964
949
|
//];
|
|
965
950
|
}
|
|
966
951
|
|
|
952
|
+
export { MatrixNumjs };
|
|
@@ -2,14 +2,17 @@ import calculation from './calculation.js';
|
|
|
2
2
|
import noise from './noise.js';
|
|
3
3
|
import random from './random.js';
|
|
4
4
|
import trigonometry from './trigonometry.js';
|
|
5
|
-
import math from './math.js';
|
|
5
|
+
import math$1 from './math.js';
|
|
6
6
|
import vector from './p5.Vector.js';
|
|
7
|
+
import '../constants-C-g_eAdC.js';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
function math(p5){
|
|
9
10
|
p5.registerAddon(calculation);
|
|
10
11
|
p5.registerAddon(noise);
|
|
11
12
|
p5.registerAddon(random);
|
|
12
13
|
p5.registerAddon(trigonometry);
|
|
13
|
-
p5.registerAddon(math);
|
|
14
|
+
p5.registerAddon(math$1);
|
|
14
15
|
p5.registerAddon(vector);
|
|
15
16
|
}
|
|
17
|
+
|
|
18
|
+
export { math as default };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { Matrix } from './Matrices/Matrix.js';
|
|
2
|
+
import './p5.Vector.js';
|
|
3
|
+
import '../constants-C-g_eAdC.js';
|
|
4
|
+
import './Matrices/MatrixInterface.js';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* @module Math
|
|
3
8
|
* @requires constants
|
|
@@ -7,7 +12,6 @@
|
|
|
7
12
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/
|
|
8
13
|
* Reference/Global_Objects/SIMD
|
|
9
14
|
*/
|
|
10
|
-
import { Matrix } from "./Matrices/Matrix";
|
|
11
15
|
// import { MatrixNumjs as Matrix } from './Matrices/MatrixNumjs'
|
|
12
16
|
|
|
13
17
|
function matrix(p5, fn) {
|
|
@@ -108,9 +112,8 @@ function matrix(p5, fn) {
|
|
|
108
112
|
p5.Matrix = Matrix;
|
|
109
113
|
}
|
|
110
114
|
|
|
111
|
-
export default matrix;
|
|
112
|
-
export { Matrix };
|
|
113
|
-
|
|
114
115
|
if (typeof p5 !== "undefined") {
|
|
115
116
|
matrix(p5, p5.prototype);
|
|
116
117
|
}
|
|
118
|
+
|
|
119
|
+
export { Matrix, matrix as default };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { f as TWO_PI } from '../constants-C-g_eAdC.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @module Math
|
|
3
5
|
* @requires constants
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
|
-
import * as constants from "../core/constants";
|
|
7
8
|
|
|
8
9
|
/// HELPERS FOR REMAINDER METHOD
|
|
9
10
|
const calculateRemainder2D = function (xComponent, yComponent) {
|
|
@@ -3293,7 +3294,7 @@ class Vector {
|
|
|
3293
3294
|
* </div>
|
|
3294
3295
|
*/
|
|
3295
3296
|
static random2D() {
|
|
3296
|
-
return this.fromAngle(Math.random() *
|
|
3297
|
+
return this.fromAngle(Math.random() * TWO_PI);
|
|
3297
3298
|
}
|
|
3298
3299
|
|
|
3299
3300
|
/**
|
|
@@ -3316,7 +3317,7 @@ class Vector {
|
|
|
3316
3317
|
* </div>
|
|
3317
3318
|
*/
|
|
3318
3319
|
static random3D() {
|
|
3319
|
-
const angle = Math.random() *
|
|
3320
|
+
const angle = Math.random() * TWO_PI;
|
|
3320
3321
|
const vz = Math.random() * 2 - 1;
|
|
3321
3322
|
const vzBase = Math.sqrt(1 - vz * vz);
|
|
3322
3323
|
const vx = vzBase * Math.cos(angle);
|
|
@@ -3928,9 +3929,8 @@ function vector(p5, fn) {
|
|
|
3928
3929
|
*/
|
|
3929
3930
|
}
|
|
3930
3931
|
|
|
3931
|
-
export default vector;
|
|
3932
|
-
export { Vector };
|
|
3933
|
-
|
|
3934
3932
|
if (typeof p5 !== "undefined") {
|
|
3935
3933
|
vector(p5, p5.prototype);
|
|
3936
3934
|
}
|
|
3935
|
+
|
|
3936
|
+
export { Vector, vector as default };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { x as RAD_TO_DEG, D as DEG_TO_RAD } from '../constants-C-g_eAdC.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @module Math
|
|
3
5
|
* @submodule Trigonometry
|
|
@@ -6,7 +8,6 @@
|
|
|
6
8
|
* @requires constants
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
|
-
import * as constants from '../core/constants';
|
|
10
11
|
|
|
11
12
|
function trigonometry(p5, fn){
|
|
12
13
|
const DEGREES = fn.DEGREES = 'degrees';
|
|
@@ -516,7 +517,7 @@ function trigonometry(p5, fn){
|
|
|
516
517
|
* </code>
|
|
517
518
|
* </div>
|
|
518
519
|
*/
|
|
519
|
-
fn.degrees = angle => angle *
|
|
520
|
+
fn.degrees = angle => angle * RAD_TO_DEG;
|
|
520
521
|
|
|
521
522
|
/**
|
|
522
523
|
* Converts an angle measured in degrees to its value in radians.
|
|
@@ -552,7 +553,7 @@ function trigonometry(p5, fn){
|
|
|
552
553
|
* </code>
|
|
553
554
|
* </div>
|
|
554
555
|
*/
|
|
555
|
-
fn.radians = angle => angle *
|
|
556
|
+
fn.radians = angle => angle * DEG_TO_RAD;
|
|
556
557
|
|
|
557
558
|
/**
|
|
558
559
|
* Changes the unit system used to measure angles.
|
|
@@ -757,14 +758,14 @@ function trigonometry(p5, fn){
|
|
|
757
758
|
// This is necessary for acceleration events to work properly
|
|
758
759
|
if(mode === RADIANS) {
|
|
759
760
|
// Change pRotation to radians
|
|
760
|
-
this.pRotationX = this.pRotationX *
|
|
761
|
-
this.pRotationY = this.pRotationY *
|
|
762
|
-
this.pRotationZ = this.pRotationZ *
|
|
761
|
+
this.pRotationX = this.pRotationX * DEG_TO_RAD;
|
|
762
|
+
this.pRotationY = this.pRotationY * DEG_TO_RAD;
|
|
763
|
+
this.pRotationZ = this.pRotationZ * DEG_TO_RAD;
|
|
763
764
|
} else {
|
|
764
765
|
// Change pRotation to degrees
|
|
765
|
-
this.pRotationX = this.pRotationX *
|
|
766
|
-
this.pRotationY = this.pRotationY *
|
|
767
|
-
this.pRotationZ = this.pRotationZ *
|
|
766
|
+
this.pRotationX = this.pRotationX * RAD_TO_DEG;
|
|
767
|
+
this.pRotationY = this.pRotationY * RAD_TO_DEG;
|
|
768
|
+
this.pRotationZ = this.pRotationZ * RAD_TO_DEG;
|
|
768
769
|
}
|
|
769
770
|
|
|
770
771
|
this._angleMode = mode;
|
|
@@ -781,7 +782,7 @@ function trigonometry(p5, fn){
|
|
|
781
782
|
*/
|
|
782
783
|
fn._toRadians = function(angle) {
|
|
783
784
|
if (this._angleMode === DEGREES) {
|
|
784
|
-
return angle *
|
|
785
|
+
return angle * DEG_TO_RAD;
|
|
785
786
|
}
|
|
786
787
|
return angle;
|
|
787
788
|
};
|
|
@@ -796,7 +797,7 @@ function trigonometry(p5, fn){
|
|
|
796
797
|
*/
|
|
797
798
|
fn._toDegrees = function(angle) {
|
|
798
799
|
if (this._angleMode === RADIANS) {
|
|
799
|
-
return angle *
|
|
800
|
+
return angle * RAD_TO_DEG;
|
|
800
801
|
}
|
|
801
802
|
return angle;
|
|
802
803
|
};
|
|
@@ -811,7 +812,7 @@ function trigonometry(p5, fn){
|
|
|
811
812
|
*/
|
|
812
813
|
fn._fromRadians = function(angle) {
|
|
813
814
|
if (this._angleMode === DEGREES) {
|
|
814
|
-
return angle *
|
|
815
|
+
return angle * RAD_TO_DEG;
|
|
815
816
|
}
|
|
816
817
|
return angle;
|
|
817
818
|
};
|
|
@@ -826,14 +827,14 @@ function trigonometry(p5, fn){
|
|
|
826
827
|
*/
|
|
827
828
|
fn._fromDegrees = function(angle) {
|
|
828
829
|
if (this._angleMode === RADIANS) {
|
|
829
|
-
return angle *
|
|
830
|
+
return angle * DEG_TO_RAD;
|
|
830
831
|
}
|
|
831
832
|
return angle;
|
|
832
833
|
};
|
|
833
834
|
}
|
|
834
835
|
|
|
835
|
-
export default trigonometry;
|
|
836
|
-
|
|
837
836
|
if(typeof p5 !== 'undefined'){
|
|
838
837
|
trigonometry(p5, p5.prototype);
|
|
839
838
|
}
|
|
839
|
+
|
|
840
|
+
export { trigonometry as default };
|