Skip to content
Browse files

More shaded areas fixes: improve fill and stroke colors, close polygo…

…ns properly
  • Loading branch information...
1 parent c173b5b commit bcd94c7014536fa7f56426c93cb0294be68a76a7 @osnr osnr committed Jul 11, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 exercises/shaded_areas.html
View
9 exercises/shaded_areas.html
@@ -79,21 +79,22 @@
triangle: function(x, y, size) {
var s = 2*size,
- v = [[x, y], [x + s, y], [x + s/2, y + sqrt(3)*s/2], [x, y]],
+ v = [[x, y], [x + s, y], [x + s/2, y + sqrt(3)*s/2]],
centroid = [(v[0][0] + v[1][0] + v[2][0]) / 3,
(v[0][1] + v[1][1] + v[2][1]) / 3];
// recenter the triangle
v = _.map(v, function(vertex) {
return [vertex[0] - centroid[0], vertex[1] - centroid[1]];
});
+ v.push(true);
var sign = function(p1, p2, p3) {
return (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]);
};
return {
- vertices: v,
+ vertices: _.initial(v),
contains: function(point) {
var b1, b2, b3;
@@ -148,8 +149,8 @@
<div class="graphie" id="shapes">
var g = init({ range: [[-14, 14], [-14, 14]], scale: [11, 11] });
- graph.outerShape = OUTER.drawShape(g, { fill: GRAY, stroke: "black" });
- graph.innerShape = INNER.drawShape(g, { fill: "white", stroke: "black" });
+ graph.outerShape = OUTER.drawShape(g, { fill: BLUE, stroke: BLUE, "fill-opacity": 0.5 });
+ graph.innerShape = INNER.drawShape(g, { fill: "#f8f8f8", stroke: BLUE });
graph.outerSize = OUTER.drawSize(g, { stroke: BLUE, opacity: 1 });
graph.innerSize = INNER.drawSize(g, { stroke: ORANGE, opacity: 1 }, true);

0 comments on commit bcd94c7

Please sign in to comment.
Something went wrong with that request. Please try again.