29 lines
766 B
TypeScript
29 lines
766 B
TypeScript
export abstract class BaseOperation<P> {
|
|
public parameters: P;
|
|
|
|
/**
|
|
* Some GEGL operations will run infinitely unless you limit the buffer in
|
|
* some way, so all operations must indicate whether or not they should be
|
|
* followed by a crop operation.
|
|
*/
|
|
public abstract appendCrop: boolean;
|
|
|
|
/** The GEGL operation name, starting with `gegl:`. */
|
|
public abstract name: string;
|
|
|
|
constructor(parameters: P) {
|
|
this.parameters = parameters;
|
|
}
|
|
|
|
public graph(): string[] {
|
|
const graph: string[] = [this.name];
|
|
|
|
for (const [key, value] of Object.entries(this.parameters)) {
|
|
const kebabCasedKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
graph.push(`${kebabCasedKey}=${value as string}`);
|
|
}
|
|
|
|
return graph;
|
|
}
|
|
}
|