leafer-ui icon indicating copy to clipboard operation
leafer-ui copied to clipboard

node环境下使用napi的问题

Open bgyh2003 opened this issue 2 months ago • 1 comments

import { useCanvas, Rect, Leafer } from "@leafer/node"
import napi from '@napi-rs/canvas'
import dataUrlToFile from "../utils/dataUrlToFile"
useCanvas("napi", napi)

describe('leafer', () => {

    test('rect', async () => {

        const leafer = new Leafer({
            width: 800,
            height: 600
        });


        const rect = new Rect({
            width: 500,
            height: 500,
            rotation: 45,
            fill: "red",
            stroke: "yellow",
            strokeWidth: 5,
            shadow: { color: "#333", blur: 30, x: 50, y: 50 },
            dashPattern: [20, 5],
            dashOffset: 1,
            innerShadow: { color: "blue", blur: 20, x: 10, y: 10 }
        })

        leafer.add(rect)

        const res = await leafer.export('png')
        dataUrlToFile(res.data, __dirname + "/rect2.png")

    })

})




最终生成的图片乱了

Image

bgyh2003 avatar Nov 10 '25 07:11 bgyh2003

收到,谢谢反馈~

leaferjs avatar Nov 10 '25 11:11 leaferjs