pathanimator/inbrowser/ts/algorithm/Noise.ts

19 lines
413 B
TypeScript
Raw Permalink Normal View History

2022-01-19 18:34:37 +01:00
/// <reference path="Algorithm.ts" />
/**
* Demo algorithm that fills image with noise
*/
class Noise extends Algorithm {
/**
* Run the algorithm
*/
run() {
var width = this.output.getWidth();
var height = this.output.getHeight();
var pixels = this.output.getPixels8();
var end = width * height * 3;
for (var i = 0; i < end; ++i) {
pixels[i] = Math.random()*255;
}
}
}