Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
Upgraded canvas to 2.4.1 and ejs to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Dalbrekt committed Mar 28, 2019
1 parent 4a6ea9b commit 28f3df8
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 10 deletions.
8 changes: 5 additions & 3 deletions lib/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var filters = {

function getBoundingBox(diagram) {
var Canvas = require('canvas'),
_canvas = new Canvas(1, 1),
_canvas = Canvas.createCanvas(1, 1),
ctx = _canvas.getContext('2d'),
canvas = new mdjson.Graphics.Canvas(ctx);
var boundingBox = diagram.getBoundingBox(canvas);
Expand All @@ -63,7 +63,7 @@ function getImageData(diagram, type) {
boundingBox.expand(rectExpand);

var Canvas = require('canvas'),
_canvas = new Canvas(boundingBox.getWidth(), boundingBox.getHeight(), type),
_canvas = Canvas.createCanvas(boundingBox.getWidth(), boundingBox.getHeight(), type),
ctx = _canvas.getContext('2d'),
canvas = new mdjson.Graphics.Canvas(ctx);

Expand Down Expand Up @@ -111,6 +111,8 @@ function exportDiagramBulk(diagrams, filename, format, options, fn) {
filename = filename || "<%=diagram.name%>.png";
format = format || "png";
options = options || {};

var path = filename.endsWith("/") ? filename + "<%=diagram.name%>.png" : filename;

// if elements parameter is selector expression, retrieve them from Repository.
if (_.isString(diagrams)) {
Expand All @@ -132,7 +134,7 @@ function exportDiagramBulk(diagrams, filename, format, options, fn) {
for (var i = 0, len = diagrams.length; i < len; i++) {
try {
options.diagram = diagrams[i];
renderedFilename = ejs.render(filename, options);
renderedFilename = ejs.render(path, options);
fs.ensureFileSync(renderedFilename);
if (format === "png") {
exportDiagramAsPNG(options.diagram, renderedFilename);
Expand Down
Loading

0 comments on commit 28f3df8

Please sign in to comment.