mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Fix recursive handling of layers in flatten().
This commit is contained in:
@@ -1296,36 +1296,35 @@ Guacamole.Client = function(tunnel) {
|
|||||||
canvas.width = default_layer.width;
|
canvas.width = default_layer.width;
|
||||||
canvas.height = default_layer.height;
|
canvas.height = default_layer.height;
|
||||||
|
|
||||||
// Copy image from source
|
|
||||||
var context = canvas.getContext("2d");
|
var context = canvas.getContext("2d");
|
||||||
context.drawImage(default_layer.getLayer().getCanvas(), 0, 0);
|
|
||||||
|
|
||||||
function draw_all(layers, x, y) {
|
function draw_layer(layer, x, y) {
|
||||||
|
|
||||||
var index, layer;
|
// Draw layer
|
||||||
|
if (layer.width > 0 && layer.height > 0) {
|
||||||
|
|
||||||
// Draw all immediate children
|
// Save and update alpha
|
||||||
for (index in layers) {
|
var initial_alpha = context.globalAlpha;
|
||||||
layer = layers[index];
|
context.globalAlpha *= layer.alpha / 255.0;
|
||||||
|
|
||||||
context.globalAlpha = layer.alpha / 255.0;
|
// Copy data
|
||||||
context.drawImage(layer.getLayer().getCanvas(),
|
context.drawImage(layer.getLayer().getCanvas(), x, y);
|
||||||
layer.x + x, layer.y + y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw all children of children
|
// Draw all children
|
||||||
for (layer in layers) {
|
for (var index in layer.children) {
|
||||||
layer = layers[index];
|
var child = layer.children[index];
|
||||||
draw_all(layer.children, layer.x + x, layer.y + y);
|
draw_layer(child, x + child.x, y + child.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore alpha
|
// Restore alpha
|
||||||
context.globalAlpha = 1;
|
context.globalAlpha = initial_alpha;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw all immediate children
|
}
|
||||||
draw_all(default_layer.children, 0, 0);
|
|
||||||
|
// Draw default layer and all children
|
||||||
|
draw_layer(default_layer, 0, 0);
|
||||||
|
|
||||||
// Return new canvas copy
|
// Return new canvas copy
|
||||||
return canvas;
|
return canvas;
|
||||||
@@ -1403,13 +1402,13 @@ Guacamole.Client.LayerContainer = function(index, width, height) {
|
|||||||
* The width of this layer in pixels.
|
* The width of this layer in pixels.
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
this.width = 0;
|
this.width = width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The height of this layer in pixels.
|
* The height of this layer in pixels.
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
this.height = 0;
|
this.height = height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent layer container of this layer, if any.
|
* The parent layer container of this layer, if any.
|
||||||
|
Reference in New Issue
Block a user