From c9f87d365c9876de8b1e5829609f87af72bbaac6 Mon Sep 17 00:00:00 2001 From: Bauke Date: Thu, 10 Mar 2022 18:06:01 +0100 Subject: [PATCH] Add gegl:mosaic. --- source/gegl/exports.ts | 1 + source/gegl/mosaic.ts | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 source/gegl/mosaic.ts diff --git a/source/gegl/exports.ts b/source/gegl/exports.ts index 2b788d2..2269cf2 100644 --- a/source/gegl/exports.ts +++ b/source/gegl/exports.ts @@ -4,6 +4,7 @@ export * from './crop.js'; export * from './focus-blur.js'; export * from './generic.js'; export * from './mirrors.js'; +export * from './mosaic.js'; export * from './newsprint.js'; export * from './plasma.js'; export * from './simplex-noise.js'; diff --git a/source/gegl/mosaic.ts b/source/gegl/mosaic.ts new file mode 100644 index 0000000..bfb6643 --- /dev/null +++ b/source/gegl/mosaic.ts @@ -0,0 +1,48 @@ +import {BaseOperation} from './base.js'; + +export interface MosaicParameters { + antialiasing: boolean; + colorAveraging: boolean; + colorVariation: number; + jointsColor: string; + lightColor: string; + lightDir: number; + seed: number; + tileAllowSplit: boolean; + tileHeight: number; + tileNeatness: number; + tileSize: number; + tileSpacing: number; + tileSurface: boolean; + tileType: 'squares' | 'hexagons' | 'octagons' | 'triangles'; +} + +export class Mosaic extends BaseOperation { + public static default: MosaicParameters = { + antialiasing: true, + colorAveraging: true, + colorVariation: 0.2, + jointsColor: '#000', + lightColor: '#fff', + lightDir: 135, + seed: 0, + tileAllowSplit: true, + tileHeight: 4, + tileNeatness: 0.65, + tileSize: 15, + tileSpacing: 1, + tileSurface: false, + tileType: 'hexagons', + }; + + public get default() { + return Mosaic.default; + } + + public appendCrop = false; + public name = 'gegl:mosaic'; + + constructor(parameters?: Partial) { + super({...Mosaic.default, ...parameters}); + } +}