Files
ubuntu-post-install/paintplus/frontend/src/js/modules/layer/flatten.js
T
Claude 084922afaa paintplus: vendor the app source and rename from EditmaskwithAI
Bring the full EditmaskwithAI application into the repo under paintplus/
(429 files) so the service is self-contained — the installer copies the
vendored source to ~/docker/paintplus/src instead of cloning at runtime.

Rename to PaintPlus (service + branding; app logic untouched):
- services/editmaskwithai.sh -> services/paintplus.sh (register_service
  paintplus, install_paintplus, ~/docker/paintplus, Caddy paintplus:8000,
  Authelia option preserved)
- container names -> paintplus across docker-compose*.yml; dev network
  -> paintplus-network
- browser <title> -> "PaintPlus - AI Image Editor"; README heading ->
  PaintPlus with upstream provenance note
- README utilities table: editmaskwithai -> paintplus

Backend/frontend code (help strings referencing the old container name,
the ai_photo_edit.db filename) is intentionally left as-is to avoid
touching application logic.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nb2vJ8W7bHKx1JXVvpCraH
2026-06-26 05:48:43 +00:00

56 lines
1.4 KiB
JavaScript

import app from './../../app.js';
import config from './../../config.js';
import Base_layers_class from './../../core/base-layers.js';
import alertify from './../../../../node_modules/alertifyjs/build/alertify.min.js';
class Layer_flatten_class {
constructor() {
this.Base_layers = new Base_layers_class();
}
flatten() {
//create tmp canvas
var canvas = document.createElement('canvas');
canvas.width = config.WIDTH;
canvas.height = config.HEIGHT;
var ctx = canvas.getContext("2d");
var layers_sorted = this.Base_layers.get_sorted_layers();
//paint layers
for (var i = layers_sorted.length - 1; i >= 0; i--) {
var layer = layers_sorted[i];
ctx.globalAlpha = layer.opacity / 100;
ctx.globalCompositeOperation = layer.composition;
this.Base_layers.render_object(ctx, layer);
}
//create requested layer
var params = [];
params.type = 'image';
params.name = 'Merged';
params.data = canvas.toDataURL("image/png");
//remove rest of layers
let delete_actions = [];
for (var i = config.layers.length - 1; i >= 0; i--) {
delete_actions.push(new app.Actions.Delete_layer_action(config.layers[i].id));
}
// Run actions
app.State.do_action(
new app.Actions.Bundle_action('flatten_image', 'Flatten Image', [
new app.Actions.Insert_layer_action(params),
...delete_actions
])
);
canvas.width = 1;
canvas.height = 1;
}
}
export default Layer_flatten_class;