diagram-js-origin
Advanced tools
Comparing version 0.14.1 to 0.15.0
@@ -0,6 +1,13 @@ | ||
var svgAppend = require('tiny-svg/lib/append'), | ||
svgAttr = require('tiny-svg/lib/attr'), | ||
svgCreate = require('tiny-svg/lib/create'); | ||
function ConfigureOrigin(canvas) { | ||
var base = canvas.getLayer('bg'); | ||
var g = base.group(), | ||
w = 30, h = 2, | ||
var g = svgCreate('g'); | ||
svgAppend(g, base); | ||
var w = 30, h = 2, | ||
style = { | ||
@@ -12,6 +19,39 @@ 'fill': '#CCC', | ||
// two rectangles that mark the diagram origin | ||
g.rect(w / -2 - 1, h / -2 - 1, w, h, h / 2).attr(style); | ||
g.rect(h / -2 - 1, w / -2 - 1, h, w, h / 2).attr(style); | ||
var horizontal = svgCreate('rect'); | ||
g.text(-40, -10, '(0, 0)').attr(style); | ||
svgAttr(horizontal, { | ||
x: w / -2 - 1, | ||
y: h / -2 - 1, | ||
width: w, | ||
height: h, | ||
rx: h / 2 | ||
}); | ||
svgAttr(horizontal, style); | ||
svgAppend(horizontal, g); | ||
var vertical = svgCreate('rect'); | ||
svgAttr(vertical, { | ||
x: h / -2 - 1, | ||
y: w / -2 - 1, | ||
width: h, | ||
height: w, | ||
rx: h / 2 | ||
}); | ||
svgAttr(vertical, style); | ||
svgAppend(vertical, g); | ||
var text = svgCreate('text'); | ||
svgAttr(text, { | ||
x: -40, | ||
y: -10, | ||
text: '(0, 0)' | ||
}); | ||
svgAttr(text, style); | ||
svgAppend(text, g); | ||
} | ||
@@ -21,2 +61,2 @@ | ||
module.exports = ConfigureOrigin; | ||
module.exports = ConfigureOrigin; |
{ | ||
"name": "diagram-js-origin", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"description": "A origin crosshair for diagram-js", | ||
@@ -20,2 +20,5 @@ "scripts": { | ||
"license": "MIT", | ||
"dependencies": { | ||
"tiny-svg": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
@@ -22,0 +25,0 @@ "brfs": "^1.2.0", |
8897
127
2
+ Addedtiny-svg@^0.1.0
+ Addedtiny-svg@0.1.3(transitive)