mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
arrow consistency
This commit is contained in:
parent
7f7681320e
commit
529fce3209
1 changed files with 34 additions and 23 deletions
57
src/tree.js
57
src/tree.js
|
@ -6,10 +6,11 @@ var VisBranch = Backbone.Model.extend({
|
||||||
arrow: null,
|
arrow: null,
|
||||||
offsetX: GRAPHICS.nodeRadius * 4.75,
|
offsetX: GRAPHICS.nodeRadius * 4.75,
|
||||||
offsetY: 0,
|
offsetY: 0,
|
||||||
arrowInnerMargin: 8,
|
arrowHeight: 14,
|
||||||
arrowLength: 15,
|
arrowInnerSkew: 0,
|
||||||
arrowRatio: 3.5,
|
arrowEdgeHeight: 6,
|
||||||
arrowEdgeHeight: 5,
|
arrowLength: 14,
|
||||||
|
arrowOffsetFromCircleX: 10,
|
||||||
vPad: 5,
|
vPad: 5,
|
||||||
hPad: 5,
|
hPad: 5,
|
||||||
animationSpeed: GRAPHICS.defaultAnimationTime,
|
animationSpeed: GRAPHICS.defaultAnimationTime,
|
||||||
|
@ -81,32 +82,42 @@ var VisBranch = Backbone.Model.extend({
|
||||||
y: pos.y + y
|
y: pos.y + y
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
var coords = function(pos) {
|
var toStringCoords = function(pos) {
|
||||||
return String(Math.round(pos.x)) + ',' + String(Math.round(pos.y));
|
return String(Math.round(pos.x)) + ',' + String(Math.round(pos.y));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var arrowTip = offset2d(this.getCommitPosition(),
|
||||||
|
this.get('arrowOffsetFromCircleX'),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
var arrowEdgeUp = offset2d(arrowTip, this.get('arrowLength'), -this.get('arrowHeight'));
|
||||||
|
var arrowEdgeLow = offset2d(arrowTip, this.get('arrowLength'), this.get('arrowHeight'));
|
||||||
|
|
||||||
// worst variable names evar!!! warning
|
var arrowInnerUp = offset2d(arrowEdgeUp,
|
||||||
// start at rect corner
|
this.get('arrowInnerSkew'),
|
||||||
var overlap = 5;
|
this.get('arrowEdgeHeight')
|
||||||
var startPos = offset2d(this.getRectPosition(), overlap, this.get('arrowInnerMargin'));
|
);
|
||||||
// first the beginning of the head
|
var arrowInnerLow = offset2d(arrowEdgeLow,
|
||||||
var next = offset2d(startPos, -this.get('arrowLength'), 0);
|
this.get('arrowInnerSkew'),
|
||||||
// head side point
|
-this.get('arrowEdgeHeight')
|
||||||
var next2 = offset2d(next, 0, -this.get('arrowEdgeHeight'));
|
);
|
||||||
// head point
|
|
||||||
var next3 = offset2d(this.getCommitPosition(),
|
|
||||||
3, 0);
|
|
||||||
|
|
||||||
// get the next three points in backwards order
|
var tailLength = 30;
|
||||||
var end = offset2d(this.getRectPosition(), overlap, this.getSingleRectSize().h - this.get('arrowInnerMargin'));
|
var arrowStartUp = offset2d(arrowInnerUp, tailLength, 0);
|
||||||
var beforeEnd = offset2d(end, -this.get('arrowLength'), 0);
|
var arrowStartLow = offset2d(arrowInnerLow, tailLength, 0);
|
||||||
var beforeBeforeEnd = offset2d(beforeEnd, 0, this.get('arrowEdgeHeight'));
|
|
||||||
|
|
||||||
var pathStr = '';
|
var pathStr = '';
|
||||||
pathStr += 'M' + coords(startPos) + ' ';
|
pathStr += 'M' + toStringCoords(arrowStartUp) + ' ';
|
||||||
_.each([next, next2, next3, beforeBeforeEnd, beforeEnd, end], function(pos) {
|
var coords = [
|
||||||
pathStr += 'L' + coords(pos) + ' ';
|
arrowInnerUp,
|
||||||
|
arrowEdgeUp,
|
||||||
|
arrowTip,
|
||||||
|
arrowEdgeLow,
|
||||||
|
arrowInnerLow,
|
||||||
|
arrowStartLow
|
||||||
|
];
|
||||||
|
_.each(coords, function(pos) {
|
||||||
|
pathStr += 'L' + toStringCoords(pos) + ' ';
|
||||||
}, this);
|
}, this);
|
||||||
pathStr += 'z';
|
pathStr += 'z';
|
||||||
return pathStr;
|
return pathStr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue