Permalink
Browse files

Add parallel line markers to parallel lines #FIXIT

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D423
  • Loading branch information...
1 parent 0a0d34f commit cf70efbd6f5a985beaad5d35081bcb9a618e13c2 @beneater beneater committed Jul 20, 2012
@@ -24,6 +24,7 @@
});
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, true );
graph.pl.drawAngle( UNKNOWN_INDEX, false, "#FFA500" );
@@ -36,6 +36,7 @@
});
graph.pl = new ParallelLines(0, 0, 10, 0, 3);
graph.pl.draw();
+ graph.pl.drawMarkers(ANGLE);
graph.pl.drawTransverse(ANGLE);
graph.pl.drawAngle(KNOWN_INDEX, eq1);
graph.pl.drawAngle(UNKNOWN_INDEX, eq2, "#FFA500");
@@ -24,6 +24,7 @@
});
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, true );
graph.pl.drawAngle( UNKNOWN_INDEX, false, "#FFA500" );
@@ -36,6 +36,7 @@
});
graph.pl = new ParallelLines(0, 0, 10, 0, 3);
graph.pl.draw();
+ graph.pl.drawMarkers(ANGLE);
graph.pl.drawTransverse(ANGLE);
graph.pl.drawAngle(KNOWN_INDEX, eq1);
graph.pl.drawAngle(UNKNOWN_INDEX, eq2, "#FFA500");
@@ -25,6 +25,7 @@
});
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, true );
graph.pl.drawAngle( UNKNOWN_INDEX, false, "#FFA500" );
@@ -37,6 +37,7 @@
});
graph.pl = new ParallelLines(0, 0, 10, 0, 3);
graph.pl.draw();
+ graph.pl.drawMarkers(ANGLE);
graph.pl.drawTransverse(ANGLE);
graph.pl.drawAngle(KNOWN_INDEX, eq1);
graph.pl.drawAngle(UNKNOWN_INDEX, eq2, "#FFA500");
@@ -24,6 +24,7 @@
});
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, true );
graph.pl.drawAngle( UNKNOWN_INDEX, false, "#FFA500" );
@@ -36,6 +36,7 @@
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, eq1 );
graph.pl.drawAngle( UNKNOWN_INDEX, eq2, "#FFA500" );
@@ -24,6 +24,7 @@
});
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, true );
graph.pl.drawAngle( UNKNOWN_INDEX, false, "#FFA500" );
@@ -35,6 +35,7 @@
});
graph.pl = new ParallelLines( 0, 0, 10, 0, 3 );
graph.pl.draw();
+ graph.pl.drawMarkers(ANCHOR);
graph.pl.drawTransverse( ANCHOR );
graph.pl.drawAngle( KNOWN_INDEX, eq1 );
graph.pl.drawAngle( UNKNOWN_INDEX, eq2, "#FFA500" );
View
@@ -293,6 +293,32 @@ function ParallelLines(x1, y1, x2, y2, distance) {
graph.line([x1, y1 + distance], [x2, y2 + distance]);
};
+ this.drawMarkers = function(position) {
+ var graph = KhanUtil.currentGraph;
+ var pmarkX = (x2 - x1) / 2 + x1;
+ if (position === "right" || (position >= 40 && position <= 140)) {
+ pmarkX = x2 - 55 / graph.scaleVector([1, 1])[0];
+ } else if (position === "left") {
+ pmarkX = x1 + 50 / graph.scaleVector([1, 1])[0];
+ }
+ var pmarkX1 = pmarkX;
+ var pmarkX2 = pmarkX + 5 / graph.scaleVector([1, 1])[0];
+ var pmarkW = 5 / graph.scaleVector([1, 1])[0];
+ var pmarkH = 5 / graph.scaleVector([1, 1])[1];
+ graph.path([[pmarkX1 - pmarkW, y1 + pmarkH],
+ [pmarkX1, y1],
+ [pmarkX1 - pmarkW, y1 - pmarkH]]);
+ graph.path([[pmarkX2 - pmarkW, y1 + pmarkH],
+ [pmarkX2, y1],
+ [pmarkX2 - pmarkW, y1 - pmarkH]]);
+ graph.path([[pmarkX1 - pmarkW, y1 + pmarkH + distance],
+ [pmarkX1, y1 + distance],
+ [pmarkX1 - pmarkW, y1 - pmarkH + distance]]);
+ graph.path([[pmarkX2 - pmarkW, y1 + pmarkH + distance],
+ [pmarkX2, y1 + distance],
+ [pmarkX2 - pmarkW, y1 - pmarkH + distance]]);
+ };
+
this.drawTransverse = function(angleDeg) {
anchorAngle = angleDeg;
var graph = KhanUtil.currentGraph;
@@ -601,4 +627,4 @@ function labelDirection(angle) {
} else if (angle > 270 && angle < 360) {
return "below right";
}
-}
+}

0 comments on commit cf70efb

Please sign in to comment.