Skip to content

Commit

Permalink
Fix annoyances
Browse files Browse the repository at this point in the history
  • Loading branch information
acamposuribe committed Feb 17, 2024
1 parent 2a980b2 commit 9184099
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/p5.brush.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<title>p5.brush.js Example</title>
<script src="https://cdn.jsdelivr.net/npm/p5@1.9.0/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5.brush@1.1.1/dist/p5.brush.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5.brush@1.1.2/dist/p5.brush.js"></script>
<link rel="stylesheet" href="./style.css">
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p5.brush",
"version": "1.1.1",
"version": "1.1.2",
"description": "Unlock custom brushes, natural fill effects and intuitive hatching in p5.js",
"main": "src/index.js",
"module": "src/index.js",
Expand Down
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
// Set the renderer to the specified canvas or to the window if no ID is given
if (!canvasID && _isInstanced) canvasID = _inst;
_r = (!canvasID) ? window.self : canvasID;

// Load color blending
Mix.load(inst);
_isLoaded = true;
Expand Down Expand Up @@ -184,8 +185,7 @@
* @returns {number} A random number within the specified range.
*/
random(e = 0, r = 1) {
if (arguments.length === 1) {return this.map(rng(), 0, 1, 0, e); }
else {return this.map(rng(), 0, 1, e, r)}
return e + rng() * (r - e);
},

/**
Expand All @@ -205,8 +205,8 @@
* @returns {number} A random number following a normal distribution.
*/
gaussian(mean = 0, stdev = 1) {
const u = 1 - R.random();
const v = R.random();
const u = 1 - rng();
const v = rng();
const z = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
return z * stdev + mean;
},
Expand Down Expand Up @@ -728,6 +728,7 @@
* Deactivates the current vector field.
*/
export function noField () {
_ensureReady();
FF.isActive = false;
}

Expand Down

0 comments on commit 9184099

Please sign in to comment.