Skip to content

Commit 47d0f73

Browse files
committed
Export bitmap image with upscaling
1 parent 6da71ad commit 47d0f73

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
"dependencies": {
3232
"jszip": "^3.10.1"
3333
}
34-
}
34+
}

rspack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
code: './src/code.ts',
55
},
66
resolve: {
7-
extensions: ['.ts'],
7+
extensions: ['.ts', '.js'],
88
},
99
output: {
1010
chunkFilename: 'code.js',

src/Element.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,19 @@ export class Element {
265265
addAsset(node: SceneNode, type: 'svg' | 'png') {
266266
if (this.parent) this.parent.addAsset(node, type)
267267
else
268-
this.assets[node.name + '.' + type] = () =>
269-
node.exportAsync({
270-
format: type === 'svg' ? 'SVG' : 'PNG',
268+
this.assets[node.name + '.' + type] = async () => {
269+
const isSvg = type === 'svg'
270+
const data = await node.exportAsync({
271+
format: isSvg ? 'SVG' : 'PNG',
272+
constraint: isSvg
273+
? undefined
274+
: {
275+
type: 'SCALE',
276+
value: 1.5,
277+
},
271278
})
279+
return data
280+
}
272281
}
273282

274283
async render(dep: number = 0): Promise<string> {

0 commit comments

Comments
 (0)