Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing multi canvas of victor layers #1301

Merged
merged 15 commits into from
Jun 27, 2023
Merged

Fix printing multi canvas of victor layers #1301

merged 15 commits into from
Jun 27, 2023

Conversation

aziz-access
Copy link
Contributor

What is the current behavior? (You can also link to an open issue here)

Fix printing multi canvas of victor layers

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications:

Other information:

@aziz-access aziz-access added the bug Incorrect or unexpected behaviors // Anomalies de fonctionnement label Jun 22, 2023
@aziz-access aziz-access self-assigned this Jun 22, 2023
@aziz-access aziz-access requested a review from alecarn June 22, 2023 17:38
Comment on lines 698 to 735
for (let index = 0; index < mapCanvas.length; index++) {
const canvas = mapCanvas[index];
if (canvas.width > 0) {
const opacity = canvas.parentElement.style.opacity || canvas.style.opacity;
mapContextResult.globalAlpha = opacity === '' ? 1 : Number(opacity);
const transform = canvas.style.transform;
let matrix: number[];
if (transform) {
// Get the transform parameters from the style's transform matrix
matrix = transform
.match(/^matrix\(([^\(]*)\)$/)[1]
.split(',')
.map(Number);
} else {
matrix = [
parseFloat(canvas.style.width) / canvas.width,
0,
0,
parseFloat(canvas.style.height) / canvas.height,
0,
0,
];
}
CanvasRenderingContext2D.prototype.setTransform.apply(
mapContextResult,
matrix
);
const backgroundColor = canvas.parentElement.style.backgroundColor;
if (backgroundColor) {
mapContextResult.fillStyle = backgroundColor;
mapContextResult.fillRect(0, 0, canvas.width, canvas.height);
}
mapContextResult.drawImage(canvas, 0, 0);
mapContextResult.globalAlpha = 1;
// reset canvas transform to initial
mapContextResult.setTransform(1, 0, 0, 1, 0, 0);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour la lisibilité, ça serait bien d'isoler ce code dans une méthode.

Suggested change
for (let index = 0; index < mapCanvas.length; index++) {
const canvas = mapCanvas[index];
if (canvas.width > 0) {
const opacity = canvas.parentElement.style.opacity || canvas.style.opacity;
mapContextResult.globalAlpha = opacity === '' ? 1 : Number(opacity);
const transform = canvas.style.transform;
let matrix: number[];
if (transform) {
// Get the transform parameters from the style's transform matrix
matrix = transform
.match(/^matrix\(([^\(]*)\)$/)[1]
.split(',')
.map(Number);
} else {
matrix = [
parseFloat(canvas.style.width) / canvas.width,
0,
0,
parseFloat(canvas.style.height) / canvas.height,
0,
0,
];
}
CanvasRenderingContext2D.prototype.setTransform.apply(
mapContextResult,
matrix
);
const backgroundColor = canvas.parentElement.style.backgroundColor;
if (backgroundColor) {
mapContextResult.fillStyle = backgroundColor;
mapContextResult.fillRect(0, 0, canvas.width, canvas.height);
}
mapContextResult.drawImage(canvas, 0, 0);
mapContextResult.globalAlpha = 1;
// reset canvas transform to initial
mapContextResult.setTransform(1, 0, 0, 1, 0, 0);
}
}
for (let index = 0; index < mapCanvas.length; index++) {
const canvas = mapCanvas[index];
if (canvas.width > 0) {
this.handleCanvas(...)
}
}

@alecarn alecarn merged commit 4c7f71f into next Jun 27, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect or unexpected behaviors // Anomalies de fonctionnement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants