Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Commit

Permalink
draw: support old-style connectors w/ no angle, but x, y
Browse files Browse the repository at this point in the history
For compatability.
  • Loading branch information
bpowers committed Sep 12, 2015
1 parent 566b511 commit 53e848d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ CommonJS modules in the `lib/` directory.
TODO
----

- fix sweep/inverse flags in connectors
- refactor/add-in support for old-style connectors w/o `angle` attrib
- intersection of arc w/ rectangle for takeoff from stock
- intersection of arc w/ rounded-rect for takeoff from module
- refactor/add-in support for old-style connectors w/o `angle` attrib
- add-back isee compat support
- logging framework

Expand Down
7 changes: 3 additions & 4 deletions lib/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,13 @@ var DConnector = (function () {
DConnector.prototype.drawLabel = function () { };
DConnector.prototype.visualize = function () { };
DConnector.prototype.arcCircle = function () {
if (!this.e.hasOwnProperty('angle')) {
console.log('FIXME: support non-spec x,y connectors');
return null;
}
var from = this.drawing.namedEnts[this.e.from];
var to = this.drawing.namedEnts[this.e.to];
if (!from || !to)
return;
if (!this.e.hasOwnProperty('angle')) {
return circleFromPoints({ x: from.cx, y: from.cy }, { x: to.cx, y: to.cy }, { x: this.e.x, y: this.e.y });
}
var slopeTakeoff = tan(this.takeoffθ());
var slopePerpToTakeoff = -1 / slopeTakeoff;
if (isZero(slopePerpToTakeoff))
Expand Down
7 changes: 3 additions & 4 deletions sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -13926,14 +13926,13 @@ define('draw',["require", "exports", './runtime', "./util", "../bower_components
DConnector.prototype.drawLabel = function () { };
DConnector.prototype.visualize = function () { };
DConnector.prototype.arcCircle = function () {
if (!this.e.hasOwnProperty('angle')) {
console.log('FIXME: support non-spec x,y connectors');
return null;
}
var from = this.drawing.namedEnts[this.e.from];
var to = this.drawing.namedEnts[this.e.to];
if (!from || !to)
return;
if (!this.e.hasOwnProperty('angle')) {
return circleFromPoints({ x: from.cx, y: from.cy }, { x: to.cx, y: to.cy }, { x: this.e.x, y: this.e.y });
}
var slopeTakeoff = tan(this.takeoffθ());
var slopePerpToTakeoff = -1 / slopeTakeoff;
if (isZero(slopePerpToTakeoff))
Expand Down
2 changes: 1 addition & 1 deletion sd.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,16 +875,18 @@ class DConnector implements Ent {

// TODO: handle old-style connectors w/ x and y but no angle.
private arcCircle(): Circle {
if (!this.e.hasOwnProperty('angle')) {
console.log('FIXME: support non-spec x,y connectors');
return null;
}

const from = this.drawing.namedEnts[this.e.from];
const to = this.drawing.namedEnts[this.e.to];
if (!from || !to)
return;

if (!this.e.hasOwnProperty('angle')) {
return circleFromPoints(
{x: from.cx, y: from.cy},
{x: to.cx, y: to.cy},
{x: this.e.x, y: this.e.y});
}

// Find cx, cy from 'takeoff angle', and center of
// 'from', and center of 'to'. This means we have 2
// points on the edge of a cirlce, and the tangent at
Expand Down

0 comments on commit 53e848d

Please sign in to comment.