mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-24 04:34:34 +02:00
RIPPING out arbor.js code
This commit is contained in:
parent
f5fcd32815
commit
51ab487003
20 changed files with 1 additions and 3355 deletions
|
@ -20,7 +20,6 @@ var CommandBuffer = Backbone.Model.extend({
|
|||
|
||||
this.buffer = [];
|
||||
this.timeout = null;
|
||||
this.delay = TIME.betweenCommandsDelay;
|
||||
},
|
||||
|
||||
addCommand: function(command) {
|
||||
|
@ -43,7 +42,7 @@ var CommandBuffer = Backbone.Model.extend({
|
|||
setTimeout: function() {
|
||||
this.timeout = setTimeout(_.bind(function() {
|
||||
this.sipFromBuffer();
|
||||
}, this), this.delay);
|
||||
}, this), TIME.betweenCommandsDelay);
|
||||
},
|
||||
|
||||
popAndProcess: function() {
|
||||
|
|
|
@ -23,22 +23,8 @@
|
|||
</div>
|
||||
|
||||
<script src="../lib/jquery-1.8.0.min.js"></script>
|
||||
<!-- Include the individual arbor source files so we can extend-->
|
||||
<script src="../arbor_src/etc.js"></script>
|
||||
<script src="../arbor_src/kernel.js"></script>
|
||||
<script src="../arbor_src/graphics/colors.js"></script>
|
||||
<script src="../arbor_src/graphics/primitives.js"></script>
|
||||
<script src="../arbor_src/graphics/graphics.js"></script>
|
||||
<script src="../arbor_src/tween/easing.js"></script>
|
||||
<script src="../arbor_src/tween/tween.js"></script>
|
||||
<script src="../arbor_src/physics/atoms.js"></script>
|
||||
<script src="../arbor_src/physics/barnes-hut.js"></script>
|
||||
<script src="../arbor_src/physics/physics.js"></script>
|
||||
<script src="../arbor_src/physics/system.js"></script>
|
||||
<script src="../arbor_src/dev.js"></script>
|
||||
|
||||
<script src="../lib/Tween.js"></script>
|
||||
<script src="../lib/rgbcolor.js"></script>
|
||||
<script src="../lib/underscore-min.js"></script>
|
||||
<script src="../lib/backbone-min.js"></script>
|
||||
|
||||
|
|
107
src/legacy.js
107
src/legacy.js
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* this code is adapted from the excellent ArborJS tutorial by
|
||||
* Samizdat Drafting Co
|
||||
*/
|
||||
|
||||
Renderer = function(canvas) {
|
||||
canvas = $(canvas).get(0);
|
||||
var ctx = canvas.getContext("2d");
|
||||
var particleSystem = null;
|
||||
|
||||
var that = {
|
||||
init: function(system){
|
||||
particleSystem = system;
|
||||
particleSystem.screen({padding:[100, 100, 100, 100],
|
||||
step:.02});
|
||||
$(window).resize(that.resize);
|
||||
that.resize();
|
||||
that.initMouseHandling();
|
||||
},
|
||||
|
||||
drawNode: function(node, pt) {
|
||||
// node: {mass:#, p:{x,y}, name:"", data:{}}
|
||||
// pt: {x:#, y:#} node position in screen coords
|
||||
node.draw(ctx, pt);
|
||||
},
|
||||
|
||||
drawEdge: function(edge, pt1, pt2) {
|
||||
// edge: {source:Node, target:Node, length:#, data:{}}
|
||||
// pt1: {x:#, y:#} source position in screen coords
|
||||
// pt2: {x:#, y:#} target position in screen coords
|
||||
edge.draw(ctx, pt1, pt2);
|
||||
},
|
||||
|
||||
redraw: function(){
|
||||
if (particleSystem === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
events.trigger('fixNodePositions', particleSystem);
|
||||
|
||||
ctx.clearRect(0,0, canvas.width, canvas.height);
|
||||
particleSystem.eachEdge(this.drawEdge);
|
||||
particleSystem.eachNode(this.drawNode);
|
||||
|
||||
events.trigger('drawGitVisuals', particleSystem, ctx, canvas);
|
||||
},
|
||||
|
||||
resize: function(){
|
||||
var w = $(canvas).width(),
|
||||
h = $(canvas).height();
|
||||
// resize the canvas element to fill the screen TODO -- fix this
|
||||
canvas.width = w; canvas.height = h;
|
||||
// inform the system so it can map coords for us
|
||||
particleSystem.screenSize(w,h);
|
||||
that.redraw();
|
||||
},
|
||||
|
||||
initMouseHandling: function(){
|
||||
// no-nonsense drag and drop (thanks springy.js)
|
||||
selected = null;
|
||||
nearest = null;
|
||||
var dragged = null;
|
||||
var oldmass = 1;
|
||||
|
||||
$(canvas).mousedown(function(e){
|
||||
var pos = $(this).offset();
|
||||
var p = {x:e.pageX-pos.left, y:e.pageY-pos.top};
|
||||
selected = nearest = dragged = particleSystem.nearest(p);
|
||||
|
||||
if (selected && selected.node !== null){
|
||||
dragged.node.tempMass = constants.clickDragMass;
|
||||
dragged.node.fixed = true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$(canvas).mousemove(function(e){
|
||||
var old_nearest = nearest && nearest.node._id;
|
||||
var pos = $(this).offset();
|
||||
var s = {x:e.pageX-pos.left, y:e.pageY-pos.top};
|
||||
|
||||
nearest = particleSystem.nearest(s);
|
||||
if (!nearest) { return; }
|
||||
|
||||
if (dragged !== null && dragged.node !== null) {
|
||||
var p = particleSystem.fromScreen(s);
|
||||
dragged.node.p = {x:p.x, y:p.y};
|
||||
dragged.tempMass = constants.clickDragMass;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$(window).bind('mouseup',function(e){
|
||||
if (dragged===null || dragged.node===undefined) return
|
||||
dragged.node.fixed = false;
|
||||
dragged.node.tempMass = constants.baseMass;
|
||||
dragged = null;
|
||||
selected = null;
|
||||
return false;
|
||||
});
|
||||
|
||||
},
|
||||
}
|
||||
return that;
|
||||
}
|
||||
|
46
src/mine.js
46
src/mine.js
|
@ -3,9 +3,6 @@
|
|||
*/
|
||||
var events = _.clone(Backbone.Events);
|
||||
|
||||
var sys = null;
|
||||
var graphicsEffects = {};
|
||||
|
||||
var gitEngine = null;
|
||||
var gitVisuals = null;
|
||||
|
||||
|
@ -44,46 +41,3 @@ $(document).ready(function(){
|
|||
$('#commandTextField').focus();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Extend the Arbiter classes below with my own custom functionality.
|
||||
*/
|
||||
|
||||
Node.prototype.draw = function(ctx, pt) {
|
||||
this.drawCircleNode(ctx, pt);
|
||||
};
|
||||
|
||||
Node.prototype.drawCircleNode = function(ctx, pt) {
|
||||
ctx.strokeStyle = graphics.nodeEdge;
|
||||
ctx.lineWidth = graphics.nodeStrokeWidth;
|
||||
ctx.fillStyle = graphics.nodeFill;
|
||||
var radius = graphics.nodeRadius;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.arc(pt.x, pt.y, radius, 0, Math.PI*2, true);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
ctx.fill();
|
||||
};
|
||||
|
||||
/**
|
||||
* Edge
|
||||
*/
|
||||
Edge.prototype.draw = function(ctx, pt1, pt2) {
|
||||
this.drawLine(ctx, pt1, pt2);
|
||||
};
|
||||
|
||||
Edge.prototype.drawLine = function(ctx, pt1, pt2, opacityPercent) {
|
||||
var color = new Color(graphics.edgeStroke);
|
||||
color.a = color.a * (opacityPercent === undefined ? 1 : opacityPercent);
|
||||
|
||||
ctx.lineWidth = graphics.edgeWidth + 1;
|
||||
ctx.strokeStyle = color.toRGBA();
|
||||
ctx.fillStyle = null;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pt1.x, pt1.y);
|
||||
ctx.lineTo(pt2.x, pt2.y);
|
||||
ctx.stroke();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue