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
@ -1128,15 +1128,14 @@ export default (function () {
|
|||||||
svgImage.setAttribute("height", dh);
|
svgImage.setAttribute("height", dh);
|
||||||
svgImage.setAttribute("preserveAspectRatio", "none");
|
svgImage.setAttribute("preserveAspectRatio", "none");
|
||||||
|
|
||||||
if (sx || sy || sw !== image.width || sh !== image.height) {
|
// Crop the image using a temporary canvas and convert to a bitmap
|
||||||
//crop the image using a temporary canvas
|
|
||||||
canvas = this.__document.createElement("canvas");
|
canvas = this.__document.createElement("canvas");
|
||||||
canvas.width = dw;
|
canvas.width = dw;
|
||||||
canvas.height = dh;
|
canvas.height = dh;
|
||||||
context = canvas.getContext("2d");
|
context = canvas.getContext("2d");
|
||||||
context.drawImage(image, sx, sy, sw, sh, 0, 0, dw, dh);
|
context.drawImage(image, sx, sy, sw, sh, 0, 0, dw, dh);
|
||||||
image = canvas;
|
image = canvas;
|
||||||
}
|
|
||||||
this.__applyTransformation(svgImage, matrix);
|
this.__applyTransformation(svgImage, matrix);
|
||||||
svgImage.setAttributeNS(
|
svgImage.setAttributeNS(
|
||||||
"http://www.w3.org/1999/xlink",
|
"http://www.w3.org/1999/xlink",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aha-app/svgcanvas",
|
"name": "@aha-app/svgcanvas",
|
||||||
"version": "2.5.0-a11",
|
"version": "2.5.0-a12",
|
||||||
"description": "svgcanvas",
|
"description": "svgcanvas",
|
||||||
"main": "dist/svgcanvas.js",
|
"main": "dist/svgcanvas.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -9,6 +9,7 @@ import ellipse2 from "./tests/ellipse2";
|
|||||||
import fillstyle from "./tests/fillstyle";
|
import fillstyle from "./tests/fillstyle";
|
||||||
import globalAlpha from "./tests/globalalpha";
|
import globalAlpha from "./tests/globalalpha";
|
||||||
import gradient from "./tests/gradient";
|
import gradient from "./tests/gradient";
|
||||||
|
import image from "./tests/image";
|
||||||
import linecap from "./tests/linecap";
|
import linecap from "./tests/linecap";
|
||||||
import linewidth from "./tests/linewidth";
|
import linewidth from "./tests/linewidth";
|
||||||
import scaledLine from "./tests/scaledLine";
|
import scaledLine from "./tests/scaledLine";
|
||||||
@ -36,6 +37,7 @@ const tests = [
|
|||||||
fillstyle,
|
fillstyle,
|
||||||
globalAlpha,
|
globalAlpha,
|
||||||
gradient,
|
gradient,
|
||||||
|
image,
|
||||||
linecap,
|
linecap,
|
||||||
linewidth,
|
linewidth,
|
||||||
scaledLine,
|
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