[Fixed Position] Draw line as SVG

Draw line elements as SVG, WTD-880.
This commit is contained in:
Victor Woeltjen
2015-02-20 15:02:16 -08:00
parent 638a7c8609
commit 2c0180ebda
6 changed files with 100 additions and 15 deletions

View File

@ -11,7 +11,12 @@ define(
fill: "#888",
border: "transparent"
},
"fixed.line": {},
"fixed.line": {
x: 0,
y: 0,
x2: 5,
y2: 3
},
"fixed.text": {
fill: "transparent",
border: "transparent"

View File

@ -1,13 +1,13 @@
/*global define*/
define(
['./TelemetryProxy', './ElementProxy'],
function (TelemetryProxy, ElementProxy) {
['./TelemetryProxy', './ElementProxy', './LineProxy'],
function (TelemetryProxy, ElementProxy, LineProxy) {
"use strict";
return {
"fixed.telemetry": TelemetryProxy,
"fixed.line": ElementProxy,
"fixed.line": LineProxy,
"fixed.box": ElementProxy,
"fixed.image": ElementProxy,
"fixed.text": ElementProxy

View File

@ -0,0 +1,63 @@
/*global define*/
define(
['./ElementProxy'],
function (ElementProxy) {
'use strict';
/**
*
*/
function LineProxy(element, index, elements) {
var proxy = new ElementProxy(element, index, elements);
proxy.x = function (v) {
var x = Math.min(element.x, element.x2),
delta = v - x;
if (arguments.length > 0 && delta) {
element.x += delta;
element.x2 += delta;
}
return x;
};
proxy.y = function (v) {
var y = Math.min(element.y, element.y2),
delta = v - y;
if (arguments.length > 0 && delta) {
element.y += delta;
element.y2 += delta;
}
return y;
};
proxy.width = function () {
return Math.max(element.x, element.x2) - proxy.x();
};
proxy.height = function () {
return Math.max(element.y, element.y2) - proxy.y();
};
proxy.x1 = function () {
return element.x - proxy.x();
};
proxy.y1 = function () {
return element.y - proxy.y();
};
proxy.x2 = function () {
return element.x2 - proxy.x();
};
proxy.y2 = function () {
return element.y2 - proxy.y();
};
return proxy;
}
return LineProxy;
}
);