Skip to content

Commit ce0961f

Browse files
committed
fix: PNG wasn't using the background
1 parent 8eb2884 commit ce0961f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/components/RuneSVG/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class RuneSVG extends Component<Props, State> {
4848
// Initial state based on props
4949
state: State = {
5050
displayPhonemes: this.props.displayPhonemes ?? false,
51-
backgroundColor: this.props.backgroundColor ?? "transparent",
51+
backgroundColor: this.props.backgroundColor ?? "black",
5252
transparentBackground: this.props.transparentBackground ?? true,
5353
runeColor: this.props.runeColor ?? "crimson",
5454
runeGuideColor: this.props.runeGuideColor ?? "transparent",

src/components/RunicEditor/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class RunicEditor extends Component<Props, State> {
188188

189189
// Miscellaneous
190190

191-
download = (format: "svg" | "png" | "jpeg") => {
191+
download = async (format: "svg" | "png" | "jpeg") => {
192192
const svgElement = this.runeSVGElement.svgElement;
193193

194194
// Add background color (only if transparentBackground is disabled)
@@ -203,10 +203,10 @@ export class RunicEditor extends Component<Props, State> {
203203
const uri = svgToUri(svgElement);
204204
downloadURI(uri, `${filename}.svg`);
205205
} else {
206-
drawSVGToCanvas(svgElement).then((canvas) => {
207-
const uri = canvas.toDataURL(`image/${format}`);
208-
downloadURI(uri, `${filename}.${format}`);
209-
});
206+
// Draw the svg with styles to canvas, then download
207+
const canvas = await drawSVGToCanvas(svgElement)
208+
const uri = canvas.toDataURL(`image/${format}`);
209+
downloadURI(uri, `${filename}.${format}`);
210210
}
211211

212212
// Remove background color

0 commit comments

Comments
 (0)