mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-15 00:54:25 +02:00
Resolves #147 Flip trees upside down with flip
This commit is contained in:
parent
108937aad5
commit
937977f232
12 changed files with 61 additions and 35 deletions
|
@ -3,6 +3,7 @@ var Backbone = require('backbone');
|
|||
var GRAPHICS = require('../util/constants').GRAPHICS;
|
||||
|
||||
var VisBase = require('../visuals/visBase').VisBase;
|
||||
var GlobalState = require('../util/globalState');
|
||||
|
||||
var VisEdge = VisBase.extend({
|
||||
defaults: {
|
||||
|
@ -51,6 +52,7 @@ var VisEdge = VisBase.extend({
|
|||
// is M(move abs) C (curve to) (control point 1) (control point 2) (final point)
|
||||
// the control points have to be __below__ to get the curve starting off straight.
|
||||
|
||||
var flipFactor = (GlobalState.flipTreeY) ? -1 : 1;
|
||||
var coords = function(pos) {
|
||||
return String(Math.round(pos.x)) + ',' + String(Math.round(pos.y));
|
||||
};
|
||||
|
@ -58,19 +60,19 @@ var VisEdge = VisBase.extend({
|
|||
delta = delta || GRAPHICS.curveControlPointOffset;
|
||||
return {
|
||||
x: pos.x,
|
||||
y: pos.y + delta * dir
|
||||
y: pos.y + flipFactor * delta * dir
|
||||
};
|
||||
};
|
||||
var offset2d = function(pos, x, y) {
|
||||
return {
|
||||
x: pos.x + x,
|
||||
y: pos.y + y
|
||||
y: pos.y + flipFactor * y
|
||||
};
|
||||
};
|
||||
|
||||
// first offset tail and head by radii
|
||||
tailPos = offset(tailPos, -1, this.get('tail').getRadius());
|
||||
headPos = offset(headPos, 1, this.get('head').getRadius());
|
||||
headPos = offset(headPos, 1, this.get('head').getRadius() * 1.15);
|
||||
|
||||
var str = '';
|
||||
// first move to bottom of tail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue