-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add napi-rs and wasm_bindgen bindings to bbox
- Loading branch information
Showing
18 changed files
with
310 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ jobs: | |
run: cargo fmt -- --check | ||
|
||
- name: Clippy | ||
run: cargo clippy | ||
run: cargo clippy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { promises } = require('fs') | ||
const { join } = require('path') | ||
const { performance } = require('perf_hooks') | ||
|
||
const { Resvg } = require('../index') | ||
|
||
async function main() { | ||
const svg = await promises.readFile(join(__dirname, './bbox.svg')) | ||
|
||
const opts = { | ||
fitTo: { | ||
mode: 'width', | ||
value: 500, | ||
}, | ||
font: { | ||
loadSystemFonts: false, | ||
}, | ||
} | ||
|
||
const t = performance.now() | ||
const resvg = new Resvg(svg, opts) | ||
const bbox = resvg.innerBBox() | ||
const pngData = resvg.render() | ||
const pngBuffer = pngData.asPng() | ||
|
||
console.info('SVG BBox:', `${bbox.width} x ${bbox.height}`) | ||
console.info('Original SVG Size:', `${resvg.width} x ${resvg.height}`) | ||
console.info('Output PNG Size :', `${pngData.width} x ${pngData.height}`) | ||
console.info('✨ Done in', performance.now() - t, 'ms') | ||
|
||
await promises.writeFile(join(__dirname, './bbox-out.png'), pngBuffer) | ||
} | ||
|
||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.