Skip to content

Commit

Permalink
v4.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Jun 19, 2024
1 parent 2e547ae commit 486b5a5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# [4.3.10]

- PT-BR language translation updates for v4.3.9.
- Layer cloning will now preserve lasso changes.

# [4.3.9]

- Fix for quick settings not always applying.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tokenizer",
"version": "4.3.9",
"version": "4.3.10",
"license": "MIT",
"scripts": {
"lint": "npx eslint src/",
Expand Down
91 changes: 47 additions & 44 deletions src/tokenizer/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,53 +110,56 @@ export default class Layer {
// this.tintColor = "#f59042";
}

clone() {
const imgOptions = {
view: this.view,
img: this.img,
canvasHeight: this.source.height,
canvasWidth: this.source.width,
tintColor: this.tintColor,
tintLayer: this.tintLayer,
};

const colorOptions = {
view: this.view,
color: this.color,
canvasHeight: this.source.height,
canvasWidth: this.source.width,
};

const newLayer = this.img
? Layer.fromImage(imgOptions)
: Layer.fromColor(colorOptions);

newLayer.providesMask = this.providesMask;
newLayer.active = false;

newLayer.scale = this.scale;
newLayer.rotation = this.rotation;
newLayer.position = foundry.utils.deepClone(this.position);
newLayer.center = this.center;
newLayer.mirror = this.mirror;
newLayer.flipped = this.flipped;
newLayer.visible = this.visible;
newLayer.alpha = this.alpha;

if (this.mask) newLayer.mask = Utils.cloneCanvas(this.mask);
if (this.sourceMask) this.sourceMask = Utils.cloneCanvas(this.sourceMask);
if (this.renderedMask) this.renderedMask = Utils.cloneCanvas(this.renderedMask);
newLayer.customMask = this.customMask;
newLayer.customMaskLayers = this.customMaskLayers;
newLayer.appliedMaskIds = new Set(this.appliedMaskIds);

newLayer.compositeOperation = this.compositeOperation;
newLayer.maskCompositeOperation = this.maskCompositeOperation;
static fromLayer(layer) {
const newLayer = new Layer({
view: layer.view,
canvas: Utils.cloneCanvas(layer.canvas),
img: layer.img,
tintColor: layer.tintColor,
tintLayer: layer.tintLayer,
maskFromImage: layer.maskFromImage,
visible: layer.visible,
color: layer.color,
});

newLayer.colorLayer = layer.colorLayer;
newLayer.source = Utils.cloneCanvas(layer.source);
newLayer.canvas = Utils.cloneCanvas(layer.canvas);
newLayer.preview = Utils.cloneCanvas(layer.preview);
newLayer.original = Utils.cloneCanvas(layer.original);

newLayer.providesMask = layer.providesMask;

newLayer.scale = layer.scale;
newLayer.rotation = layer.rotation;
newLayer.position = foundry.utils.deepClone(layer.position);
newLayer.center = layer.center;
newLayer.mirror = layer.mirror;
newLayer.flipped = layer.flipped;
newLayer.visible = layer.visible;
newLayer.alpha = layer.alpha;

if (layer.mask) newLayer.mask = Utils.cloneCanvas(layer.mask);
if (layer.sourceMask) layer.sourceMask = Utils.cloneCanvas(layer.sourceMask);
if (layer.renderedMask) layer.renderedMask = Utils.cloneCanvas(layer.renderedMask);
newLayer.customMask = layer.customMask;
newLayer.customMaskLayers = layer.customMaskLayers;
newLayer.appliedMaskIds = new Set(layer.appliedMaskIds);

newLayer.compositeOperation = layer.compositeOperation;
newLayer.maskCompositeOperation = layer.maskCompositeOperation;
newLayer.maskFromImage = layer.maskFromImage;

newLayer.alphaPixelColors = new Set(layer.alphaPixelColors);
if (layer.previousAlphaPixelColors) newLayer.previousAlphaPixelColors = new Set(layer.previousAlphaPixelColors);

newLayer.redraw();
return newLayer;

newLayer.alphaPixelColors = new Set(this.alphaPixelColors);
if (this.previousAlphaPixelColors) newLayer.previousAlphaPixelColors = new Set(this.previousAlphaPixelColors);
}

clone() {
const newLayer = Layer.fromLayer(this);
return newLayer;
}

Expand Down

0 comments on commit 486b5a5

Please sign in to comment.