@zushah/chalkboard 1.5.0 → 1.6.0
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/CHANGELOG.md +34 -8
- package/README.md +19 -17
- package/docs/README.md +1 -1
- package/examples/README.md +1 -1
- package/examples/fluid.js +1 -1
- package/examples/hyperbolics.js +4 -4
- package/examples/mandelbrot.js +1 -1
- package/examples/matr-donut.js +1 -1
- package/examples/newton.js +4 -4
- package/examples/quat-donut.js +1 -1
- package/package.json +5 -2
- package/src/Chalkboard.js +836 -451
- package/src/ChalkboardProcessing.js +706 -328
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
# Chalkboard changelog
|
|
2
2
|
All notable changes of every update of the Chalkboard library are recorded in this file.
|
|
3
3
|
|
|
4
|
+
## [v1.6.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0) - 12/25/2023
|
|
5
|
+
The eighth release of the Chalkboard library.
|
|
6
|
+
Commits: [`v1.5.0...v1.6.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.5.0...v1.6.0)
|
|
7
|
+
- Added a new type of function: the inverse function (`type` of `"inve"`)
|
|
8
|
+
- Added `stat.regression` to calculate different types of statistical regression models (linear, polynomial, exponential, etc.)
|
|
9
|
+
- Added `plot.CONTEXT` which determines the `CanvasRenderingContext2D` to use for plots
|
|
10
|
+
- Added LU decomposition and QR decomposition for matrices with `matr.LUdecomp` and `matr.QRdecomp`
|
|
11
|
+
- Added `matr.push` and `matr.pull` to add or remove rows or columns from matrices
|
|
12
|
+
- Added `matr.fill` to create a new matrix with a single value for all of the elements
|
|
13
|
+
- Added more commands for generating random numbers: `numb.exponential`, `numb.Bernoullian`, and `numb.Poissonian`
|
|
14
|
+
- Added `numb.Goldbach` to return an even number as a sum of two prime numbers
|
|
15
|
+
- Added `numb.Euler` to calculate Euler's totient function on a number
|
|
16
|
+
- Added `stat.shuffle` to randomly shuffle an array and `stat.subsets` to return all of the possible subsets of an array
|
|
17
|
+
- Changed all of the `plot` commands to use an optional `config` object parameter to configure their customizations (size, color, domain, etc.) instead of separate parameters for each of them
|
|
18
|
+
- Changed `real.function`, `real.val`, `calc.dfdx`, `calc.d2fdx2`, and `calc.fxdx` to accomodate the new `"inve"` function type
|
|
19
|
+
- Changed all of the `plot` commands, the `LOGO` command, and the `geom.line3D` command to use the new `plot.CONTEXT` value instead of `ctx` and `canvas`
|
|
20
|
+
- Changed `matr.empty` and `matr.random` to use `rows` and `cols` as parameters for the size of the matrix instead of `dimension`, and renamed the `dimension` parameter for `matr.identity` to `size`
|
|
21
|
+
- Changed `real.nrt` to be renamed as `real.root` (so `stat.mean` had to be changed since it was used there), and changed the `n` parameter in `comp.root` to be renamed as `index`
|
|
22
|
+
- Changed `numb.random` to use its default values only if the parameters are undefined instead of if the parameters are falsy
|
|
23
|
+
- Changed `matr.new` to use its `matrix` parameter instead of leaving it as declared but unused
|
|
24
|
+
- Changed `comp.d2fdz2` which was incorrectly named as `comp.df2dz2`
|
|
25
|
+
- Fixed (rewrote) `numb.Gaussian` which basically didn't work at all
|
|
26
|
+
- Fixed `real.pow` which returned `NaN` for 0 raised to the power of 0
|
|
27
|
+
- Fixed the default domain for `plot.function` which was incorrectly using the domain for domain colorings instead of normal graphs
|
|
28
|
+
|
|
29
|
+
|
|
4
30
|
## [v1.5.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.5.0) - 12/18/2023
|
|
5
31
|
The seventh release of the Chalkboard library.
|
|
6
|
-
Commits: [`v1.4.0...v1.5.0`](https://github.com/Zushah/Chalkboard/compare/v1.4.0...v1.5.0)
|
|
32
|
+
Commits: [`v1.4.0...v1.5.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.4.0...v1.5.0)
|
|
7
33
|
- Added Chalkboard as an npm package, so now it can be used on the server-side just like the client side
|
|
8
34
|
- Added `comp.function`, `comp.parse`, and `comp.val` to define, parse, and evaluate complex functions
|
|
9
35
|
- Added `calc.dfdz`, `calc.d2fdz2`, and `calc.fzdz` to calculate the first derivatives, second derivatives, and antiderivatives of complex functions
|
|
@@ -25,7 +51,7 @@ Commits: [`v1.4.0...v1.5.0`](https://github.com/Zushah/Chalkboard/compare/v1.4.0
|
|
|
25
51
|
|
|
26
52
|
## [v1.4.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.4.0) - 12/11/2023
|
|
27
53
|
The sixth release of the Chalkboard library.
|
|
28
|
-
Commits: [`v1.3.1...v1.4.0`](https://github.com/Zushah/Chalkboard/compare/v1.3.1...v1.4.0)
|
|
54
|
+
Commits: [`v1.3.1...v1.4.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.3.1...v1.4.0)
|
|
29
55
|
- Added many new commands for arrays: creating an array of random numbers, calculating different types of the norm (and the squared norm) of an array, calculating the normalized array, calculating the array that has the numbers that are equal to, greater than (or equal to), less than (or equal to), or some compound inequality of another number or array, calculating the skewness and kurtosis of an array, calculating the different quartiles of an array, and converting an array to a vector, matrix, object, string, or printing it in the console
|
|
30
56
|
- Added `plot.barplot`, `plot.lineplot`, and `plot.scatterplot` to plot arrays of data
|
|
31
57
|
- Added `.constrain` commands for numbers, arrays, complex numbers, quaternions, vectors, and matrices to constrain their values within a range
|
|
@@ -45,14 +71,14 @@ Commits: [`v1.3.1...v1.4.0`](https://github.com/Zushah/Chalkboard/compare/v1.3.1
|
|
|
45
71
|
|
|
46
72
|
## [v1.3.1](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.1) - 12/04/2023
|
|
47
73
|
The fifth release of the Chalkboard library.
|
|
48
|
-
Commits: [`v1.3.0...v1.3.1`](https://github.com/Zushah/Chalkboard/compare/v1.3.0...v1.3.1)
|
|
74
|
+
Commits: [`v1.3.0...v1.3.1`](https://www.github.com/Zushah/Chalkboard/compare/v1.3.0...v1.3.1)
|
|
49
75
|
- Fixed `matr.translator` which was misspelled
|
|
50
76
|
- Fixed `matr.rotator` which didn't work for two-dimensional rotations and was also misspelled
|
|
51
77
|
- Fixed `calc.grad` which didn't work for vector fields because of another misspelling
|
|
52
78
|
|
|
53
79
|
## [v1.3.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0) - 12/04/2023
|
|
54
80
|
The fourth release of the Chalkboard library.
|
|
55
|
-
Commits: [`v1.2.0...v1.3.0`](https://github.com/Zushah/Chalkboard/compare/v1.2.0...v1.3.0)
|
|
81
|
+
Commits: [`v1.2.0...v1.3.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.2.0...v1.3.0)
|
|
56
82
|
- Added multivariable calculus, with commands for directional differentiation, multivariable chain rule, gradient (partial differentiation), double gradient (second-order partial differentiation), divergence, curl, double integration, line/surface integration, arc length, surface area, and curvature
|
|
57
83
|
- Added second-order differentiation with `calc.d2fdx2`, unit tangent vectors for parametric curves with `calc.tangent`, unit normal vectors with `calc.normal`, and unit binormal vectors with `calc.binormal`
|
|
58
84
|
- Functions that previously had the `type` property of `"para"` should now be changed to `"curv"`
|
|
@@ -71,11 +97,11 @@ Commits: [`v1.2.0...v1.3.0`](https://github.com/Zushah/Chalkboard/compare/v1.2.0
|
|
|
71
97
|
- Changed all `plot` commands so they can now optionally have their opacity changed with the `rgba` parameter (which previously used to only be `rgb`)
|
|
72
98
|
- Changed `numb.Gaussian` to use `for(;;)` instead of `while(typeof x === "undefined")`
|
|
73
99
|
- Changed the name of `calc.average` to `calc.mean`
|
|
74
|
-
- Fixed `matr.invert` returning `NaN` values when `0` is on the diagonal of a matrix, thanks to [@bhavjitChauhan](https://github.com/bhavjitChauhan).
|
|
100
|
+
- Fixed `matr.invert` returning `NaN` values when `0` is on the diagonal of a matrix, thanks to [@bhavjitChauhan](https://www.github.com/bhavjitChauhan).
|
|
75
101
|
|
|
76
102
|
## [v1.2.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.2.0) - 11/27/2023
|
|
77
103
|
The third release of the Chalkboard library.
|
|
78
|
-
Commits: [`v1.1.0...v1.2.0`](https://github.com/Zushah/Chalkboard/compare/v1.1.0...v1.2.0)
|
|
104
|
+
Commits: [`v1.1.0...v1.2.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.1.0...v1.2.0)
|
|
79
105
|
- Added new matrix commands for the trace of a matrix, the row space of a matrix, the column space, and null space, the exponentation, the row Echelon form (Gaussian elimination), solving systems of linear equations, and conversion of a matrix to an object
|
|
80
106
|
- Added `plot.comp`, `plot.vec2`, `plot.vec3`, and `plot.matr` to replace `comp.display`, `vec2.display`, `vec3.display`, and `matr.display`
|
|
81
107
|
- Added `numb.binomial` to calculate binomial coefficients
|
|
@@ -89,7 +115,7 @@ Commits: [`v1.1.0...v1.2.0`](https://github.com/Zushah/Chalkboard/compare/v1.1.0
|
|
|
89
115
|
|
|
90
116
|
## [v1.1.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.1.0) - 11/13/2023
|
|
91
117
|
The second release of the Chalkboard library.
|
|
92
|
-
Commits: [`v1.0.0...v1.1.0`](https://github.com/Zushah/Chalkboard/compare/v1.0.0...v1.1.0)
|
|
118
|
+
Commits: [`v1.0.0...v1.1.0`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...v1.1.0)
|
|
93
119
|
- Added `numb.prime` to calculate the nth prime number, `numb.nextPrime` to calculate the next prime number, and `numb.primeGap` to calculate the prime gap with an interval
|
|
94
120
|
- Added `numb.factors` to calculate the prime factorization of a number and `numb.divisors` to calculate the divisors of a number
|
|
95
121
|
- Added `numb.Gaussian` to calculate a random number based on a Gaussian distribution
|
|
@@ -108,4 +134,4 @@ Commits: [`v1.0.0...v1.1.0`](https://github.com/Zushah/Chalkboard/compare/v1.0.0
|
|
|
108
134
|
|
|
109
135
|
## [v1.0.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) - 11/06/2023
|
|
110
136
|
The first release of the Chalkboard library.
|
|
111
|
-
Commits: [`v1.0.0...main`](https://github.com/Zushah/Chalkboard/compare/v1.0.0...main)
|
|
137
|
+
Commits: [`v1.0.0...main`](https://www.github.com/Zushah/Chalkboard/compare/v1.0.0...main)
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<p align="center"><a href="https://www.github.com/Zushah/Chalkboard"><img src="./assets/Chalkboard-logo.png" width="50%"></a></p>
|
|
2
2
|
<p align="center">
|
|
3
|
-
<a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v1.
|
|
3
|
+
<a href="https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0"><img src="https://img.shields.io/github/v/release/Zushah/Chalkboard" alt="Latest release"></a>
|
|
4
4
|
<a href="https://www.codefactor.io/repository/github/zushah/chalkboard"><img src="https://www.codefactor.io/repository/github/zushah/chalkboard/badge" alt="CodeFactor grade"></a>
|
|
5
|
-
<a href="https://www.npmjs.com/package/@zushah/chalkboard"><img src="https://img.shields.io/
|
|
6
|
-
<a href="https://github.com/Zushah/Chalkboard/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-yellow" alt="MIT License"></a>
|
|
7
|
-
<a href="https://www.jsdelivr.com/package/gh/Zushah/Chalkboard"><img src="https://data.jsdelivr.com/v1/package/gh/Zushah/Chalkboard/badge" alt="
|
|
5
|
+
<a href="https://www.npmjs.com/package/@zushah/chalkboard"><img src="https://img.shields.io/npm/dt/@zushah/chalkboard" alt="npm downloads"></a>
|
|
6
|
+
<a href="https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-yellow" alt="MIT License"></a>
|
|
7
|
+
<a href="https://www.jsdelivr.com/package/gh/Zushah/Chalkboard"><img src="https://data.jsdelivr.com/v1/package/gh/Zushah/Chalkboard/badge" alt="jsDelivr requests"></a>
|
|
8
8
|
<br>
|
|
9
9
|
<a href="https://zushah.github.io/Chalkboard/home.html">https://zushah.github.io/Chalkboard/home.html</a>
|
|
10
10
|
</p>
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
</ol>
|
|
22
22
|
|
|
23
23
|
# About
|
|
24
|
-
The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by [Zushah](https://www.github.com/Zushah) during 2022 and 2023 and then [released](https://github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v1.
|
|
24
|
+
The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by [Zushah](https://www.github.com/Zushah) during 2022 and 2023 and then [released](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.0.0) on November 6, 2023. As per the latest release of [v1.6.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0), Chalkboard has 444 different commands. The library is available for regular JavaScript on both the client-side and the server-side as well as [Proccesing.js](https://www.processing.org/) (fully compatible with [Khan Academy](https://www.khanacademy.org/cs/chalkboard/6708642430369792)). Chalkboard's website can be visited [here](https://zushah.github.io/Chalkboard/home.html).
|
|
25
25
|
|
|
26
26
|
# Installation
|
|
27
27
|
If your JavaScript project is being run on the client-side within a webpage, you can install Chalkboard with this HTML tag:
|
|
28
28
|
```html
|
|
29
|
-
<script
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/gh/Zushah/Chalkboard@1.6.0/src/Chalkboard.min.js"></script>
|
|
30
30
|
```
|
|
31
31
|
If your JavaScript project is being run on the server-side within the [Node.js](https://nodejs.org/en) environment, you can install Chalkboard with this console command:
|
|
32
32
|
```bash
|
|
33
|
-
npm install @zushah/chalkboard@1.
|
|
33
|
+
npm install @zushah/chalkboard@1.6.0
|
|
34
34
|
```
|
|
35
|
-
Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.
|
|
35
|
+
Alternatively, you can simply download the [latest release](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0) and put the relevant files in your project's directory.
|
|
36
36
|
|
|
37
37
|
More methods and details about installing Chalkboard can be read [here](https://zushah.github.io/Chalkboard/installation.html).
|
|
38
38
|
|
|
@@ -71,7 +71,9 @@ const cb = Chalkboard; // Chalkboard is a nice name but it's also long
|
|
|
71
71
|
/*
|
|
72
72
|
Note that this code is written on the client-side
|
|
73
73
|
You can write all the same code on the server-side, too, but you would have to replace the line above with:
|
|
74
|
-
|
|
74
|
+
import cb from "@zushah/chalkboard";
|
|
75
|
+
OR
|
|
76
|
+
const cb = require("@zushah/chalkboard");
|
|
75
77
|
*/
|
|
76
78
|
|
|
77
79
|
let f = cb.real.function("Math.cos(2 * x)"); // f(x) = cos(2x)
|
|
@@ -85,16 +87,16 @@ let fnds = cb.calc.fnds(f, r, cb.PI(-1/2), cb.PI(1/2), 0, cb.PI(2)); // Flux of
|
|
|
85
87
|
|
|
86
88
|
let primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
|
|
87
89
|
let midPrime = cb.stat.median(primes); // Median number in the primes array
|
|
88
|
-
cb.plot.barplot(primes, cb.stat.array(0, 100, 11), 5,
|
|
90
|
+
cb.plot.barplot(primes, cb.stat.array(0, 100, 11), {size: 5, strokeStyle: "black", fillStyle: "blue"}); // Barplot of the primes array with a bin size of 10, a scale of 2, a stroke color of black, and a fill color of blue
|
|
89
91
|
|
|
90
92
|
let z = cb.comp.new(1, 1); // z = 1 + i
|
|
91
93
|
let zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
|
|
92
|
-
let f = cb.comp.function("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
|
|
94
|
+
let f = cb.comp.function("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
|
|
93
95
|
cb.plot.function(f); // Plots the domain coloring of f
|
|
94
96
|
|
|
95
97
|
let r = cb.real.function(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
|
|
96
|
-
cb.plot.xyplane(2); // Draws the Cartesian coordinate plane
|
|
97
|
-
cb.plot.function(r, 2,
|
|
98
|
+
cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
|
|
99
|
+
cb.plot.function(r, {size: 2, strokeStyle: "rgb(255, 100, 100)", domain: [0, cb.PI(2)]}); // Plots r(t) scaled by 2 colored light red from t = 0 to t = π/2
|
|
98
100
|
|
|
99
101
|
let a = cb.vec3.new(1, 2, 3); // Vector a = (1, 2, 3)
|
|
100
102
|
let b = cb.vec3.new(4, 5, 6); // Vector b = (4, 5, 6)
|
|
@@ -111,7 +113,7 @@ let mi = cb.matr.invert(m); // mi is the inverse of m
|
|
|
111
113
|
let mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
|
|
112
114
|
cb.matr.print(mmi); // Prints mmi in the console
|
|
113
115
|
```
|
|
114
|
-
More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples.html) with their source code [here](https://github.com/Zushah/Chalkboard/tree/main/examples).
|
|
116
|
+
More examples that are more interesting can be seen [here](https://zushah.github.io/Chalkboard/examples.html) with their source code [here](https://www.github.com/Zushah/Chalkboard/tree/main/examples).
|
|
115
117
|
|
|
116
118
|
# Contributing
|
|
117
119
|
<ol>
|
|
@@ -121,12 +123,12 @@ More examples that are more interesting can be seen [here](https://zushah.github
|
|
|
121
123
|
<li>Open a pull request. It will be reviewed soon and then merged to the main branch.</li>
|
|
122
124
|
</ol>
|
|
123
125
|
|
|
124
|
-
The changelog can be read [here](https://github.com/Zushah/Chalkboard/blob/main/CHANGELOG.md).
|
|
126
|
+
The changelog can be read [here](https://www.github.com/Zushah/Chalkboard/blob/main/CHANGELOG.md).
|
|
125
127
|
|
|
126
|
-
The Chalkboard library is available under the [MIT License](https://github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
|
|
128
|
+
The Chalkboard library is available under the [MIT License](https://www.github.com/Zushah/Chalkboard/blob/main/LICENSE.md).
|
|
127
129
|
|
|
128
130
|
# Acknowledgements
|
|
129
|
-
Thanks to [Bhavjit Chauhan](https://github.com/bhavjitChauhan) for his [contribution](https://www.github.com/Zushah/Chalkboard/pull/1) to [v1.3.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
|
|
131
|
+
Thanks to [Bhavjit Chauhan](https://www.github.com/bhavjitChauhan) for his [contribution](https://www.github.com/Zushah/Chalkboard/pull/1) to [v1.3.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.3.0).\
|
|
130
132
|
Thanks to [G. Yang](https://www.github.com/gyang0) for his [contribution](https://www.github.com/Zushah/zushah.github.io/pull/1) to the [documentation](https://www.github.com/Zushah/zushah.github.io/tree/main/Chalkboard).
|
|
131
133
|
|
|
132
134
|
# Contact
|
package/docs/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# Chalkboard documentation
|
|
2
|
-
The documentation for [Chalkboard v1.
|
|
2
|
+
The documentation for [Chalkboard v1.6.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0) can be visited [here](https://zushah.github.io/Chalkboard/documentation.html/). Its source code is located [here](https://www.github.com/Zushah/zushah.github.io/blob/main/Chalkboard/documentation.html).
|
package/examples/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Chalkboard examples
|
|
2
|
-
Six basic programs made by Zushah that utilize [Chalkboard v1.
|
|
2
|
+
Six basic programs made by Zushah that utilize [Chalkboard v1.6.0](https://www.github.com/Zushah/Chalkboard/releases/tag/v1.6.0) are located in this directory.
|
|
3
3
|
|
|
4
4
|
They can be viewed in action here:
|
|
5
5
|
- [fluid.js](https://zushah.github.io/Chalkboard/examples/fluid.html)
|
package/examples/fluid.js
CHANGED
package/examples/hyperbolics.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
|
|
3
|
-
Version 1.
|
|
3
|
+
Version 1.6.0 Example Program: Hyperbolic Functions
|
|
4
4
|
Authored by Zushah ===> https://www.github.com/Zushah
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -15,12 +15,12 @@ var theta = 0;
|
|
|
15
15
|
function main() {
|
|
16
16
|
ctx.fillStyle = "rgb(255, 255, 255)";
|
|
17
17
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
18
|
-
cb.plot.xyplane(
|
|
18
|
+
cb.plot.xyplane({lineWidth: 2});
|
|
19
19
|
|
|
20
20
|
// Plot the unit hyperbola with a parametric function (see: https://en.wikipedia.org/wiki/Hyperbola)
|
|
21
21
|
var f = cb.real.function(["(t * t + 1) / (2 * t)", "(t * t - 1) / (2 * t)"], "curv");
|
|
22
|
-
cb.plot.function(f,
|
|
23
|
-
cb.plot.function(f,
|
|
22
|
+
cb.plot.function(f, {strokeStyle: "rgb(100, 100, 255)", domain: [0, 10], lineWidth: 4});
|
|
23
|
+
cb.plot.function(f, {strokeStyle: "rgb(100, 100, 255)", domain: [-10, 0], lineWidth: 4});
|
|
24
24
|
|
|
25
25
|
// The two main hyperbolic trigonometric functions, hyperbolic sine (sinh) and hyperbolic cosine (cosh)
|
|
26
26
|
var x = cb.trig.cosh(theta);
|
package/examples/mandelbrot.js
CHANGED
package/examples/matr-donut.js
CHANGED
package/examples/newton.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
The Chalkboard Library ===> https://www.github.com/Zushah/Chalkboard
|
|
3
|
-
Version 1.
|
|
3
|
+
Version 1.6.0 Example Program: Newton's Method
|
|
4
4
|
Authored by Zushah ===> https://www.github.com/Zushah
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -26,10 +26,10 @@ var y = cb.real.function(cb.calc.dfdx(f, root) + " * (x - " + root + ") + " + cb
|
|
|
26
26
|
function main() {
|
|
27
27
|
ctx.fillStyle = "rgb(255, 255, 255)";
|
|
28
28
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
29
|
-
cb.plot.xyplane(
|
|
29
|
+
cb.plot.xyplane({lineWidth: 2});
|
|
30
30
|
|
|
31
31
|
// Draw the polynomial
|
|
32
|
-
cb.plot.function(f,
|
|
32
|
+
cb.plot.function(f, {strokeStyle: "rgb(100, 100, 255)", lineWidth: 4});
|
|
33
33
|
ctx.fillStyle = "rgb(0, 0, 0)";
|
|
34
34
|
ctx.font = "50px Times New Roman";
|
|
35
35
|
ctx.fillText("f(x) = " + c1.toFixed(2) + "x⁴ + " + c2.toFixed(2) + "x³ + " + c3.toFixed(2) + "x² + " + c4.toFixed(2) + "x + " + c5.toFixed(2), 20, 70);
|
|
@@ -38,7 +38,7 @@ function main() {
|
|
|
38
38
|
if(cb.real.val(f, root).toFixed(1) == 0) {
|
|
39
39
|
ctx.fillText("y = " + cb.calc.dfdx(f, root).toFixed(2) + "x - " + (cb.calc.dfdx(f, root) * root).toFixed(2), 20, 120);
|
|
40
40
|
ctx.fillText("A possible root is at x = " + root.toFixed(2), 20, 170);
|
|
41
|
-
cb.plot.function(y,
|
|
41
|
+
cb.plot.function(y, {strokeStyle: "rgb(255, 100, 100)", lineWidth: 4});
|
|
42
42
|
ctx.save();
|
|
43
43
|
ctx.translate(canvas.width / 2, canvas.height / 2);
|
|
44
44
|
ctx.beginPath();
|
package/examples/quat-donut.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zushah/chalkboard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "The Chalkboard library provides a plethora of mathematical functionalities for its user.",
|
|
5
5
|
"main": "src/Chalkboard.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,5 +20,8 @@
|
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/Zushah/Chalkboard/issues"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://zushah.github.io/Chalkboard/home.html"
|
|
23
|
+
"homepage": "https://zushah.github.io/Chalkboard/home.html",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
}
|
|
24
27
|
}
|