spaceship-sprites
Version:
Spaceship Sprite is a random ship sprite generator in typescript.
24 lines (23 loc) • 790 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
const transformFade = (dim, x, y, pixel) => {
let yR = y / dim[1];
return pixel.mixWeighed(new _1.Color(0, 0, 0), yR);
};
const transformVignette = (dim, x, y, pixel) => {
let cx = dim[0] / 2;
let cy = dim[1] / 2;
let dist = Math.sqrt(Math.pow(cx - (x + 0.5), 2) + Math.pow(cy - (y + 0.5), 2));
let w = clamp((dist / Math.max(dim[0], dim[1])) * 2, 0, 1);
return pixel.mixWeighed(new _1.Color(0, 0, 0), w);
};
class Utils {
}
Utils.clamp = clamp;
Utils.transformFade = transformFade;
Utils.transformVignette = transformVignette;
exports.default = Utils;