Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

anim functions

  • Loading branch information...
commit 7d65f1d6ce1096ee4cc959f1f3f510caf455993e 2 parents 55ac750 + f65a198
Rafa vanhalt authored
25 index.html
View
@@ -23,6 +23,7 @@
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
+ <script src='javascripts/raphael-min.js' type='text/javascript'></script>
<script src='javascripts/get_data.js' type='text/javascript'></script>
<script src='javascripts/preprocess.js' type="text/javascript"></script>
<script src='JSOptimizer/js/taoptimizer.js' type="text/javascript"></script>
@@ -71,7 +72,7 @@
<div class="clearfix">
<label>url del gdoc (spreadsheet please)</label>
<div class="input">
- <input type="text" class="input-xxlarge" name="url" id='url' value='https://spreadsheets.google.com/feeds/cells/0Av8QEY2w-qTYdE1EX0R3a04zaEVwY0ltVU1oSkxKSWc/od5/public/basic?alt=json-in-script&callback=parseRequest' />
+ <input type="text" class="input-xxlarge" name="url" id='url' value='https://spreadsheets.google.com/feeds/cells/0Aj6IH4grpvxcdGpBNHBrelNJS0NhNjBDblFlbkVrWkE/od6/public/basic?alt=json-in-script&callback=parseRequest' />
</div>
</div>
<p>
@@ -80,7 +81,7 @@
</a>
</p>
</div>
-<div id='graph'></div>
+<div id='graph' style='width:1000px; height:1000px;'></div>
</form>
@@ -136,14 +137,20 @@
var optimizer = new TAOptimizer(p, params);
var redraw = function(o) {
- //console.log("Redraw called!");
+ console.log("Redraw called!");
var grafico = new Graficador('graph', {
- width: 1100,
- height: 1000,
- kx: 4,
- ky: 4
- });
- grafico.loadData(o.solution);
+ width: 1100,//px
+ height: 1000,//px
+ 'margin-top': 50,//px
+ 'margin-right': 50,//px
+ 'margin-bottom': 50,//px
+ 'margin-left': 50,//px
+ textoffset: 5, // -textoffset px
+ kx: 50,
+ ky: 10
+ });
+ console.log(o.solution)
+ grafico.loadData(o.solution );
}
optimizer.callback = redraw
30 javascripts/graficador.js
View
@@ -120,6 +120,7 @@ function testValues() {
var Graficador = function(div, config) {
this.divId = div;
this.config = config || {};
+ $(this.divId).empty();
this.paper = new Raphael(this.divId, this.config.width, this.config.height);
};
@@ -132,6 +133,7 @@ Graficador.prototype.defaultLine = {
};
Graficador.prototype.loadData = function (data) {
+ this.paper.clear();
for (var i=0; i< data.length; i++) {
this.writeText(data[i]);
var linesAndData = this.joinLine(data[i].segments);
@@ -188,6 +190,28 @@ Graficador.prototype.joinLine = function(segments) {
return [ret, attr];
};
+Graficador.prototype.makeRoundStringLine = function(arr) {
+ function midPoint(Ax, Ay, Bx, By) {
+ var Zx = (Ax-Bx)/2 + Bx;
+ var Zy = (Ay-By)/2 + By;
+ return [Zx, Zy];
+ }
+ var string = '';
+ for (var i=0; i < arr.length; i++) {
+ string += (i == 0)? 'M' : 'L';
+
+ Z = midPoint(point[X], point[Y], next[X], next[Y]);
+ path_string += " "+Z[X]+","+Z[Y];
+ path_string += "Q"+next[X]+","+next[Y];
+
+ string += (arr[i][0]*this.config.kx+this.config['margin-left'])+','+(arr[i][1]*this.config.ky+this.config['margin-top']);
+
+
+
+
+ }
+};
+
Graficador.prototype.makeStringLine = function(arr) {
var string = '';
for (var i=0; i < arr.length; i++) {
@@ -205,10 +229,10 @@ Graficador.prototype.writeText = function(tHash) {
tHash.name
),
opts = {};
- for (key in this.defaultText)
- opts[key] = this.defaultText[key];
+ for (key in this.defaultText)
+ opts[key] = this.defaultText[key];
for (key in (tHash.attributes || {} )){
- if (['fill', 'fill-opacity', 'font', 'font-family', 'font-size', 'font-weight', 'stroke', 'text-anchor'].indexOf(key))
+ if (['fill', 'fill-opacity', 'font', 'font-family', 'font-size', 'font-weight', 'stroke', 'text-anchor'].indexOf(key) > -1)
opts[key] = tHash.attributes[key];
}
thisText.attr(opts);
7 javascripts/preprocess.js
View
@@ -15,7 +15,7 @@ function preprocessData(data) {
var eventList = {};
for (d in data) {
if (!eventList[data[d].character]) {
- eventList[data[d].character] = [];
+ eventList[data[d].character] = {};
}
eventList[data[d].character].name = data[d].character;
if (!eventList[data[d].character].position) {
@@ -49,13 +49,14 @@ function mergeSegments(events, places_position){
pos_y = places_position[positions[position]['group']];
pos_x = positions[position]['orderBox'];
var current = [pos_x, pos_y]
- character_time['segments'].push({'start': current});
+ character_time['segments'].push({'start': current, "attributes":{"color": "#bbffbb"}});
if(prev != null) {
- positions[position - 1]['end'] = current;
+ character_time['segments'][character_time['segments'].length - 2]['end'] = current;
}
prev = current;
}
character_time['name'] = character['name'];
+ character_time['segments'].pop();
result.push(character_time);
}
return result;
15 javascripts/timelineproblem.js
View
@@ -82,16 +82,11 @@
delta = (Math.random() - 0.5) * (0.2 * 100.0 / this.numGroups);
numOperations = 2;
op = Math.round(Math.random() * numOperations);
- if (op === 0) {
- from = this.groupNames[i];
- to = this.groupNames[j];
- prevPos = this.groupPosition[to];
- this.groupPosition[to] = this.groupPosition[from];
- this.groupPosition[from] = prevPos;
- } else if (op === 1) {
- from = this.groupNames[i];
- this.groupPosition[from] += delta;
- }
+ from = this.groupNames[i];
+ to = this.groupNames[j];
+ prevPos = this.groupPosition[to];
+ this.groupPosition[to] = this.groupPosition[from];
+ this.groupPosition[from] = prevPos;
this.solution = mergeSegments(this.problem.eventList, this.groupPosition);
return this.solution;
};
24 src/timelineproblem.coffee
View
@@ -85,15 +85,21 @@ class TimeLineProblem extends ProblemInstance
# Determine what to do
numOperations = 2
op = Math.round( Math.random() * numOperations )
- if op == 0
- from = @groupNames[i]
- to = @groupNames[j]
- prevPos = @groupPosition[to]
- @groupPosition[to] = @groupPosition[from]
- @groupPosition[from] = prevPos
- else if op == 1
- from = @groupNames[i]
- @groupPosition[from] += delta
+ from = @groupNames[i]
+ to = @groupNames[j]
+ prevPos = @groupPosition[to]
+ @groupPosition[to] = @groupPosition[from]
+ @groupPosition[from] = prevPos
+
+ #if op == 0
+ # from = @groupNames[i]
+ # to = @groupNames[j]
+ # prevPos = @groupPosition[to]
+ # @groupPosition[to] = @groupPosition[from]
+ # @groupPosition[from] = prevPos
+ #else if op == 1
+ # from = @groupNames[i]
+ # @groupPosition[from] += delta
@solution = mergeSegments(@problem.eventList, @groupPosition)
return @solution
Please sign in to comment.
Something went wrong with that request. Please try again.