From abb86e1c53551ec315c543534226197d46a26ddf Mon Sep 17 00:00:00 2001 From: Bernard Xie Date: Wed, 14 Dec 2022 10:35:15 -0800 Subject: [PATCH 1/4] increase png export quality by 1.5 --- lib/png/generate_png.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/png/generate_png.js b/lib/png/generate_png.js index 133cadba8..735100662 100644 --- a/lib/png/generate_png.js +++ b/lib/png/generate_png.js @@ -11,8 +11,8 @@ async (imgString) => { }; const img = await loadImage(); const canvas = document.createElement("canvas"); - canvas.width = img.width; - canvas.height = img.height; + canvas.width = img.width * 1.5; + canvas.height = img.height * 1.5; const ctx = canvas.getContext("2d"); if (!ctx) { return new Error("could not get canvas context"); From b3a47c845a20e3d32e333f5fe86dda7df791c61a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 18 Dec 2022 20:25:29 -0800 Subject: [PATCH 2/4] bump upscale factor --- lib/png/generate_png.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/png/generate_png.js b/lib/png/generate_png.js index 735100662..8c1c40806 100644 --- a/lib/png/generate_png.js +++ b/lib/png/generate_png.js @@ -11,8 +11,8 @@ async (imgString) => { }; const img = await loadImage(); const canvas = document.createElement("canvas"); - canvas.width = img.width * 1.5; - canvas.height = img.height * 1.5; + canvas.width = img.width * 2; + canvas.height = img.height * 2; const ctx = canvas.getContext("2d"); if (!ctx) { return new Error("could not get canvas context"); From 0331d20617d17c9c9d27689c2fbd9d729a1b8325 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 18 Dec 2022 20:31:41 -0800 Subject: [PATCH 3/4] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 28e0ab2af..f3697a1b2 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -9,6 +9,7 @@ - `d2 fmt` now preserves leading comment spacing. [#400](https://github.com/terrastruct/d2/issues/400) - Markdown can now be styled with keywords stroke and fill. [https://github.com/terrastruct/d2/pull/460](https://github.com/terrastruct/d2/pull/460) +- PNG export resolution increased by 2x to not be blurry exporting on retina displays. [https://github.com/terrastruct/d2/pull/445](https://github.com/terrastruct/d2/pull/445) #### Bugfixes ⛑️ From 850d38910db1ac11fd19d6a0b0621a338b9f46bc Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 18 Dec 2022 20:33:33 -0800 Subject: [PATCH 4/4] update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3293a0cdd..18e337c82 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ one, please see [./d2renderers/d2fonts](./d2renderers/d2fonts). ## Export file types -D2 currently supports SVG exports. More coming soon. +D2 currently supports SVG and PNG exports. More coming soon. ## Language tooling @@ -209,6 +209,7 @@ let us know and we'll be happy to include it here! - **Emacs extension**: [https://github.com/andorsk/d2-mode](https://github.com/andorsk/d2-mode) - **Telegram bot**: [https://github.com/meinside/telegram-d2-bot](https://github.com/meinside/telegram-d2-bot) - **Postgres importer**: [https://github.com/zekenie/d2-erd-from-postgres](https://github.com/zekenie/d2-erd-from-postgres) +- **Structurizr to D2 exporter**: [https://github.com/goto1134/structurizr-d2-exporter](https://github.com/goto1134/structurizr-d2-exporter) ### Misc