Force all images to be inline bitmaps.
Otherwise the SVGs we generate can't be opened by editing tools like Figma.
This commit is contained in:
parent
4f7bcfec4c
commit
7fe0aeaaea
17
context.js
17
context.js
@ -1128,15 +1128,14 @@ export default (function () {
|
||||
svgImage.setAttribute("height", dh);
|
||||
svgImage.setAttribute("preserveAspectRatio", "none");
|
||||
|
||||
if (sx || sy || sw !== image.width || sh !== image.height) {
|
||||
//crop the image using a temporary canvas
|
||||
canvas = this.__document.createElement("canvas");
|
||||
canvas.width = dw;
|
||||
canvas.height = dh;
|
||||
context = canvas.getContext("2d");
|
||||
context.drawImage(image, sx, sy, sw, sh, 0, 0, dw, dh);
|
||||
image = canvas;
|
||||
}
|
||||
// Crop the image using a temporary canvas and convert to a bitmap
|
||||
canvas = this.__document.createElement("canvas");
|
||||
canvas.width = dw;
|
||||
canvas.height = dh;
|
||||
context = canvas.getContext("2d");
|
||||
context.drawImage(image, sx, sy, sw, sh, 0, 0, dw, dh);
|
||||
image = canvas;
|
||||
|
||||
this.__applyTransformation(svgImage, matrix);
|
||||
svgImage.setAttributeNS(
|
||||
"http://www.w3.org/1999/xlink",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aha-app/svgcanvas",
|
||||
"version": "2.5.0-a11",
|
||||
"version": "2.5.0-a12",
|
||||
"description": "svgcanvas",
|
||||
"main": "dist/svgcanvas.js",
|
||||
"scripts": {
|
||||
|
@ -9,6 +9,7 @@ import ellipse2 from "./tests/ellipse2";
|
||||
import fillstyle from "./tests/fillstyle";
|
||||
import globalAlpha from "./tests/globalalpha";
|
||||
import gradient from "./tests/gradient";
|
||||
import image from "./tests/image";
|
||||
import linecap from "./tests/linecap";
|
||||
import linewidth from "./tests/linewidth";
|
||||
import scaledLine from "./tests/scaledLine";
|
||||
@ -36,6 +37,7 @@ const tests = [
|
||||
fillstyle,
|
||||
globalAlpha,
|
||||
gradient,
|
||||
image,
|
||||
linecap,
|
||||
linewidth,
|
||||
scaledLine,
|
||||
|
18
test/tests/image.js
Normal file
18
test/tests/image.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user