Skip to content

Commit

Permalink
Fixed isolation style placement for inverted mask
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozo132 committed Jan 9, 2025
1 parent 4a5525a commit 00d5b9a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zpl2svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
// YYYY-MM-DD HH:MM:SS
const timestamp = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')

svg.push(`<svg class="${main_classes}" width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="background-color: #FFF;">`)
svg.push(`<svg class="${main_classes}" width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="background-color: #FFF; isolation: isolate; position: relative;">`)
// svg.push(`<rect x="0" y="0" width="100%" height="100%" fill="#FFF"/>`)

svg.push(` <!-- ######################################################### -->`)
Expand All @@ -273,7 +273,7 @@
svg.push(` <!-- Timestamp: ${timestamp} -->`)
svg.push(` <!-- ######################################################### -->`)

svg.push(` <g transform="scale(${scale}) translate(${x_offset}, ${y_offset})" style="isolation: isolate; position: relative;">`)
svg.push(` <g transform="scale(${scale}) translate(${x_offset}, ${y_offset})">`)


for (let i = 0; i < lines.length; i++) {
Expand Down Expand Up @@ -900,7 +900,9 @@
const imageLoader = getImageLoader() // Gets a new Image element from browser or node-canvas from Node.js
const ctx = canvas.getContext('2d');
if (!ctx) throw new Error('Failed to get 2d context')
const image = await imageLoader(`data:image/svg+xml;base64,${btoa(svg)}`)
const svg_base64 = `data:image/svg+xml;base64,${btoa(svg)}`
// console.log(`svg_base64:`, svg_base64)
const image = await imageLoader(svg_base64)
canvas.width = image.width
canvas.height = image.height
ctx.drawImage(image, 0, 0)
Expand Down

0 comments on commit 00d5b9a

Please sign in to comment.