@code-not-art/core
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -8,4 +8,16 @@ /** | ||
y: number; | ||
constructor(x: number, y: number); | ||
/** | ||
* Vec2 constructor. If only one number is passed in, the class property y will be set to the same value as x. | ||
* @example specify single parameter | ||
* new Vec2(10) | ||
* // same as Vec2(10,10) | ||
* @param x | ||
* @param y Optional, if ommitted, use same x value for both x and y | ||
*/ | ||
constructor(x: number, y?: number); | ||
magnitude(): number; | ||
/** | ||
* | ||
* @returns Angle in radians of the vector's rotation from 0. Assumes vector is cartesian coordinates. | ||
*/ | ||
angle(): number; | ||
@@ -61,4 +73,11 @@ add(value: Vec2 | number): Vec2; | ||
static ones(): Vec2; | ||
/** | ||
* Create a new Vec2 based on another Vec2 or a single number. | ||
* | ||
* For a Vec2 argument, this will return a new Vec2 with the same x and y values as the provided Vec2. | ||
* For a number argument, this will return a new Vec2 with both x and y equal to the provided number. | ||
*/ | ||
static from(prototype: Vec2 | number): Vec2; | ||
} | ||
export default Vec2; | ||
//# sourceMappingURL=Vec2.d.ts.map |
@@ -8,2 +8,10 @@ "use strict"; | ||
var Vec2 = /** @class */ (function () { | ||
/** | ||
* Vec2 constructor. If only one number is passed in, the class property y will be set to the same value as x. | ||
* @example specify single parameter | ||
* new Vec2(10) | ||
* // same as Vec2(10,10) | ||
* @param x | ||
* @param y Optional, if ommitted, use same x value for both x and y | ||
*/ | ||
function Vec2(x, y) { | ||
@@ -18,3 +26,3 @@ var _this = this; | ||
this.x = x; | ||
this.y = y; | ||
this.y = y === undefined ? x : y; | ||
} | ||
@@ -25,2 +33,6 @@ /* ===== Properties ===== */ | ||
}; | ||
/** | ||
* | ||
* @returns Angle in radians of the vector's rotation from 0. Assumes vector is cartesian coordinates. | ||
*/ | ||
Vec2.prototype.angle = function () { | ||
@@ -96,3 +108,3 @@ return Math.atan2(this.y, this.x); | ||
}; | ||
// ===== Some generators for common simple vectors | ||
// ===== Static generators for common simple vectors | ||
/** | ||
@@ -126,2 +138,16 @@ * Vec2 for the origin of the plane. Shortcut for `new Vec2(0, 0)` | ||
}; | ||
/** | ||
* Create a new Vec2 based on another Vec2 or a single number. | ||
* | ||
* For a Vec2 argument, this will return a new Vec2 with the same x and y values as the provided Vec2. | ||
* For a number argument, this will return a new Vec2 with both x and y equal to the provided number. | ||
*/ | ||
Vec2.from = function (prototype) { | ||
if (prototype instanceof Vec2) { | ||
return new Vec2(prototype.x, prototype.y); | ||
} | ||
else { | ||
return new Vec2(prototype); | ||
} | ||
}; | ||
return Vec2; | ||
@@ -128,0 +154,0 @@ }()); |
@@ -118,3 +118,3 @@ "use strict"; | ||
Random.prototype.float = function (min, max, distribution) { | ||
return this.next(distribution) * (max - min + 1) + min; | ||
return this.next(distribution) * (max - min) + min; | ||
}; | ||
@@ -121,0 +121,0 @@ Random.prototype.angle = function (distribution) { |
@@ -0,1 +1,2 @@ | ||
export { default as curl } from './curl'; | ||
export declare type Noise2D = (x: number, y: number) => number; | ||
@@ -2,0 +3,0 @@ export declare type Noise3D = (x: number, y: number, z: number) => number; |
@@ -32,5 +32,10 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.simplex4 = exports.simplex3 = exports.simplex2 = void 0; | ||
exports.simplex4 = exports.simplex3 = exports.simplex2 = exports.curl = void 0; | ||
var openSimplex = __importStar(require("open-simplex-noise")); | ||
var curl_1 = require("./curl"); | ||
Object.defineProperty(exports, "curl", { enumerable: true, get: function () { return __importDefault(curl_1).default; } }); | ||
var defaultOptions = { | ||
@@ -37,0 +42,0 @@ amplitude: 1, |
export declare function array(length: number): number[]; | ||
export declare function range(start: number, end: number): number[]; | ||
export declare function sequence<T>(count: number, method: (i: number) => T): T[]; | ||
export declare function repeat(count: number, action: (index: number) => void): void; | ||
export declare function repeat(count: number, action: (index: number, stopLoop: () => void) => void): void; | ||
//# sourceMappingURL=arrays.d.ts.map |
@@ -17,4 +17,14 @@ "use strict"; | ||
function repeat(count, action) { | ||
var _loop_1 = function (i) { | ||
var stopRequested = false; | ||
var stopLoop = function () { return (stopRequested = true); }; | ||
action(i, stopLoop); | ||
if (stopRequested) { | ||
return "break"; | ||
} | ||
}; | ||
for (var i = 0; i < count; i++) { | ||
action(i); | ||
var state_1 = _loop_1(i); | ||
if (state_1 === "break") | ||
break; | ||
} | ||
@@ -21,0 +31,0 @@ } |
{ | ||
"name": "@code-not-art/core", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "HTML 5 Canvas Drawing Library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -9,5 +9,13 @@ /** | ||
constructor(x: number, y: number) { | ||
/** | ||
* Vec2 constructor. If only one number is passed in, the class property y will be set to the same value as x. | ||
* @example specify single parameter | ||
* new Vec2(10) | ||
* // same as Vec2(10,10) | ||
* @param x | ||
* @param y Optional, if ommitted, use same x value for both x and y | ||
*/ | ||
constructor(x: number, y?: number) { | ||
this.x = x; | ||
this.y = y; | ||
this.y = y === undefined ? x : y; | ||
} | ||
@@ -19,2 +27,6 @@ | ||
} | ||
/** | ||
* | ||
* @returns Angle in radians of the vector's rotation from 0. Assumes vector is cartesian coordinates. | ||
*/ | ||
angle() { | ||
@@ -105,3 +117,3 @@ return Math.atan2(this.y, this.x); | ||
// ===== Some generators for common simple vectors | ||
// ===== Static generators for common simple vectors | ||
@@ -139,3 +151,17 @@ /** | ||
} | ||
/** | ||
* Create a new Vec2 based on another Vec2 or a single number. | ||
* | ||
* For a Vec2 argument, this will return a new Vec2 with the same x and y values as the provided Vec2. | ||
* For a number argument, this will return a new Vec2 with both x and y equal to the provided number. | ||
*/ | ||
static from(prototype: Vec2 | number) { | ||
if (prototype instanceof Vec2) { | ||
return new Vec2(prototype.x, prototype.y); | ||
} else { | ||
return new Vec2(prototype); | ||
} | ||
} | ||
} | ||
export default Vec2; |
@@ -116,3 +116,3 @@ import srng from 'seed-random'; | ||
float(min: number, max: number, distribution?: Distribution): number { | ||
return this.next(distribution) * (max - min + 1) + min; | ||
return this.next(distribution) * (max - min) + min; | ||
} | ||
@@ -119,0 +119,0 @@ |
import * as openSimplex from 'open-simplex-noise'; | ||
export { default as curl } from './curl'; | ||
@@ -3,0 +4,0 @@ export type Noise2D = (x: number, y: number) => number; |
@@ -10,6 +10,14 @@ export function array(length: number) { | ||
} | ||
export function repeat(count: number, action: (index: number) => void): void { | ||
export function repeat( | ||
count: number, | ||
action: (index: number, stopLoop: () => void) => void, | ||
): void { | ||
for (let i = 0; i < count; i++) { | ||
action(i); | ||
let stopRequested = false; | ||
const stopLoop = () => (stopRequested = true); | ||
action(i, stopLoop); | ||
if (stopRequested) { | ||
break; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
243906
129
3726