本文整理汇总了TypeScript中seedrandom.alea函数的典型用法代码示例。如果您正苦于以下问题:TypeScript alea函数的具体用法?TypeScript alea怎么用?TypeScript alea使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了alea函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: restoreRng
export function restoreRng(state: any): GeneratorInterface {
return new SeedrandomGenerator(
seedrandom.alea('', {
state
})
);
}
示例2: generate
function generate() {
const thisIterations = getControlInteger(iterationsInput, 0, MAX_ITERATIONS, DEFAULT_ITERATIONS);
const thisSeed = seedInput.value;
const thisVariation = getControlInteger(variationInput, 0, MAX_VARIATION, DEFAULT_VARIATION);
if (mask) {
if (iterations === thisIterations && seed === thisSeed && variation === thisVariation) {
return;
}
}
iterations = thisIterations;
seed = thisSeed;
variation = thisVariation;
const path = BlockFractal.makeBlockFractal({
random: seedrandom.alea(seed),
iterations,
variation: variation / 100
});
mask = path.rasterize();
//const maxSize = (Math.pow(2, iterations + 2) - 1) * zoom;
mult = Math.pow(2, 7 - iterations);
document.getElementById('label').innerText = seed;
document.title = `BlockFractal - ${seed}`;
let newHash = `#${encodeURIComponent(seed)}`;
if (variation != DEFAULT_VARIATION) {
newHash += `/v=${variation}`;
}
if (hashSeed !== seed) {
window.location.hash = newHash;
hashSeed = seed;
} else {
window.location.replace(newHash);
}
}
示例3: createRng
export function createRng(seed: number): GeneratorInterface {
if (seed < 0) {
seed = Math.random();
}
return new SeedrandomGenerator(
seedrandom.alea(seed as any, {
state: true
})
);
}
示例4: constructor
constructor(
mean: number, stdDeviation: number, dtype?: keyof RandNormalDataTypes,
truncated?: boolean, seed?: number) {
this.mean = mean;
this.stdDev = stdDeviation;
this.dtype = dtype;
this.nextVal = NaN;
this.truncated = truncated;
if (this.truncated) {
this.upper = this.mean + this.stdDev * 2;
this.lower = this.mean - this.stdDev * 2;
}
const seedValue = seed ? seed : Math.random();
this.random = seedrandom.alea(seedValue.toString());
}