imagerot
Version:
A lightweight, cross-environment image library for applying unique effects via raw image buffers.
25 lines (24 loc) • 1.55 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nostalgia = void 0;
const nostalgia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ data, width, height, effects }) {
data = yield effects.degrade.method({ data, width, height }, { quality: 0.85 });
for (const direction of ['horizontal', 'vertical']) {
data = (yield effects.blur.method({ data, width, height }, { direction, intensity: 2 })) || data;
}
data = yield effects.chromaticAberration.method({ data, width, height }, { intensity: 2 });
data = yield effects.grayscale.method({ data, width, height }, { intensity: 0.275 });
data = yield effects.noise.method({ data, width, height }, { intensity: 8 });
data = yield effects.brightness.method({ data, width, height }, { brightness: 2 });
return data;
});
exports.nostalgia = nostalgia;